Stabilize @defer/@stream snapshots with canonical envelope#9935
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request stabilizes @defer/@stream snapshot output by changing CookieCrumble’s execution-result formatting to emit a canonical incremental-delivery “envelope” that is independent of how the transport batches response payloads.
Changes:
- Reworked
ExecutionResultSnapshotValueFormatterto reconstruct a single canonical envelope (data+ collectedpending/incremental/completed, ordered byid) across all payloads. - Updated defer/stream tests to use the normal
MatchSnapshot/MatchMarkdownSnapshotAPIs and re-recorded snapshots to reflect the canonical envelope. - Removed the aggregated snapshot APIs/formatter hooks (now redundant given canonical formatting).
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Core/test/Execution.Tests/StreamTests.cs | Switch stream tests from aggregated snapshot helper to standard MatchSnapshot(). |
| src/HotChocolate/Core/test/Execution.Tests/DeferTests.cs | Switch defer tests from aggregated markdown snapshot helper to standard MatchMarkdownSnapshot(). |
| src/HotChocolate/Core/test/Execution.Tests/DeferReferenceTests.cs | Switch defer reference tests from aggregated markdown snapshot helper to standard MatchMarkdownSnapshot(). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/StreamTests.Stream.snap | Update snapshot to canonical incremental-delivery envelope. |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/StreamTests.Stream_Nested_Defer.snap | Update snapshot to canonical incremental-delivery envelope (nested defer). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/StreamTests.Stream_Label_Set_To_abc.snap | Update snapshot to canonical incremental-delivery envelope (label). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/StreamTests.Stream_InitialCount_Set_To_1.snap | Update snapshot to canonical incremental-delivery envelope (initialCount=1). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/StreamTests.Stream_InitialCount_Exceeds_Total_Count.snap | Update snapshot to canonical incremental-delivery envelope (initialCount exceeds total). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.InlineFragment_Defer.md | Update snapshot to canonical incremental-delivery envelope (inline fragment defer). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.InlineFragment_Defer_Nested.md | Update snapshot to canonical incremental-delivery envelope (nested). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.InlineFragment_Defer_Label_Set_To_abc.md | Update snapshot to canonical incremental-delivery envelope (label). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.FragmentSpread_Defer.md | Update snapshot to canonical incremental-delivery envelope (fragment spread). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.FragmentSpread_Defer_Nested.md | Update snapshot to canonical incremental-delivery envelope (nested). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.FragmentSpread_Defer_Label_Set_To_abc.md | Update snapshot to canonical incremental-delivery envelope (label). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.Ensure_GlobalState_Is_Passed_To_DeferContext_Stacked_Defer.md | Update snapshot to canonical incremental-delivery envelope (stacked defer). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.Ensure_GlobalState_Is_Passed_To_DeferContext_Stacked_Defer_2.md | Update snapshot to canonical incremental-delivery envelope (stacked defer variant). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.Ensure_GlobalState_Is_Passed_To_DeferContext_Single_Defer.md | Update snapshot to canonical incremental-delivery envelope (single defer). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferTests.Ensure_GlobalState_Is_Passed_To_DeferContext_Single_Defer_2.md | Update snapshot to canonical incremental-delivery envelope (single defer variant). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferReferenceTests.InlineFragment_Defer_With_TypeCondition.md | Update snapshot to canonical incremental-delivery envelope (type condition). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferReferenceTests.Emits_Children_Of_Empty_Defer_Fragment.md | Update snapshot to canonical incremental-delivery envelope (empty fragment). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferReferenceTests.Defer_Fragment_With_Errors_On_Top_Level_Query_Field.md | Update snapshot to canonical incremental-delivery envelope (deferred errors). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferReferenceTests.Defer_Fragment_With_Error.md | Update snapshot to canonical incremental-delivery envelope (deferred resolver error). |
| src/HotChocolate/Core/test/Execution.Tests/snapshots/DeferReferenceTests.Deduplicates_List_Fields_In_Initial_Payload.md | Update snapshot to canonical incremental-delivery envelope (dedup behavior visibility). |
| src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/SnapshotValueFormatters.cs | Removes the ExecutionResultAggregated formatter accessor. |
| src/CookieCrumble/src/CookieCrumble.HotChocolate/Formatters/ExecutionResultSnapshotValueFormatter.cs | Implements canonical incremental-delivery envelope reconstruction for streamed results. |
| src/CookieCrumble/src/CookieCrumble.HotChocolate/Extensions/SnapshotExtensions.cs | Removes the aggregated snapshot extension methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Coverage OverviewLanguages: C# C# / code-coverage/dotnetThe overall coverage in the branch remains at 49%, unchanged from the branch. Show a code coverage summary of the most impacted files.
Code Coverage is in Public Preview. Learn more and provide us with your feedback. |
This was referenced Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@defer/@streamsnapshots rendered differently depending on how the transport batched the response (one bundled payload vs. several), making them nondeterministic — the cause of an intermittent snapshot mismatch.ExecutionResultSnapshotValueFormatterto reconstruct a single, delivery-order-independent incremental-delivery envelope (datapluspending/incremental/completedgathered across all payloads and ordered byid), so the snapshot is identical whether the response was bundled or split.labels, paths, and field deduplication are all visible, which the previous merged form silently dropped.MatchAggregatedSnapshot/MatchAggregatedMarkdownSnapshotand theExecutionResultAggregatedformatter; migrates the defer/stream tests toMatchSnapshot/MatchMarkdownSnapshotand re-records 20 snapshots.StableExecutionResultSnapshotValueFormatteris left untouched.Test plan
HotChocolate.Execution.Testsgreen on net9.0 (614 passed, 1 skipped).DeferTests,DeferReferenceTests, andStreamTestsrepeatedly across separate process launches on net8.0, net9.0, and net10.0 — 0 failures (previously ~40–65% flaky per run on every framework).