Dynamically generate graphql schema, resolve using services

This commit is contained in:
rijkvanzanten
2020-09-30 20:37:21 -04:00
parent 7ac0ab1de6
commit 551cb19e9a
7 changed files with 1017 additions and 24925 deletions

View File

@@ -0,0 +1,16 @@
import { Router } from 'express';
import { graphqlHTTP } from 'express-graphql';
import { GraphQLService } from '../services';
import asyncHandler from 'express-async-handler';
const router = Router();
router.use(asyncHandler(async (req, res) => {
const service = new GraphQLService({ accountability: req.accountability });
const schema = await service.getSchema();
graphqlHTTP({ schema, graphiql: true })(req, res);
}));
export default router;