Files
directus/api/src/controllers/graphql.ts
rijkvanzanten 801e868554 Fix remaining eslint errors
h/t @paescuj
2021-04-29 15:55:12 -04:00

44 lines
911 B
TypeScript

import { Router } from 'express';
import { parseGraphQL } from '../middleware/graphql';
import { respond } from '../middleware/respond';
import { GraphQLService } from '../services';
import asyncHandler from '../utils/async-handler';
const router = Router();
router.use(
'/system',
parseGraphQL,
asyncHandler(async (req, res, next) => {
const service = new GraphQLService({
accountability: req.accountability,
schema: req.schema,
scope: 'system',
});
res.locals.payload = await service.execute(res.locals.graphqlParams);
return next();
}),
respond
);
router.use(
'/',
parseGraphQL,
asyncHandler(async (req, res, next) => {
const service = new GraphQLService({
accountability: req.accountability,
schema: req.schema,
scope: 'items',
});
res.locals.payload = await service.execute(res.locals.graphqlParams);
return next();
}),
respond
);
export default router;