Repository navigation
Resolve _service.sdl once per request without internal directives - #10831
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change is accompanied by targeted coverage and documentation for its SDL caching, filtering, and duplicate-resolution behavior.
No open issues 🎉
1 file not reviewed
src/HotChocolate/ApolloFederation/src/ApolloFederation/Properties/FederationResources.Designer.cs: Generated file
What changed in this PR
Updates Apollo Federation’s _service { sdl } handling to cache formatted SDL per schema, hide internal directives by default, and reject duplicate SDL resolutions within a request.
Changes:
- Added schema-scoped SDL caching with
ConditionalWeakTable. - Added internal-directive filtering that respects
DisableInternalDirectives. - Added request-level duplicate-resolution protection and localized error handling.
- Expanded tests and migration documentation.
| File | Summary |
|---|---|
website/content/docs/hotchocolate/migrating/migrate-from-15-to-16.md |
Documents internal directive filtering for _service { sdl }. |
src/HotChocolate/ApolloFederation/test/ApolloFederation.Tests/ServiceTypeTests.cs |
Tests directive visibility, caching, duplicate selections, aliases, and repeated requests. |
src/HotChocolate/ApolloFederation/src/ApolloFederation/Types/ServerFields.cs |
Tracks SDL resolution per request and reports duplicate resolutions. |
src/HotChocolate/ApolloFederation/src/ApolloFederation/Types/_Service.cs |
Caches formatted SDL per schema and excludes internal directives by default. |
src/HotChocolate/ApolloFederation/src/ApolloFederation/ThrowHelper.cs |
Adds the duplicate SDL resolution exception helper. |
src/HotChocolate/ApolloFederation/src/ApolloFederation/Properties/FederationResources.resx |
Adds the duplicate-resolution error message resource. |
src/HotChocolate/ApolloFederation/src/ApolloFederation/Properties/FederationResources.Designer.cs |
Exposes the generated resource accessor. |
src/HotChocolate/ApolloFederation/src/ApolloFederation/FederationTypeInterceptor.cs |
Installs the guarded SDL resolver on the _Service.sdl field. |
src/HotChocolate/ApolloFederation/src/ApolloFederation/FederationContextData.cs |
Defines the request context key used to track SDL resolution. |
Review effort: Lite
Contributor
Patch coverage100.0% of changed lines covered (34/34)
Project coverage: 59.5% (321736/541021 lines) |
# Conflicts: # src/HotChocolate/ApolloFederation/src/ApolloFederation/FederationContextData.cs
glen-84
added a commit
that referenced
this pull request
Nov 9, 2026
(cherry picked from commit 25f0144)
glen-84
added a commit
that referenced
this pull request
Nov 10, 2026
(cherry picked from commit 25f0144)
glen-84
added a commit
that referenced
this pull request
Nov 10, 2026
(cherry picked from commit 25f0144)
This was referenced Nov 10, 2026
This was referenced Nov 19, 2026
fix(deps): Bump Basic.Reference.Assemblies.Net100 and 32 others
AdCodicem/AdCodicem.ValueObjects#262
Closed
This was referenced Nov 26, 2026
fix(deps): Bump Basic.Reference.Assemblies.Net100 and 43 others
AdCodicem/AdCodicem.ValueObjects#274
Closed
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.
Summary
_service.sdlformats the schema once per schema instance and returns that string from then on, instead of printing the schema each time the field resolves.@authorizeand@allowAnonymous, as the schema download does.DisableInternalDirectivesbrings them back in both places. Composition that reads a Hot Chocolate subgraph through_service { sdl }no longer receives that subgraph's@authorizedirectives; the subgraph still enforces them.sdlonce. A furthersdlselection in the same request, through another alias ofsdlor of_service, returns an error on its path, and since both fields are non-null the response hasdata: null._service { sdl }.Test plan
ServiceTypeTestscases: the SDL of a schema with an[Authorize]field leaves out@authorizeand includes it withDisableInternalDirectives,GetSdlreturns the same string for one schema, two aliases ofsdland two_servicealiases that selectsdlreturn one error anddata: null, and two requests on one executor both resolve the SDL. The directive, caching, and alias cases fail without the change.HotChocolate.ApolloFederation.Testson net8.0, net9.0, net10.0, and net11.0.HotChocolate.ApolloFederation.ImplementationFirst.Tests,HotChocolate.Fusion.Composition.ApolloFederation.Tests,HotChocolate.Fusion.Connectors.ApolloFederation.Tests,HotChocolate.Fusion.Connectors.ApolloFederation.Compliance.Tests, which reads_service { sdl }over HTTP, and the Apollo Federation classes ofHotChocolate.Fusion.AspNetCore.Tests.