diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-01-30 12:41:01 -0500 |
| commit | cd0b07b3adb36fb5ec098f9e511ab45d774fee7b (patch) | |
| tree | a203e5010219ccea1acc6bbd2c0a4bcfa0a78615 /backend/src/index.js | |
| parent | 0a1648bf47490b312169c531aeb51ef4725e8d2e (diff) | |
Move to Prisma Backend
Diffstat (limited to 'backend/src/index.js')
| -rw-r--r-- | backend/src/index.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/backend/src/index.js b/backend/src/index.js new file mode 100644 index 0000000..c73cb74 --- /dev/null +++ b/backend/src/index.js @@ -0,0 +1,33 @@ +const { GraphQLServer } = require('graphql-yoga'); +const { Prisma } = require('prisma-binding'); + +const Mutation = require('./resolvers/Mutation'); +const Query = require('./resolvers/Query'); +const AuthPayload = require('./resolvers/AuthPayload'); + +const server = new GraphQLServer({ + typeDefs: 'src/schema.graphql', + resolvers: { + // detail resolvers + Mutation, + Query, + AuthPayload, + }, + context: req => ({ + ...req, + db: new Prisma({ + typeDefs: 'src/generated/prisma.graphql', + endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma DB service (value is set in .env) + secret: process.env.PRISMA_SECRET, // taken from database/prisma.yml (value is set in .env) + debug: true, // log all GraphQL queries & mutations + }), + }), +}); + +// This is an example of custom express middlware +server.express.use((req, res, next) => { + console.log("Hi I'm middlware"); + next(); +}); + +server.start(() => console.log('Server is running on http://localhost:4000')); |
