Skip to content

[Fusion] Fix deferred fragments losing type conditions on composite fields - #10038

Merged
tobias-tengler merged 2 commits into
mainfrom
tte/fix-defer-composite-type-condition-loss
Jul 2, 2026
Merged

tobias-tengler merged 2 commits into
mainfrom
tte/fix-defer-composite-type-condition-loss

Conversation

@tobias-tengler

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 2, 2026 15:54

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

This PR fixes a Fusion defer planning bug where composite fields selected under a type condition could lose that type condition when reconstructing incremental plan operations (leading to invalid subgraph operations when the enclosing parent is abstract-typed).

Changes:

  • Track the active type condition name on FieldPathSegment when entering composite fields during defer occurrence collection.
  • When rebuilding incremental plan operations, re-wrap composite fields in an ... on <Type> inline fragment when the path segment indicates a type condition.
  • Add a regression test and snapshot covering a Node (abstract) parent with deferred fragments and a deferred composite field requiring an entity lookup across subgraphs.

Reviewed changes

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

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/DeferTests.cs Adds a regression test exercising deferred composite fields under a type condition on an abstract parent.
src/HotChocolate/Fusion/test/Fusion.AspNetCore.Tests/snapshots/DeferTests.Defer_Composite_Field_Under_Type_Condition_On_Abstract_Parent_Is_Wrapped.yaml Snapshot proving the reconstructed deferred operations preserve the type condition wrapping.
src/HotChocolate/Fusion/src/Fusion.Execution/Planning/FieldPathSegment.cs Extends path segments to carry an optional TypeCondition for later reconstruction.
src/HotChocolate/Fusion/src/Fusion.Execution/Planning/DeferOperationRewriter.cs Re-wraps reconstructed composite fields in inline fragments based on the stored path segment type condition.
src/HotChocolate/Fusion/src/Fusion.Execution/Planning/DeferOccurrenceCollector.cs Records the active type condition name onto composite path segments during traversal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tobias-tengler
tobias-tengler merged commit e841974 into main Jul 2, 2026
147 checks passed
@tobias-tengler
tobias-tengler deleted the tte/fix-defer-composite-type-condition-loss branch July 2, 2026 16:00
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (16/16)

File Covered Changed Patch %
…/src/Fusion.Execution/Planning/DeferOccurrenceCollector.cs 2 2 100.0% 🟢
…/src/Fusion.Execution/Planning/DeferOperationRewriter.cs 13 13 100.0% 🟢
…/Fusion/src/Fusion.Execution/Planning/FieldPathSegment.cs 1 1 100.0% 🟢

Project coverage: 52.5% (217101/413261 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.

2 participants