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

Enable generate_query_fragments by default #6013

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

lrlna
Copy link
Member

@lrlna lrlna commented Sep 17, 2024

The router previously had experimental_reuse_query_fragments enabled by default when trying to optimize fragments before sending operations to subgraphs. While on occasion this algorithm can be more performant, we found that in vast majority of cases the query planner can be just as performant using generate_query_fragments query plan option, which also significantly reduces query size being sent to subgraphs. While the two options will produce correct responses, the queries produced internally by the query planner will differ.

This change enables generate_query_fragments by default, while disabling experimental_reuse_query_fragments. You can change this behavior with the following options:

supergraph:
  generate_query_fragments: false
  experimental_reuse_query_fragments: true

The router previously had `experimental_reuse_query_fragments` enabled by
default when trying to optimize fragments before sending operations to subgraphs.
While on occasion this algorithm can be more performant, we found that in vast
majority of cases the query planner can be just as performant using
`generate_query_fragments` query plan option, which also significantly reduces
query size being sent to subgraphs. While the two options will produce correct
responses, the queries produced internally by the query planner will differ.

This change enables `generate_query_fragments` by default, while disabling
`experimental_reuse_query_fragments`. You can change this behavior with the
following options:

```yaml
supergraph:
  generate_query_fragments: false
  experimental_reuse_query_fragments: true
```
@lrlna lrlna requested review from a team as code owners September 17, 2024 12:54
@lrlna lrlna self-assigned this Sep 17, 2024
Comment on lines 693 to 694
/// Default: true
#[serde(default = "default_generate_query_fragments")]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fails our own default tests:

Screenshot 2024-09-17 at 14 59 07

The only way for this config to have its own Default implementation is to be defined as an enum/struct, which feels wayyy too much for something like this. Any other ideas on setting up a default in a single place for this config?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove #[serde(default = "default_generate_query_fragments")] and replace two instances of generate_query_fragments.unwrap_or_default() in this file with generate_query_fragments.unwrap_or_else(default_generate_query_fragments)

Since the struct already has #[serde(default)] serde will rely on the existing impl Default for Supergraph

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i felt that using unwrap_or_else hid away the default definition. but i guess since we've got a doc comment with Default: true it's maybe a bit more clear.

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

Successfully merging this pull request may close these issues.

3 participants