'use strict'; const router = require('express').Router(); const { createHandler } = require("graphql-http/lib/use/express"); /// Include graphql schema and resolvers const schemaDescription = require('./graphql/schema.js'); const schemaResolvers = require('./graphql/resolvers.js'); router.get('/test', async (req, res) => { console.log( req.graphQLContext ); res.status(200).send({ msg : "It is alive!" }); } ); router.post( '/graphql', createHandler({ schema: schemaDescription, rootValue : schemaResolvers, context: async (req, params) => { return { graphQLContext : req.raw.graphQLContext }; }, graphiql: true }) ); module.exports = router;