Skip to content

Fix PageInfo Shareable Directive with Apollo Federation#9809

Merged
michaelstaib merged 3 commits into
mainfrom
mst/paging-apollo
Jun 1, 2026
Merged

Fix PageInfo Shareable Directive with Apollo Federation#9809
michaelstaib merged 3 commits into
mainfrom
mst/paging-apollo

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Jun 1, 2026

Copy link
Copy Markdown
Member

Fixes #9798

Copilot AI review requested due to automatic review settings June 1, 2026 09:40

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 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.RegisterMoreTypes to detect and handle runtime PageInfo types (IPageInfo) and register ShareableDirective accordingly.
  • 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.

@michaelstaib michaelstaib merged commit ec31a06 into main Jun 1, 2026
144 checks passed
@michaelstaib michaelstaib deleted the mst/paging-apollo branch June 1, 2026 09:59
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.

Application with a query that returns PageConnection with ApolloFederation fails to start

2 participants