Fix PageInfo Shareable Directive with Apollo Federation#9809
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a schema-startup crash when using Apollo Federation together with implementation-first paging fields that return PageConnection<T> (issue #9798). The core change ensures the @shareable directive type is registered whenever a discovered PageInfo object type is backed by a runtime type implementing IPageInfo, not only when the built-in PageInfoType is used.
Changes:
- Update
FederationTypeInterceptor.RegisterMoreTypesto detect and handle runtimePageInfotypes (IPageInfo) and registerShareableDirectiveaccordingly. - Add a focused implementation-first regression test project that reproduces the crash and snapshots the resulting schemas for both Apollo Federation and Composite Source Schema paths.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/ApolloFederation/src/ApolloFederation/FederationTypeInterceptor.cs | Registers ShareableDirective when a discovered page-info type is runtime-backed by IPageInfo, preventing directive resolution failures during schema completion. |
| src/HotChocolate/ApolloFederation/test/ApolloFederation.ImplementationFirst/PageConnectionFederationTests.cs | Regression test ensuring schema builds with .AddApolloFederation() + implementation-first PageConnection<T> field. |
| src/HotChocolate/ApolloFederation/test/ApolloFederation.ImplementationFirst/PageConnectionCompositeSchemaTests.cs | Companion test ensuring composite schema defaults also build successfully for the same paging scenario. |
| src/HotChocolate/ApolloFederation/test/ApolloFederation.ImplementationFirst/EmployeeQuery.cs | Minimal implementation-first query using [UseConnection] and returning PageConnection<Employee> to reproduce #9798. |
| src/HotChocolate/ApolloFederation/test/ApolloFederation.ImplementationFirst/Employee.cs | Minimal entity type for the paging tests. |
| src/HotChocolate/ApolloFederation/test/ApolloFederation.ImplementationFirst/ModuleInfo.cs | Declares the module name used by the types source generator (ImplementationFirstTypes). |
| src/HotChocolate/ApolloFederation/test/ApolloFederation.ImplementationFirst/HotChocolate.ApolloFederation.ImplementationFirst.Tests.csproj | New test project wiring analyzers/source-gen and required references. |
| src/HotChocolate/ApolloFederation/test/ApolloFederation.ImplementationFirst/snapshots/PageConnectionFederationTests.PageConnection_Field_With_ApolloFederation_Builds_Schema.graphql | Snapshot asserting the federation schema output (including @shareable on PageInfo fields). |
| src/HotChocolate/ApolloFederation/test/ApolloFederation.ImplementationFirst/snapshots/PageConnectionCompositeSchemaTests.PageConnection_Field_With_CompositeSourceSchema_Builds_Schema.graphql | Snapshot asserting composite schema output (including @shareable behavior for composite). |
| src/HotChocolate/ApolloFederation/HotChocolate.ApolloFederation.slnx | Adds the new implementation-first test project to the Apollo Federation solution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9798