Skip to content

Properly handle @defer in DocumentRewriter#9699

Merged
tobias-tengler merged 2 commits into
mainfrom
tte/document-rewriter-defer
May 13, 2026
Merged

Properly handle @defer in DocumentRewriter#9699
tobias-tengler merged 2 commits into
mainfrom
tte/document-rewriter-defer

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 13, 2026 13:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 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 @defer awareness to DocumentRewriter by introducing defer scopes/contexts and emitting rewritten deferred selections as ... @defer { ... }.
  • Add extensive DocumentRewriterTests covering 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.

@tobias-tengler tobias-tengler merged commit 1485dc4 into main May 13, 2026
143 of 145 checks passed
@tobias-tengler tobias-tengler deleted the tte/document-rewriter-defer branch May 13, 2026 14:28
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