Created
January 14, 2017 04:42
-
-
Save bencooling/fb6f27e89b792f49ba57ebed088513e1 to your computer and use it in GitHub Desktop.
javascript: graphql
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
const { graphql, buildSchema } = require('graphql'); | |
const schema = buildSchema(` | |
type Query { | |
hello: String, | |
} | |
`); | |
const query = '{ hello }'; | |
const resolver = { hello: () => 'Hello world!' } | |
graphql(schema, query, resolver).then(console.log); |
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
const { | |
graphql, | |
GraphQLSchema, | |
GraphQLObjectType, | |
GraphQLString | |
} = require('graphql'); | |
const schema = new GraphQLSchema({ | |
query: new GraphQLObjectType({ | |
name: 'RootQueryType', | |
fields: { | |
hello: { | |
type: GraphQLString, | |
resolve() { | |
return 'world'; | |
} | |
} | |
} | |
}) | |
}); | |
var query = '{ hello }'; | |
graphql(schema, query).then(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment