Skip to content

Add Fusion Subscriptions#9972

Open
michaelstaib wants to merge 11 commits into
mainfrom
mst/fed-sub
Open

Add Fusion Subscriptions#9972
michaelstaib wants to merge 11 commits into
mainfrom
mst/fed-sub

Conversation

@michaelstaib

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 23, 2026 11:22

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

Adds initial infrastructure for Fusion subscriptions by introducing an event-stream broker abstraction, composition support for a new @subscribe directive (and merged @fusion__subscribe metadata), and updates to execution/plan serialization intended to support an event-stream execution node.

Changes:

  • Introduces event-stream broker abstractions (IEventStreamBroker*), EventMessage, and subscription field context plumbing.
  • Extends composition to recognize @subscribe, validate consistent sources for shareable subscription fields, and emit @fusion__subscribe.
  • Updates operation plan execution and JSON/YAML plan (de)serialization to handle an EventStream node shape.

Reviewed changes

Copilot reviewed 39 out of 40 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Brokers/InMemoryEventStreamBrokerTests.cs Adds a test for the in-memory broker registration/subscription flow.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Brokers/InMemoryEventStreamBrokerProvider.cs Test broker provider implementation for DI wiring.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Brokers/InMemoryEventStreamBrokerHub.cs In-memory pub/sub hub used by tests.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Brokers/InMemoryEventStreamBroker.cs In-memory broker session used by tests.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Brokers/IInMemoryEventStreamPublisher.cs Test-only publisher abstraction for the in-memory hub.
src/HotChocolate/Fusion/test/Fusion.Execution.Tests/Execution/Brokers/EventStreamBrokerServiceCollectionExtensions.cs Test-only service registration helpers for the in-memory broker.
src/HotChocolate/Fusion/src/Fusion.Execution/Planning/Partitioners/SelectionSetPartitionerInput.cs Adds an optional provided selection set to the partitioner input.
src/HotChocolate/Fusion/src/Fusion.Execution/Planning/Partitioners/SelectionSetPartitioner.cs Passes through the provided selection set into partitioning.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanExecutor.cs Extends subscription execution path to support an event-stream root node.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/OperationPlanContext.cs Adjusts dependent-execution snapshot defaulting semantics.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/SubscriptionId.cs Extracts subscription id generator into its own type.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/Serialization/YamlOperationPlanFormatter.cs Adds YAML formatting for an event-stream node type.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/Serialization/JsonOperationPlanParser.cs Adds JSON parsing for an event-stream node type.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/Serialization/JsonOperationPlanFormatter.cs Adds JSON formatting for an event-stream node type.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs Removes nested subscription id helper (moved to SubscriptionId).
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Nodes/EventMessageResult.cs Extends event-message result payload used by subscriptions.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/ExecutionState.cs Updates dependent skipping logic to use default-vs-empty semantics.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Brokers/SubscriptionFieldContext.cs Implements argument substitution for subscription root field arguments.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Brokers/ISubscriptionFieldContext.cs Defines broker-facing subscription field context contract.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Brokers/IEventStreamBrokerProvider.cs Adds provider interface for broker sessions by label.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Brokers/IEventStreamBrokerFactory.cs Adds factory interface for resolving brokers by label.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Brokers/IEventStreamBroker.cs Adds broker session interface for subscribing to topics.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Brokers/EventMessage.cs Adds broker-agnostic event payload type with pooled backing memory.
src/HotChocolate/Fusion/src/Fusion.Execution/Execution/Brokers/DefaultEventStreamBrokerFactory.cs Default DI-based factory implementation for broker lookup.
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownDirectiveNames.cs Adds directive names for @subscribe and @fusion__subscribe.
src/HotChocolate/Fusion/src/Fusion.Composition/WellKnownArgumentNames.cs Adds argument name constants used by subscribe directives.
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaValidationRules/InvalidShareableUsageRule.cs Removes subscription-root special-case shareable restriction.
src/HotChocolate/Fusion/src/Fusion.Composition/SourceSchemaMerger.cs Merges @subscribe contributions into @fusion__subscribe.
src/HotChocolate/Fusion/src/Fusion.Composition/SchemaComposer.cs Registers a new pre-merge validation rule for subscribe sources.
src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.resx Adds localized message for multiple subscribe sources error.
src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs Designer update for the new localized resource.
src/HotChocolate/Fusion/src/Fusion.Composition/PreMergeValidationRules/MultipleSubscribeSourcesRule.cs New rule to validate consistent @subscribe source across schemas.
src/HotChocolate/Fusion/src/Fusion.Composition/Logging/LogEntryHelper.cs Adds log entry helper for the new validation error.
src/HotChocolate/Fusion/src/Fusion.Composition/Logging/LogEntryCodes.cs Adds log code for multiple subscribe sources.
src/HotChocolate/Fusion/src/Fusion.Composition/Info/SubscribeDirectiveInfo.cs Adds internal representation of a parsed @subscribe directive.
src/HotChocolate/Fusion/src/Fusion.Composition/FusionBuiltIns.cs Registers the new @subscribe directive definition for source schemas.
src/HotChocolate/Fusion/src/Fusion.Composition/Extensions/DirectivesProviderExtensions.cs Adds parsing helpers for extracting @subscribe directives.
src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/SubscribeMutableDirectiveDefinition.cs Defines the source-schema @subscribe directive shape.
src/HotChocolate/Fusion/src/Fusion.Composition/Definitions/FusionSubscribeMutableDirectiveDefinition.cs Defines the composed-schema @fusion__subscribe directive shape.
src/HotChocolate/Fusion/src/Fusion.Composition/CompositionHelper.cs Minor update to error array construction style.
Files not reviewed (1)
  • src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs: Generated file

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

Comment on lines +371 to +381
foreach (var argument in rootField.Arguments)
{
if (argument.Name.Value.Equals(argumentName, StringComparison.Ordinal))
{
var value = argument.Value is VariableNode variable
? context.Variables.GetValue<IValueNode>(variable.Name.Value)
: argument.Value;

return FormatTopicValue(value);
}
}
Comment on lines +391 to +399
foreach (var selection in definition.SelectionSet.Selections)
{
if (selection is FieldNode field
&& !field.Name.Value.Equals(IntrospectionFieldNames.TypeName, StringComparison.Ordinal)
&& (field.Alias?.Value ?? field.Name.Value).Equals(responseName, StringComparison.Ordinal))
{
return field;
}
}

if (path?.Item.ProvidedSelectionSet is not null
&& previousSchemaName == schemaName
&& !path.Item.TryGetProvidedSelectionSet(
Comment on lines +170 to +176
foreach (var rightPossibleType in schema.GetPossibleTypes(right))
{
if (leftPossibleType == rightPossibleType)
{
return true;
}
}
… IDisposable'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
# Conflicts:
#	src/HotChocolate/Fusion/src/Fusion.Composition/Properties/CompositionResources.Designer.cs
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