Properly handle @defer in DocumentRewriter#9699
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Fusion’s DocumentRewriter to properly account for executable @defer directives during selection rewriting/merging, and adds coverage (unit + snapshot/benchmark-style) to lock in the new behavior.
Changes:
- Add
@deferawareness toDocumentRewriterby introducing defer scopes/contexts and emitting rewritten deferred selections as... @defer { ... }. - Add extensive
DocumentRewriterTestscovering overlap/strip/push-down behavior for deferred selections (including nested/conditional cases). - Add “benchmark parity” planning tests + snapshots and update Fusion benchmark project wiring (plus BenchmarkDotNet versioning).
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/HotChocolate/Fusion/test/Fusion.Utilities.Tests/Rewriters/DocumentRewriterTests.cs |
Adds many new unit tests asserting correct @defer rewrite semantics (strip/push-down/preserve). |
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Planning/FusionBenchmarkTests.cs |
Adds snapshot-based planning tests intended to stay in sync with benchmark inputs. |
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Planning/__snapshots__/FusionBenchmarkTests.Simple_Query_With_Requirements.yaml |
New snapshot for the “simple query” benchmark-planning test. |
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Planning/__snapshots__/FusionBenchmarkTests.Conditional_Redundancy_Query.yaml |
New snapshot for the “conditional redundancy” benchmark-planning test. |
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Planning/__snapshots__/FusionBenchmarkTests.Complex_Query.yaml |
New snapshot for the “complex query” benchmark-planning test. |
src/HotChocolate/Fusion/src/Fusion.Utilities/Rewriters/DocumentRewriter.cs |
Implements defer scoping, back-references, and deferred selection emission. |
src/HotChocolate/Fusion/HotChocolate.Fusion.slnx |
Updates benchmark project path to renamed csproj. |
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/OperationPlannerBenchmark.cs |
Adds planner benchmark that uses rewritten documents. |
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/OperationCompilerBenchmark.cs |
Adds compiler benchmark (+ dotMemory diagnoser). |
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/InlineFragmentOperationRewriterBenchmark.cs |
Adds benchmark for inline-fragment operation rewriting. |
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/HotChocolate.Fusion.Execution.Benchmarks.csproj |
Adds dotMemory package + missing Fusion.Composition reference; reflects renamed project file. |
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/FusionBenchmarkBase.cs |
Introduces shared schema/document builders used by new benchmarks. |
src/HotChocolate/Fusion/benchmarks/Fusion.Execution.Benchmarks/DocumentRewriterBenchmark.cs |
Adds benchmark for DocumentRewriter. |
src/Directory.Packages.props |
Updates BenchmarkDotNet version and adds dotMemory package version. |
src/All.slnx |
Updates benchmark project path to renamed csproj. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.