Skip to content

feat(incremental-planner): add @defer support - #10143

Draft
tninesling wants to merge 3 commits into
tninesling/inc-port-14-type-conditionsfrom
tninesling/inc-port-15-defer
Draft

feat(incremental-planner): add @defer support#10143
tninesling wants to merge 3 commits into
tninesling/inc-port-14-type-conditionsfrom
tninesling/inc-port-15-defer

Conversation

@tninesling

@tninesling tninesling commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements @defer directive support in the incremental planner.

  • New defer.rs module: extract_defer_label, strip_defer_directive, defer_context, build_defer_info with unit tests
  • defer_ref propagated through PendingSelection; fetch groups keyed by (subgraph, merge_at, defer_ref)
  • Plan builder partitions by defer_ref, wrapping deferred groups in DeferNode/PrimaryDeferBlock/DeferredDeferBlock
  • Type-conditions defer awareness: try_pass_through_fragment and try_vacuous_type_condition extract defer labels and propagate defer_ref
  • Strips @defer from inline fragment op path elements so the directive doesn't leak into subgraph operations
  • Uses response_name() in defer serialization so aliased fields get correct response keys
  • Adds debug_assert for unlabeled @defer invariant (upstream normalization guarantees labels)

Test plan

  • Unit tests: defer_produces_defer_node, synthesized_defer_labels_do_not_leak_into_plan, defer_same_subgraph_produces_defer_node, defer_sibling_blocks_produces_multiple_deferred

Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • PR description explains the motivation for the change and relevant context for reviewing
  • PR description links appropriate GitHub/Jira tickets (creating when necessary)
  • Changeset is included for user-facing changes
  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Metrics and logs are added3 and documented
  • Tests added and passing4
    • Unit tests
    • Integration tests
    • Manual tests, as necessary

Exceptions

No user-facing changes; internal planner feature behind feature flag.

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. A lot of (if not most) features benefit from built-in observability and debug-level logs. Please read this guidance on metrics best-practices.

  4. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@tninesling
tninesling requested review from a team as code owners September 2, 2026 22:13
@apollo-librarian

apollo-librarian Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

1 new, 20 changed, 0 removed
+ graphos/routing/(latest)/upgrade/from-router-v2.mdx
* graphos/routing/(latest)/configuration/yaml.mdx
* graphos/routing/(latest)/customization/native-plugins.mdx
* graphos/routing/(latest)/customization/coprocessor/index.mdx
* graphos/routing/(latest)/customization/rhai/index.mdx
* graphos/routing/(latest)/observability/graphos/graphos-reporting.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/index.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/apm-guides/datadog/router-instrumentation.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/apm-guides/datadog/connecting-to-datadog/datadog-agent/datadog-agent-traces.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/apm-guides/jaeger/jaeger-traces.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/apm-guides/zipkin/zipkin-traces.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/conditions.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/selectors.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/spans.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/enabling-telemetry/standard-instruments.mdx
* graphos/routing/(latest)/observability/router-telemetry-otel/telemetry-pipelines/trace-exporters/overview.mdx
* graphos/routing/(latest)/performance/caching/response-caching/faq.mdx
* graphos/routing/(latest)/security/demand-control.mdx
* graphos/routing/(latest)/self-hosted/containerization/proxy-certificates.mdx
* graphos/routing/(latest)/upgrade/from-router-v1.mdx
* graphos/routing/(latest)/_sidebar.yaml

Build ID: 8867e967e13a15ce5350cd78
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/8867e967e13a15ce5350cd78


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@mergify

mergify Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 1 protections blocking · waiting on ⛓️ dependency

Protection Waiting on
🔴 ⛓️ Depends-On Requirements ⛓️ dependency

🔴 ⛓️ Depends-On Requirements

Waiting for

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

@tninesling
tninesling marked this pull request as draft September 2, 2026 23:12
@tninesling tninesling changed the title tninesling/inc port 15 defer feat(incremental-planner): add @defer support Sep 2, 2026
tninesling and others added 3 commits September 2, 2026 20:20
New defer.rs module: extract_defer_label, strip_defer_directive,
defer_context, build_defer_info with unit tests. defer_ref propagated
through PendingSelection. Fetch groups keyed by (subgraph, merge_at,
defer_ref). Plan builder partitions by defer_ref, wrapping deferred
groups in DeferNode/PrimaryDeferBlock/DeferredDeferBlock.

Type-conditions defer awareness: try_pass_through_fragment and
try_vacuous_type_condition extract defer labels and propagate defer_ref.

Strips @defer from inline fragment op path elements so the directive
does not leak into subgraph operations. Uses response_name() in defer
serialization so aliased fields get correct response keys.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Upstream normalization guarantees every @defer has a label by the time
plan building runs. Assert this so silent data loss is caught early if
the invariant ever breaks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add plan_query_with_defer helper and 4 tests covering @defer behavior:
- defer_produces_defer_node
- synthesized_defer_labels_do_not_leak_into_plan
- defer_same_subgraph_produces_defer_node
- defer_sibling_blocks_produces_multiple_deferred

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tninesling
tninesling force-pushed the tninesling/inc-port-15-defer branch from 33236b3 to 650221f Compare September 3, 2026 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant