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

fix(gateway): make loadServiceDefinitions a private method, replace with reasonable API #555

Open
trevor-scheer opened this issue Mar 9, 2021 · 1 comment
Labels

Comments

@trevor-scheer
Copy link
Member

Right now, there's a use case for subclassing ApolloGateway in order to override the loadServiceDefinitions method. This is very effectively similar to providing a function to the experimental_updateServiceDefinitions "hook", however said hook doesn't have access to the original loadServiceDefinitions fn on the gateway which can be useful.

A few reasonable alternatives to this (proposed by @glasser):

  • pass a reference to loadServiceDefinitions into the experimental_updateServiceDefinitions hook
  • create a willUpdateServiceDefinitions hook which can modify the result of the gateway's standard service defs update
  • some other hook/config option which is more explicitly dedicated to service overrides

ref: #539

@gtkatakura
Copy link

gtkatakura commented Mar 12, 2021

I am using exactly this case you said about using the original loadServiceDefinitions today to support the relay spec into the gateway:

  protected async loadServiceDefinitions(config: GatewayConfig) {
    const defs = await super.loadServiceDefinitions(config)

    if (!defs.isNewSchema || !defs.serviceDefinitions) return defs

    await this.mergeLocalServiceDefinitions(defs.serviceDefinitions)
    await this.mergeLocalGraphQLModule(defs.serviceDefinitions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants