Fix ParentRequires(string) dropping requirement on named fields#10004
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression where ParentRequires(string) could be effectively ignored for named (non-member/inferred) fields, causing required parent properties (e.g., Name) to be omitted from projections and resulting in null/incorrect resolver behavior (as reported in #10000).
Changes:
- Allow field requirements to be stored even when the entity type is not known at descriptor time (common for
.Field("...")). - Make requirements processing resilient to missing entity type information during schema completion.
- Add regression coverage in both Core descriptor tests and Data projection integration tests (with snapshot).
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/test/Data.Tests/ProjectableDataLoaderTests.cs | Adds an integration test covering ParentRequires(nameof(Brand.Name)) on a named field (computedName). |
| src/HotChocolate/Data/test/Data.Tests/snapshots/ProjectableDataLoaderTests.Brand_Details_Requires_Brand_Name_With_Named_Field.md | Adds snapshot validating the SQL projection includes Brand.Name and the resolver output is correct. |
| src/HotChocolate/Core/test/Types.Tests/Types/Descriptors/ObjectFieldDescriptorTests.cs | Adds a unit test ensuring ParentRequires(string) sets requirement flags/features for named fields. |
| src/HotChocolate/Core/src/Types/Types/Descriptors/FieldRequirementFeature.cs | Enables nullable annotations and allows EntityType to be nullable. |
| src/HotChocolate/Core/src/Types/Types/Descriptors/Configurations/FieldConfiguration.cs | Stops clearing requirements just because entityType is null; preserves requirement metadata for later use. |
| src/HotChocolate/Core/src/Types/Execution/Requirements/RequirementsTypeInterceptor.cs | Adds a guard to skip requirement processing when no entity type can be determined. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Patch coverage60.0% of changed lines covered (3/5)
Uncovered changed lines (JSON){
"sha": "63df907fd8a971e4f8b41ff795258f49ade056b2",
"files": [
{ "path": "src/HotChocolate/Core/src/Types/Execution/Requirements/RequirementsTypeInterceptor.cs", "ranges": [[49, 50]] }
]
}Project coverage: 52.4% (216241/412359 lines) |
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.
Fixes #10000