Skip to content

Instantly share code, notes, and snippets.

@maticzav
Created February 22, 2018 10:50
Show Gist options
  • Save maticzav/32941181e5447444a384c0ffa4d62a6d to your computer and use it in GitHub Desktop.
Save maticzav/32941181e5447444a384c0ffa4d62a6d to your computer and use it in GitHub Desktop.
import { GraphQLServer } from 'graphql-yoga'
import { importSchema } from 'graphql-import'
import { Prisma } from './generated/prisma'
import { Context } from './utils'
const resolvers = {
Query: {
async allBooks(parent, args, ctx, info) {
return await ctx.db.query.books({}, info)
}
},
}
const server = new GraphQLServer({
typeDefs: './src/schema.graphql',
resolvers,
context: req => ({
...req,
db: new Prisma({
endpoint: 'http://localhost:4466/list-with-noinfo/dev', // the endpoint of the Prisma DB service
secret: 'mysecret123', // specified in database/prisma.yml
debug: true, // log all GraphQL queries & mutations
}),
}),
})
server.start(() => console.log('Server is running on http://localhost:4000'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment