Skip to content

Fix NRE when ParentRequires targets a composite type#9789

Merged
tobias-tengler merged 1 commit into
mainfrom
tte/fix-parent-requires-nre
May 28, 2026
Merged

Fix NRE when ParentRequires targets a composite type#9789
tobias-tengler merged 1 commit into
mainfrom
tte/fix-parent-requires-nre

Conversation

@tobias-tengler

Copy link
Copy Markdown
Member

Closes #9788

Copilot AI review requested due to automatic review settings May 28, 2026 06:53

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

Fixes a null reference exception during operation compilation when ParentRequires targets a composite (object) type by ensuring internal requirement selections for composite fields always include a valid sub-selection.

Changes:

  • Update the queryable requirements projection optimizer to emit a minimal __typename selection set for composite requirements without explicit sub-selections.
  • Add an in-memory projections integration test covering ParentRequires on an object-valued field.
  • Add an EF Core integration test asserting required navigation projection results in an SQL join (and snapshot the SQL + result).

Reviewed changes

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

Show a summary per file
File Description
src/HotChocolate/Data/src/Data/Projections/Optimizers/QueryableRequirementsProjectionOptimizer.cs Ensures composite requirement selections compile by generating a __typename-only selection set when no sub-selections exist.
src/HotChocolate/Data/test/Data.Projections.Tests/IntegrationTests.cs Adds a regression test for ParentRequires when the required member is an object field.
src/HotChocolate/Data/test/Data.Projections.Tests/snapshots/IntegrationTests.Projection_Should_NotThrow_When_ParentRequiresObjectField.snap Snapshot for the new projections regression test result.
src/HotChocolate/Data/test/Data.EntityFramework.Tests/IntegrationTests.cs Adds an EF Core regression test validating required navigation is projected from SQL (via captured SQL).
src/HotChocolate/Data/test/Data.EntityFramework.Tests/snapshots/IntegrationTests.Projection_Should_ProjectRequiredNavigation_When_ParentRequiresObject.md Snapshot for SQL + execution result (non-NET10).
src/HotChocolate/Data/test/Data.EntityFramework.Tests/snapshots/IntegrationTests.Projection_Should_ProjectRequiredNavigation_When_ParentRequiresObject_NET10_0.md Snapshot for SQL + execution result (NET10-specific).

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

@tobias-tengler tobias-tengler merged commit 61bce25 into main May 28, 2026
143 of 145 checks passed
@tobias-tengler tobias-tengler deleted the tte/fix-parent-requires-nre branch May 28, 2026 07:07
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.

NRE when Resolve property of ObjectType with ParentRequires

2 participants