-
Notifications
You must be signed in to change notification settings - Fork 254
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
feat(gateway): Implement new supergraphSdl()
config option for dynamic gateway updates
#1246
feat(gateway): Implement new supergraphSdl()
config option for dynamic gateway updates
#1246
Conversation
c0f34e8
to
93c1244
Compare
c0afe14
to
c705f2e
Compare
903bb5f
to
0850b4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops didn't send this comment last week
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a little skim to the stuff we talked about previously. Liking it overall!
d26e1e1
to
ee9901f
Compare
e490145
to
3797c84
Compare
c2a88ea
to
bef9604
Compare
44dd614
to
8bd64aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you agree with me and drop the duplicate calls to wrapSchemaWithAliasResolver (and the functions themselves) and look at the CHANGELOG tweaks below, then this looks good to me!
This is going to simultaneously enable folks to do more sophisticated things with schema loading and make understanding the state machine in index.ts much easier. Great work!
…mic gateway updates (#1246) (copied from the changelog entry) This change improves the `supergraphSdl` configuration option to provide a clean and flexible interface for updating gateway schema on load and at runtime. This PR brings a number of updates and deprecations to the gateway. Previous options for loading the gateway's supergraph (`serviceList`, `localServiceList`, `experimental_updateServiceDefinitions`, `experimental_supergraphSdl`) are all deprecated going forward. The migration paths all point to the updated `supergraphSdl` configuration option. The most notable change here is the introduction of the concept of a `SupergraphManager` (one new possible type of `supergraphSdl`). This interface (when implemented) provides a means for userland code to update the gateway supergraph dynamically, perform subgraph healthchecks, and access subgraph datasources. All of the mentioned deprecated configurations now either use an implementation of a `SupergraphManager` internally or export one to be configured by the user (`IntrospectAndCompose` and `LocalCompose`). For now: all of the mentioned deprecated configurations will still continue to work as expected. Their usage will come with deprecation warnings advising a switch to `supergraphSdl`. * `serviceList` users should switch to the now-exported `IntrospectAndCompose` class. * `localServiceList` users should switch to the similar `LocalCompose` class. * `experimental_{updateServiceDefinitions|supergraphSdl}` users should migrate their implementation to a custom `SupergraphSdlHook` or `SupergraphManager`. Since the gateway itself is no longer responsible for composition: * `experimental_didUpdateComposition` has been renamed more appropriately to `experimental_didUpdateSupergraph` (no signature change) * `experimental_compositionDidFail` hook is removed `experimental_pollInterval` is deprecated and will issue a warning. Its renamed equivalent is `pollIntervalInMs`. Some defensive code around gateway shutdown has been removed which was only relevant to users who are running the gateway within `ApolloServer` before v2.18. If you are still running one of these versions, server shutdown may not happen as smoothly.
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