Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support gateways without executors #5539

Merged
merged 1 commit into from
Jul 23, 2021
Merged

Commits on Jul 23, 2021

  1. Support gateways without executors

    Previously gateways could express their executor in two ways: as the
    executor method (required to exist!) and as part of the return value
    from load (which was ignored!).
    
    Now we just return it from load, and allow it to be null.
    
    This supports a mocking use case. Fixes #5518. It lets you do something
    like:
    
        import { addMocksToSchema } from '@graphql-tools/mock';
        const realGateway = new ApolloGateway();
        const gateway: GatewayInterface = {
          async load(options) {
            const { schema } = await realGateway.load(options);
            return {
              schema: addMocksToSchema({ schema }),
              executor: null,
            };
          }
          stop() {
            return realGateway.stop();
          }
          onSchemaLoadOrUpdate(callback) {
            return realGateway.onSchemaLoadOrUpdate(callback);
          }
        };
        const server = new ApolloServer({ gateway });
    
    to define a server that follows a managed federation graph but executes
    queries using mocking.
    glasser committed Jul 23, 2021
    Configuration menu
    Copy the full SHA
    443c2ff View commit details
    Browse the repository at this point in the history