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

Add apollo options to gateway.load() #3143

Open
kanopa opened this issue Dec 18, 2023 · 0 comments
Open

Add apollo options to gateway.load() #3143

kanopa opened this issue Dec 18, 2023 · 0 comments

Comments

@kanopa
Copy link

kanopa commented Dec 18, 2023

Is your feature request related to a problem? Please describe.
Provide apollo config to gateway.load() for nestjs-federation package. Its allows to use apollo rover and load graphql schema through apollo studio, its also add possibility to see change log schema. This additionally solves the problem of starting several backends at the same time since IntrospectAndCompose throws an error if one of the servers did not have time to get up.

The disadvantage of this approach is that you will have to generate the hash key yourself, which is usually generated by Apollo

apolloConfig.keyHash = createSHA('sha512') .update(apolloConfig.key).digest('hex');

https://unpkg.com/browse/apollo-server-core@2.22.1/src/determineApolloConfig.ts

I think we can give the opportunity to forward these parameters and add this feature to the documentation and leave the “dangerous” functionality on the side of the package users

I see its something like this
Gateway typescript config

gateway?: GatewayConfig & { loadOptions?: Parameters<ApolloGateway['load']>[0] };
const { server: serverOpts = {}, gateway: gOpts = {} } = options;
    const { loadOptions, ...gatewayOpts } = gOpts
    const gateway: ApolloGateway = new ApolloGateway(gatewayOpts);
    await gateway.load(loadOptions);

    await super.start({
      ...serverOpts,
      plugins: [...(serverOpts.plugins || []), useApolloFederation({ gateway })],
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant