@graphql-mesh/http
Version:
36 lines (35 loc) • 1.52 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.graphqlHandler = void 0;
const graphql_yoga_1 = require("graphql-yoga");
const utils_1 = require("@graphql-tools/utils");
const graphqlHandler = ({ getBuiltMesh, playgroundTitle, playgroundEnabled, graphqlEndpoint, corsConfig, batchingLimit, healthCheckEndpoint = '/healthcheck', extraParamNames, }) => {
const getYogaForMesh = (0, utils_1.memoize1)(function getYogaForMesh(mesh) {
return (0, graphql_yoga_1.createYoga)({
plugins: [
...mesh.plugins,
(0, graphql_yoga_1.useLogger)({
skipIntrospection: true,
logFn: (eventName, { args }) => {
if (eventName.endsWith('-start')) {
mesh.logger.debug(`\t headers: `, args.contextValue.headers);
}
},
}),
],
extraParamNames,
logging: mesh.logger,
maskedErrors: false,
graphiql: playgroundEnabled && {
title: playgroundTitle,
},
cors: corsConfig,
graphqlEndpoint,
landingPage: false,
batching: batchingLimit ? { limit: batchingLimit } : false,
healthCheckEndpoint,
});
});
return (request, ctx) => getBuiltMesh().then(mesh => getYogaForMesh(mesh).handleRequest(request, ctx));
};
exports.graphqlHandler = graphqlHandler;
;