| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Co-authored-by: andimarek <1706744+andimarek@users.noreply.github.com>
|
@copilot The rule should be inlined |
Sorry, something went wrong.
Co-authored-by: andimarek <1706744+andimarek@users.noreply.github.com>
|
@copilot this PR should not start from master but from the PR we want to merge into |
Sorry, something went wrong.
The PR is configured to target the validation-refactor branch (as indicated in the stacked PR context). The base commit "051f73d Remove unnecessary null checks on getCodeRegistry()" appears to be from that branch. If the base branch setting in GitHub shows master instead of validation-refactor, that would need to be changed in the PR settings on GitHub (which I cannot modify directly from this environment). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Implements validation to detect uninhabited OneOf input types - types where no finite value can be constructed due to unresolvable cyclic references.
Based on GraphQL spec proposal #1211, adapted for the validation-refactor branch architecture.
Problem
Self-referential or cyclical OneOf types without escape paths are uninhabited:
Changes
- SchemaValidationErrorType: Added OneOfNotInhabited error classification
- TypeAndFieldRule: Inlined all OneOf validation logic into this consolidated schema validation rule class:
- Added visitGraphQLInputObjectField method for field-level validation (nullable and no default value checks)
- Added visitGraphQLInputObjectType method with recursive cycle detection via canBeProvidedAFiniteValue
- Returns true if any field references: scalar, enum, list, or non-OneOf input type
- Returns false if all fields form unresolvable OneOf cycles
- SchemaValidator: Removed separate OneOfInputObjectRules from rules list (OneOf validation now part of TypeAndFieldRule)
- Tests: 10 test cases covering inhabited cases (scalars, enums, lists, non-OneOf refs, escape paths) and uninhabited cases (self-reference, multi-type cycles)
Original promptContext
This PR re-implements the functionality from PR #4248 ("OneOf Inhabitability" by @jbellenger) but based on the validation-refactor branch (PR #4228), since #4228 will be merged first.
PR #4248 targets master and adds validation for uninhabited OneOf input types. Since PR #4228 significantly refactors validation (consolidating 31 rule classes into a single OperationValidator, removing AbstractRule, RulesVisitor, and individual rule classes), the OneOf inhabitability changes need to be adapted to work with the new validation architecture.
What needs to be implemented
The core feature is validating that OneOf input types are "inhabited" — i.e., that a finite value can be constructed for them. A self-referential OneOf like input A @oneOf { a: A } is uninhabited because you can never construct a finite value for it.
This is based on the spec proposal at graphql/graphql-spec#1211
Changes needed (adapted from PR #4248 to the validation-refactor architecture):
1. src/main/java/graphql/schema/validation/SchemaValidationErrorType.java
Add a new enum value OneOfNotInhabited (between OneOfNonNullableField and RequiredInputFieldCannotBeDeprecated).
2. src/main/java/graphql/schema/validation/OneOfInputObjectRules.java
Add a new method visitGraphQLInputObjectType that checks if a OneOf input object type is inhabited. If not, it adds a SchemaValidationError with type OneOfNotInhabited.
Add the following logic (from PR #4248):
New imports needed:
3. src/test/groovy/graphql/schema/validation/OneOfInputObjectRulesTest.groovy
Add the following 10 test cases after the existing tests:
This pull request was created from Copilot chat.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.