mirror of
https://github.com/directus/directus.git
synced 2026-02-01 17:15:00 -05:00
21 lines
488 B
TypeScript
21 lines
488 B
TypeScript
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,
|
|
schema: req.schema,
|
|
});
|
|
const schema = await service.getSchema();
|
|
|
|
graphqlHTTP({ schema, graphiql: true })(req, res);
|
|
})
|
|
);
|
|
|
|
export default router;
|