Skip to content

[Fusion] Fix data loss when selections have differing conditions - #10234

Merged
michaelstaib merged 1 commit into
mainfrom
mst/fix-conditional-selection-hoisting
Aug 13, 2026
Merged

michaelstaib merged 1 commit into
mainfrom
mst/fix-conditional-selection-hoisting

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #10204

Copilot AI lite review requested due to automatic review settings August 13, 2026 05:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Fusion execution-planning bug where promoting conditional directives (@skip / @include) to node-level conditions could drop data when different selections were gated by different conditions. The update refines the condition-hoisting logic to only promote conditions that are common across all relevant selections, leaving non-common directives inline so the source schema evaluates them per selection.

Changes:

  • Updated operation-plan rewriting to extract and hoist only common @skip/@include conditions to the plan-step node conditions.
  • Preserved non-common conditional directives in the downstream operation document to avoid skipping whole subgraph calls incorrectly.
  • Added regression tests and snapshots for root and lookup cases (including lookup paths) to cover differing conditions and hoisting behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/HotChocolate/Fusion/src/Fusion.Execution/Planning/OperationPlanner.BuildExecutionTree.cs Reworks conditional directive hoisting to compute common conditions and rewrite selection sets accordingly.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/ConditionalTests.cs Adds new regression tests covering differing conditional directives at root and lookup selections.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/ConditionalTests.Root_Fields_Of_Same_Source_Schema_With_Differing_Conditions_Are_Fetched.yaml Snapshot for root fields from same schema with differing conditions.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/ConditionalTests.Root_Fields_With_Conditions_On_Different_Variables_Are_Fetched.yaml Snapshot for root fields gated by different variables.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/ConditionalTests.Root_Common_Condition_Is_Hoisted_And_Other_Condition_Stays_Inline.yaml Snapshot verifying common condition hoisting while keeping other conditions inline.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/ConditionalTests.Root_Condition_On_Subset_Of_Fields_Is_Not_Hoisted.yaml Snapshot verifying subset-only conditions are not hoisted.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/ConditionalTests.Root_Fields_In_Fragment_With_Differing_Conditions_Are_Fetched.yaml Snapshot covering differing conditions within an inline fragment at root.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/ConditionalTests.Lookup_Fields_With_Differing_Conditions_Are_Fetched.yaml Snapshot covering differing conditions inside lookup-resolved fields.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/ConditionalTests.Lookup_With_Path_And_Common_Condition_Is_Hoisted.yaml Snapshot verifying hoisting works when a lookup uses a path and has a common condition.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/ConditionalTests.Lookup_With_Path_And_Differing_Conditions_Are_Fetched.yaml Snapshot covering differing conditions when a lookup uses a path.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@michaelstaib
michaelstaib merged commit 63d9232 into main Aug 13, 2026
150 checks passed
@michaelstaib
michaelstaib deleted the mst/fix-conditional-selection-hoisting branch August 13, 2026 06:02
@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

93.8% of changed lines covered (122/130)

File Covered Changed Patch %
…/Planning/OperationPlanner.BuildExecutionTree.cs 122 130 93.8% 🟡
Uncovered changed lines (JSON)
{
  "sha": "6ad392d1822c6fb0371c0f748c1382181fe12db8",
  "files": [
    { "path": "src/HotChocolate/Fusion/src/Fusion.Execution/Planning/OperationPlanner.BuildExecutionTree.cs", "ranges": [[2471, 2471], [2480, 2480], [2491, 2492], [2555, 2555], [2557, 2558], [2687, 2687]] }
  ]
}

Project coverage: 54.4% (242711/445939 lines)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fusion] Silent data loss: sibling root fields with differing @skip/@include conditions are never fetched

2 participants