Skip to content

Instantly share code, notes, and snippets.

@pedroraft
Last active April 15, 2018 17:09
Show Gist options
  • Save pedroraft/3949fc33320cc27320775e2daaef07fa to your computer and use it in GitHub Desktop.
Save pedroraft/3949fc33320cc27320775e2daaef07fa to your computer and use it in GitHub Desktop.
Basic graphql server
const { GraphQLServer } = require('graphql-yoga')
const typeDefs = `
type Query {
hello(name: String): String!
}
`
const resolvers = {
Query: {
hello: (_, { name }) => `Hello ${name || 'World'}`,
},
}
const server = new GraphQLServer({ typeDefs, resolvers })
server.start(() => console.log('Server is running on localhost:4000'))
{
"scripts": {
"start": "node ."
},
"dependencies": {
"graphql-yoga": "1.2.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment