feat(gateway): Implement new supergraphSdl()
config option for dynamic gateway updates (version 2 port)
#1371
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is duplicated (ported) to v2 from PR #1246. The description is directly copied from the original PR.
This PR originally introduced a new way to update the gateway dynamically via a
supergraphSdl
function. It's grown to substantially more than that (internally).Firstly, this PR brings 2 new options for the
supergraphSdl
config. It can now be aSupergraphSdlHook
orSupergraphManager
. These new interfaces bring a much more "open" way to achieve gateway updates dynamically. These interfaces are probably best explained by their types (inconfig.ts
) and usage examples in the docs. In short, the gateway now exposes a few handles to userland code via this option, which provide access to updating the supergraph, performing subgraph health checks, and accessing a subgraphs datasource.Via some great comments from @glasser, this PR has also turned into a significant refactor (which fortunately tests and proves the flexibility of this interface). All means of updating the gateway now use the
SupergraphManager
interface under the hood. Ultimately, this should result in no change for existing use cases (minus oneexperimental
hook removal, at the moment).The gateway (instance itself) is no longer responsible for composition or polling. That responsibility now lives in various
SupergraphManager
s.The following options are now deprecated, to be removed in a future version of gateway (and relatively soon) - all superseded by the capabilities of
SupergraphManager
s. Each of these options remain viable, but we urge you to move tosupergraphSdl
.serviceList
localServiceList
experimental_updateSupergraphSdl
experimental_updateServiceDefinitions
The
experimental_pollInterval
option will also be deprecated (to be replaced by an equivalentpollIntervalInMs
).Fixes #1180
TODO
serviceList
andServiceListShim
equivalence?schemaConfigDeliveryEndpoint
(unrelated but it should have one via 1283)experimental_pollInterval
in favor ofpollIntervalInMs