Skip to content

[Fusion] Add @propagateNull directive#9999

Open
michaelstaib wants to merge 3 commits into
mainfrom
mst/propagate-null
Open

[Fusion] Add @propagateNull directive#9999
michaelstaib wants to merge 3 commits into
mainfrom
mst/propagate-null

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 29, 2026 09:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces a @propagateNull directive for Fusion lookup fields to treat a null lookup result as invalidating the resolved entity, enabling dependent lookups to be skipped and improving error propagation behavior.

Changes:

  • Composition: add @propagateNull directive, validation rules, and merger/enricher support to translate it into fusion__lookup(propagateNull: true).
  • Planning/serialization: carry propagateNull through operation plan nodes (JSON/YAML), include it in operation signature hashing, and add dependency ordering to ensure propagate-null lookups run before other lookups on the same entity.
  • Execution/results: update merge/completion logic to invalidate entities on propagated nulls, adjust variable mapping to skip invalidated/null elements, and add focused execution/composition tests + snapshot updates.

Reviewed changes

Copilot reviewed 43 out of 45 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Results/FetchResultStoreTests.cs Update test for new merge API
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/PropagateNullLookupExecutionTests.cs New end-to-end propagate-null execution tests
src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaValidationRules/PropagateNullOnNonLookupFieldRuleTests.cs New validation rule tests
src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaValidationRules/PropagateNullNotRepeatableRuleTests.cs New repeatability rule tests
src/HotChocolate/Fusion/test/Fusion.Composition.Tests/SourceSchemaMerger.Object.Tests.cs Snapshot test for merged lookup metadata
src/HotChocolate/Fusion/test/Fusion.Composition.Tests/snapshots/SourceSchemaMergerTests.Merge_FourNamedSchemas_AddsFusionDefinitions.graphql Snapshot updated for new argument
src/HotChocolate/Fusion/src/Fusion.Execution/Properties/FusionExecutionResources.resx Add resource strings used by execution errors
src/HotChocolate/Fusion/src/Fusion.Execution/Properties/FusionExecutionResources.Designer.cs Generated resource accessors
src/HotChocolate/Fusion/src/Fusion.Execution/Planning/OperationPlanner.BuildExecutionTree.cs Add dependency ordering + propagateNull flag in nodes/signature
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ValueCompletion.cs Implement propagated-null completion/invalidation
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/ResultDataMapper.cs Skip invalidated/null values during variable mapping
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Results/FetchResultStore.cs Thread propagateNull through merge + skip invalidated targets
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/PendingMerge.cs Carry propagateNull into deferred merges
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanContext.cs Pass propagateNull into result store merges
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/SingleOperationDefinition.cs Add propagateNull to operation definitions
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/Serialization/YamlOperationPlanFormatter.cs Serialize propagateNull in YAML plans
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/Serialization/JsonOperationPlanParser.cs Parse propagateNull from JSON plans
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/Serialization/JsonOperationPlanFormatter.cs Serialize propagateNull in JSON plans
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs Execute with propagateNull-aware merges
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationDefinition.cs Store propagateNull on base definition
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationBatchExecutionNode.cs Pass propagateNull through batch execution
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/EventStreamExecutionNode.cs Explicitly disable propagateNull for events
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/BatchOperationDefinition.cs Add propagateNull to batch definitions
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/ErrorHelper.cs Centralize error creation + use resources
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Metadata/Lookup.cs Persist propagateNull in lookup metadata
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Directives/LookupDirectiveParser.cs Parse propagateNull from fusion__lookup
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Directives/LookupDirective.cs Add propagateNull field to directive model
src/HotChocolate/Fusion/src/Fusion.Execution.Types/Completion/CompletionTools.cs Flow propagateNull into Lookup metadata
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownDirectiveNames.cs Add WellKnown name for directive
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownArgumentNames.cs Add WellKnown name for argument
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaValidationRules/PropagateNullOnNonLookupFieldRule.cs New validation rule implementation
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaValidationRules/PropagateNullNotRepeatableRule.cs New validation rule implementation
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaMerger.cs Emit propagateNull into fusion__lookup arguments
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaEnricher.cs Track HasPropagateNullDirective metadata
src/HotChocolate/Fusion/src/Fusion.Composition/SchemaComposer.cs Register new validation rules
src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.resx Add directive/arg descriptions + log text
src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs Generated resource accessors
src/HotChocolate/Fusion/src/Fusion.Composition/Logging/LogEntryHelper.cs Add log entries for new validations
src/HotChocolate/Fusion/src/Fusion.Composition/Logging/LogEntryCodes.cs Add new error codes
src/HotChocolate/Fusion/src/Fusion.Composition/FusionBuiltIns.cs Register new built-in directive
src/HotChocolate/Fusion/src/Fusion.Composition/Features/SourceOutputFieldMetadata.cs Add HasPropagateNullDirective flag
src/HotChocolate/Fusion/src/Fusion.Composition/Extensions/OutputFieldDefinitionExtensions.cs Expose HasPropagateNullDirective
src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/PropagateNullMutableDirectiveDefinition.cs Define @propagateNull directive
src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/FusionLookupMutableDirectiveDefinition.cs Add propagateNull argument to fusion__lookup
src/HotChocolate/Fusion/benchmarks/k6/Directory.Build.props Adjust benchmark target framework
Files not reviewed (2)
  • src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs: Generated file
  • src/HotChocolate/Fusion/src/Fusion.Execution/Properties/FusionExecutionResources.Designer.cs: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

<value>The request exceeded the configured timeout of `{0}`.</value>
</data>
<data name="ErrorHelper_StateInvalidForOperationPlanCache_Message" xml:space="preserve">
<value>The operation plan cache requires a operation document hash.</value>
@tobias-tengler tobias-tengler changed the title Add propagateNull directive [Fusion] Add @propagateNull directive Jun 29, 2026
@github-actions github-actions Bot added the 📚 documentation This issue is about working on our documentation. label Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📚 documentation This issue is about working on our documentation. 🌶️ hot chocolate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants