Created
February 22, 2018 10:50
-
-
Save maticzav/32941181e5447444a384c0ffa4d62a6d to your computer and use it in GitHub Desktop.
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
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