Skip to content

[Fusion] Skip the fetch of excluded deferred plans that no nested plan reads - #162

Open
michaelstaib wants to merge 2 commits into
mst/fusion-include-flags-oncefrom
mst/fusion-silent-plan-fetch
Open

michaelstaib wants to merge 2 commits into
mst/fusion-include-flags-oncefrom
mst/fusion-silent-plan-fetch

Conversation

@michaelstaib

Copy link
Copy Markdown
Owner

A deferred plan whose fields are all excluded by @skip or @include still sent its subgraph fetch when a nested deferred group lifted a requirement into it, even when that nested group was excluded too. The gateway now completes such a plan without starting it, unless a started nested plan reads its result.

Changes:

  • FindSkippedIncrementalPlans picks the excluded plans whose fetch no started nested plan depends on. The executor completes them without running their nodes.
  • The parent scope check walks the plan nodes without collecting the requirements.

No OperationPlanner.Version bump, no plan JSON change.

Stacked on #160.

Tests: new DeferTests in Fusion.AspNetCore.Tests cover a nested group that needs the outer data, enclosing silent groups, and plans that are skipped. The payload streams are snapshotted. The nested test fails without the fix. Fusion.Execution.Tests and DeferTests on net10.0 and net8.0 are green, except one NATS test that needs Docker.

No benchmark was run.

…n reads

A deferred plan whose fields are all excluded by skip or include still ran its fetches when a nested group lifted a requirement into it, even when that nested group was itself excluded. The plan now completes without starting unless a started nested plan reads its result.

No plan output or emitted plan JSON changes.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 00:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The enclosing-plan traversal can perform cubic work on every request, including cached plans, delaying the initial payload for deeply nested plan chains.

1 open issue
What changed in this PR

This PR avoids unnecessary Fusion subgraph fetches for excluded deferred plans while preserving fetches needed by nested plans. It builds on #160’s cached include-flag evaluation without changing planner or plan-format versions.

Changes:

  • Completes excluded plans without execution when no started nested plan needs their results.
  • Checks parent-scope requirements directly from execution nodes.
  • Adds request-count and payload snapshots covering skipped groups and required enclosing fetches.
File Description
src/​HotChocolate/​Fusion/​test/​Fusion.AspNetCore.Tests/​DeferTests.cs Adds deferred-fetch regression tests and extracts a shared gateway fixture.
src/​HotChocolate/​Fusion/​src/​Fusion.Execution/​Execution/​OperationPlanExecutor.cs Identifies skippable plans and completes them without executing nodes.

Review effort: Balanced

Comment on lines +1040 to +1042
foreach (var enclosingPlan in operationPlan.IncrementalPlans)
{
if (!deliveryGroupsByPlan[enclosingPlan].DeliveryGroups.Contains(enclosing))
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