Files
payload/src/graphql/graphQLHandler.ts
Dan Ribbens ad43cbc808 feat: graphql schema output (#730)
* chore: refactor graphql initialization

* feat: generate graphql schema script

* feat: script commands are case insenstive
2022-07-08 13:50:46 -04:00

22 lines
595 B
TypeScript

import { graphqlHTTP } from 'express-graphql';
import { Response } from 'express';
import { PayloadRequest } from '../express/types';
const graphQLHandler = (req: PayloadRequest, res: Response) => {
const { payload } = req;
payload.errorResponses = null;
return graphqlHTTP(
async (request, response, { variables }) => ({
schema: payload.schema,
customFormatErrorFn: payload.customFormatErrorFn,
extensions: payload.extensions,
context: { req, res },
validationRules: payload.validationRules(variables),
}),
);
};
export default graphQLHandler;