Skip to content

Honor [Subscribe(With = ...)] in source-generated subscriptions#9702

Merged
glen-84 merged 1 commit into
mainfrom
gai/fix-source-gen-subscribe-with
May 14, 2026
Merged

Honor [Subscribe(With = ...)] in source-generated subscriptions#9702
glen-84 merged 1 commit into
mainfrom
gai/fix-source-gen-subscribe-with

Conversation

@glen-84
Copy link
Copy Markdown
Member

@glen-84 glen-84 commented May 14, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 14, 2026 07:45
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

Adds source generator support for the [Subscribe(With = nameof(...))] attribute on subscription resolvers, ensuring (1) the referenced stream-producing sibling method is excluded from being exposed as its own GraphQL field, and (2) the generated configuration sets SubscribeWith/SourceType so the runtime invokes the correct event stream.

Changes:

  • WellKnownAttributes: added SubscribeAttribute constant.
  • ObjectTypeInspector: pre-scans members for [Subscribe(With = ...)], builds a name set/lookup, skips referenced sibling methods, and propagates subscribeWith into the resolver model.
  • Resolver model + TypeFileBuilderBase: added SubscribeWith and emit configuration.SubscribeWith / configuration.SourceType when present.
  • Tests/snapshots: new generator and integration tests covering the subscribe-with behavior, ignored-method suppression, and live subscription delivery.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/HotChocolate/Core/src/Types.Analyzers/WellKnownAttributes.cs Adds the SubscribeAttribute constant.
src/HotChocolate/Core/src/Types.Analyzers/Models/Resolver.cs Adds SubscribeWith property and constructor parameter, threaded through WithSchemaTypeName.
src/HotChocolate/Core/src/Types.Analyzers/Inspectors/ObjectTypeInspector.cs Collects [Subscribe(With=...)] references, suppresses the referenced sibling methods as fields, and forwards the value to CreateResolver.
src/HotChocolate/Core/src/Types.Analyzers/FileBuilders/TypeFileBuilderBase.cs Emits configuration.SubscribeWith and configuration.SourceType when the resolver has a subscribe-with target.
src/HotChocolate/Core/test/Types.Analyzers.Tests/OperationTests.cs Adds two generator tests for Subscribe-with and [GraphQLIgnore] interaction.
src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/OperationTests.Subscription_With_Subscribe_With_Excludes_Stream_Method.md New snapshot showing generated subscription wiring.
src/HotChocolate/Core/test/Types.Analyzers.Tests/snapshots/OperationTests.Subscription_Ignored_Method_Does_Not_Suppress_Public_Resolver.md New snapshot verifying ignored stub doesn't suppress sibling field.
src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/Subscription.cs New integration subscription type exercising both private and public subscribe sources.
src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/IntegrationTests.cs Adds runtime subscription test and field-exposure test.
src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/snapshots/IntegrationTests.Schema_Snapshot.snap Updates schema snapshot to include the new Subscription type.

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

@glen-84 glen-84 merged commit e53e569 into main May 14, 2026
143 of 145 checks passed
@glen-84 glen-84 deleted the gai/fix-source-gen-subscribe-with branch May 14, 2026 07:52
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