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(federation): fix lifting selections when flattening inline fragments #6082

Merged
merged 3 commits into from
Sep 30, 2024

Conversation

goto-bus-stop
Copy link
Member

@goto-bus-stop goto-bus-stop commented Sep 30, 2024

Some of our customers have a query shape like this:

# type MySpecialNode implements Node & HasNodes
{
  nodes {
    __typename
    ... on MySpecialNode {
      value
    }
    ... on HasNodes {
      ... on Node {
        __typename
        ... on MySpecialNode {
          value
        }
      }
    }
  }
}

Here, we know that the second MySpecialNode fragment is redundant, as the first instance of the fragment will always already select the nodes.value field. We currently do not remove the redundant fragment.

This PR fixes flatten_unnecessary_fragments so it matches JS QP and removes the second instance of the fragment. The actual fix is 7e9adbd, the other changes in simplify.rs are to add a test and to remove some unnecessary clones.

Copy link
Contributor

@goto-bus-stop, please consider creating a changeset entry in /.changesets/. These instructions describe the process and tooling.

@router-perf
Copy link

router-perf bot commented Sep 30, 2024

CI performance tests

  • connectors-const - Connectors stress test that runs with a constant number of users
  • const - Basic stress test that runs with a constant number of users
  • demand-control-instrumented - A copy of the step test, but with demand control monitoring and metrics enabled
  • demand-control-uninstrumented - A copy of the step test, but with demand control monitoring enabled
  • enhanced-signature - Enhanced signature enabled
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • extended-reference-mode - Extended reference mode enabled
  • large-request - Stress test with a 1 MB request payload
  • no-tracing - Basic stress test, no tracing
  • reload - Reload test over a long period of time at a constant rate of users
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • step-local-metrics - Field stats that are generated from the router rather than FTV1
  • step-with-prometheus - A copy of the step test with the Prometheus metrics exporter enabled
  • step - Basic stress test that steps up the number of users over time
  • xlarge-request - Stress test with 10 MB request payload
  • xxlarge-request - Stress test with 100 MB request payload

@@ -311,16 +305,18 @@ impl InlineFragmentSelection {
// applied recursively. This could be worth investigating.
let rebased_inline_fragment =
self.inline_fragment.rebase_on(parent_type, schema)?;
let mut mutable_selections = self.selection_set.selections.clone();
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 was the cause: when lifting selections, we were looking at the un-flattened original selection set, instead of the flattened one.

Copy link
Contributor

@TylerBloom TylerBloom left a comment

Choose a reason for hiding this comment

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

LGTM! Also, I like the clean up work 😄

Copy link
Contributor

@duckki duckki left a comment

Choose a reason for hiding this comment

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

I see a reduction of mismatches from various graphs. Nice!

@duckki duckki merged commit 38e0cbe into dev Sep 30, 2024
14 of 15 checks passed
@duckki duckki deleted the renee/ROUTER-782 branch September 30, 2024 18:57
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