@vtex/api
Version:
VTEX I/O API client
22 lines (21 loc) • 716 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = void 0;
const graphql_1 = require("graphql");
const run = (executableSchema) => async function runHttpQuery(ctx, next) {
const { graphql: { query }, } = ctx;
const { document, operationName, variables: variableValues } = query;
const schema = executableSchema.schema;
const response = await (0, graphql_1.execute)({
contextValue: ctx,
document,
fieldResolver: (root, _, __, info) => root[info.fieldName],
operationName,
rootValue: null,
schema,
variableValues,
});
ctx.graphql.graphqlResponse = response;
await next();
};
exports.run = run;