diff options
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')); |
