[Analyzer] Fix FactoryTypeReference cache collision for shared CLR types#9747
Merged
tobias-tengler merged 1 commit intoMay 20, 2026
Merged
Conversation
41ce99e to
a2bcad2
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a type resolution bug in HotChocolate’s source-generator type handling where FactoryTypeReference could incorrectly reuse a cached wrapper type across input vs output contexts for the same CLR type, leading to invalid schema/type resolution.
Changes:
- Update
FactoryTypeReference.Keyto incorporateTypeContext(Input/Output) to prevent factory-cache collisions. - Add an analyzer integration regression case using a POCO (
Shape) in both output (query result) and input (mutation argument) positions. - Update integration test schema snapshots to include the new query field, mutation root, and generated
ShapeInput.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/Types.cs | Adds regression scenario: same CLR type used in query return and mutation argument to validate distinct input/output GraphQL types. |
| src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/snapshots/IntegrationTests.Schema_Snapshot.snap | Updates expected schema snapshot to include Mutation, Shape, and ShapeInput. |
| src/HotChocolate/Core/test/Types.Analyzers.Integration.Tests/snapshots/IntegrationTests.Schema_Snapshot_Without_ConnectionName_Inference.snap | Updates expected schema snapshot (variant) with Mutation, Shape, and ShapeInput. |
| src/HotChocolate/Core/src/Types/Types/Descriptors/TypeReferences/FactoryTypeReference.cs | Disambiguates the factory cache key by appending TypeContext for non-None contexts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced May 20, 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.
No description provided.