-
Notifications
You must be signed in to change notification settings - Fork 251
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
Adds debug query planner option to skip query planning for a single s… #2441
Conversation
🦋 Changeset detectedLatest commit: 9e0653d The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
👷 Deploy request for apollo-federation-docs pending review.Visit the deploys page to approve it
|
78ab228
to
a1d19b5
Compare
a1d19b5
to
9e34f2a
Compare
// A federated query graph always have 1 more sources than there is subgraph, because the root vertices | ||
// belong to no subgraphs and use a special source named '_'. So we skip that "fake" source. | ||
const subgraphs = mapKeys(this.federatedQueryGraph.sources).filter((name) => name !== FEDERATED_GRAPH_ROOT_SOURCE); | ||
if (subgraphs.length === 1) { |
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.
Do you want the else case to error?
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.
No. I think the config name and documentation makes it clear that it only applies to single subgraphs, and it's clearly flagged as for debug/testing so I'm not really worried about someone not understanding why they don't get what they want out of this. On the flip side, erroring could make it more annoying to use as you'd have to remember to disable the option when you go from 1 to 2 subgraph, or get a runtime crash. Admittedly this is all a bit subjective since again, it is clearly flagged for debug/testing, but I personally markedly prefer it not having a else
.
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.
A couple of asks, but otherwise LGTM.
…ubgraph This commit adds a new option to the query planner config that, when used and when the supergraph is built from only a single subgraph, skip the query planning algorithm and instead generates a single fetch (to the one subgraph) that directly uses the gateway "input" query. This option is disabled by default and marked as a "debug" option as it is a bit of a hack and so we're not suggesting committing to supporting it forever. But it is easy enough to have now and can be convenient at least for testing/debugging. Note in particular that, when used, some of the features enabled by the query planner (for instance `@defer`) cannot be enabled. The option will also stop having any effect as soon as another subgraph is added, not matter what that 2nd subgraph contains.
9e34f2a
to
9e0653d
Compare
…ubgraph
This commit adds a new option to the query planner config that, when used and when the supergraph is built from only a single subgraph, skip the query planning algorithm and instead generates a single fetch (to the one subgraph) that directly uses the gateway "input" query.
This option is disabled by default and marked as a "debug" option as it is a bit of a hack and so we're not suggesting committing to supporting it forever. But it is easy enough to have now and can be convenient at least for testing/debugging.
Note in particular that, when used, some of the features enabled by the query planner (for instance
@defer
) cannot be enabled. The option will also stop having any effect as soon as another subgraph is added, not matter what that 2nd subgraph contains.