INNER CODE UNIT · JavaScript

makeGatewaySchema

gmac/schema-stitching-handbook · combining-local-and-remote-schemas/index.js:11

async function makeGatewaySchema() {
  // Make remote executors:
  // these are simple functions that query a remote GraphQL API for JSON.
  const productsExec = makeRemoteExecutor('http://localhost:4001/graphql');
  const storefrontsExec = makeRemoteExecutor('http://localhost:4002/graphql');
  const rainforestApiExec = makeRemoteExecutor('http://localhost:4001/graphql');
  const adminContext = { authHeader: 'Bearer my-app-to-app-token' };

  return stitchSchemas({
    subschemas: [
      {
        // 1. Introspect a remote schema. Simple, but there are caveats:
        // - Remote server must enable introspection.
        // - Custom directives are not included in introspection.
        schema: await introspectSchema(productsExec, adminContext),
        executor: productsExec,
      },
      {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…