Skip to content

Fix projection of underlying ResolveWith member#9742

Merged
tobias-tengler merged 3 commits into
mainfrom
tte/fix-resolvewith-projection
May 19, 2026
Merged

Fix projection of underlying ResolveWith member#9742
tobias-tengler merged 3 commits into
mainfrom
tte/fix-resolvewith-projection

Conversation

@tobias-tengler
Copy link
Copy Markdown
Member

Closes #9741

@tobias-tengler tobias-tengler marked this pull request as ready for review May 19, 2026 13:28
Copilot AI review requested due to automatic review settings May 19, 2026 13:28
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

Fixes a regression where ResolveWith<T> on a field that shadows a runtime member of the parent type stopped projecting that underlying member, causing [UseProjection] parents to populate an empty/null member that the custom resolver then sees instead of the real data.

Changes:

  • Adds a new CoreFieldFlags.MemberReplacement flag set by ObjectFieldDescriptor.ResolveWithInternal whenever a fluent ResolveWith overrides an existing Member.
  • Updates the queryable projection handler and the SelectionExpressionBuilder (used by AsSelector) to keep projecting the underlying member when this flag is present.
  • Adds tests covering both [UseProjection] and ISelection.AsSelector<T>() paths.

Reviewed changes

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

Show a summary per file
File Description
src/HotChocolate/Core/src/Types/Types/Descriptors/Configurations/CoreFieldFlags.cs Adds MemberReplacement flag (1L << 34).
src/HotChocolate/Core/src/Types/Types/Descriptors/ObjectFieldDescriptor.cs Sets MemberReplacement when ResolveWith shadows an existing member.
src/HotChocolate/Data/src/Data/Projections/Expressions/Handlers/QueryableProjectionHandlerBase.cs Treats member-replacement fields as projectable in CanProjectMember.
src/HotChocolate/Core/src/Execution.Projections/SelectionExpressionBuilder.cs Includes member-replacement fields when building AsSelector projections; small readability refactor.
src/HotChocolate/Data/test/Data.Tests/ResolveWithProjectionTests.cs New tests covering [UseProjection] and AsSelector paths for shadowed ResolveWith.

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

@tobias-tengler tobias-tengler merged commit b6f1420 into main May 19, 2026
143 of 145 checks passed
@tobias-tengler tobias-tengler deleted the tte/fix-resolvewith-projection branch May 19, 2026 13:33
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.

ResolveWith<T> on object type fields no longer resolves after upgrade from v15 to v16

2 participants