Created
October 4, 2018 14:37
-
-
Save tenzan/c619b95855ad527dccdd950d0451f23f to your computer and use it in GitHub Desktop.
Section 3, Lecture 9: First GraphQL Server - Part 2
This file contains 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 { makeExecutableSchema } = require('graphql-tools'); | |
const { graphql } = require('graphql'); | |
const typeDefs = ` | |
schema = { | |
query: Query | |
} | |
type Query { | |
hello: String | |
} | |
`; | |
const resolvers = { | |
Query: { | |
hello: () => 'World' | |
} | |
}; | |
const schema = makeExecutableSchema({ typeDefs, resolvers }); | |
const query = process.argv[2]; | |
graphql(schema, query).then(result => { | |
console.log(JSON.stringify(result, null, 2)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error message when executing
node index.js "query { hello }"