How to use the @apollo/gateway.buildOperationContext function in @apollo/gateway

To help you get started, we’ve selected a few @apollo/gateway examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TheBrainFamily / federation-testing-tool / index.js View on Github external
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
  );
}
github apollographql / apollo-server / packages / apollo-gateway / src / __tests__ / execution-utils.ts View on Github external
}),
  );

  let errors: GraphQLError[];

  ({ 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 };
}