Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function execute(schema, query, mutation, serviceMap, variables, context) {
const operationContext = buildOperationContext(schema, query || mutation);
const queryPlan = buildQueryPlan(operationContext);
return executeQueryPlan(
queryPlan,
serviceMap,
buildRequestContext(variables, context),
operationContext
);
}
({ schema, errors } = composeAndValidate(
Object.entries(serviceMap).map(([serviceName, service]) => ({
name: serviceName,
typeDefs: service.sdl(),
})),
));
if (errors && errors.length > 0) {
throw new GraphQLSchemaValidationError(errors);
}
const operationContext = buildOperationContext(schema, request.query);
const queryPlan = buildQueryPlan(operationContext);
const result = await executeQueryPlan(
queryPlan,
serviceMap,
{
cache: undefined as any,
context: {},
request,
},
operationContext,
);
return { ...result, queryPlan };
}