Skip to content

Instantly share code, notes, and snippets.

@Angelfire
Last active December 10, 2018 21:42
Show Gist options
  • Save Angelfire/2ceeff45bd826e8fe1b980a2135ff084 to your computer and use it in GitHub Desktop.
Save Angelfire/2ceeff45bd826e8fe1b980a2135ff084 to your computer and use it in GitHub Desktop.
Very Basic GraphQL
const {
GraphQLObjectType,
GraphQLString,
GraphQLSchema,
graphql
} = require('graphql');
const schema = new GraphQLSchema({
query = new GraphQLObjectType({
name: 'Query',
fields: {
helloWorld: {
type: GraphQLString,
description: 'Hello World field',
resolve () {
return 'Hello World'
}
}
}
})
});
const query = `
query Hello {
helloWorld
}
`;
graphql(schema, query).then(result => console.log(result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment