Skip to content

Instantly share code, notes, and snippets.

@sudikrt
Last active August 4, 2019 12:05
Show Gist options
  • Save sudikrt/3c36e7941ab34ad2be5e0fb4d1d096c8 to your computer and use it in GitHub Desktop.
Save sudikrt/3c36e7941ab34ad2be5e0fb4d1d096c8 to your computer and use it in GitHub Desktop.
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