Last active
August 4, 2019 12:05
-
-
Save sudikrt/3c36e7941ab34ad2be5e0fb4d1d096c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let express = require ('express'); | |
let express_graphql = require('express-graphql'); | |
let {buildSchema} = require ('graphql'); | |
//GraphQL schema | |
var schema = buildSchema (` | |
type Query { | |
message : String | |
} | |
`); | |
//Root resolver | |
var root = { | |
message : () => 'Hello QL' | |
}; | |
//create an express server | |
//graphiql - provides a user interface in browser | |
var app = express (); | |
app.use ('/graphql', express_graphql ({ | |
schema : schema, | |
rootValue : root, | |
graphiql : true | |
})); | |
app.listen (4000, () => console.log ('Express graphQL now running on localhost:4000/graphql')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment