René's URL Explorer Experiment


Title: Add OneOf Inhabitability validation by Copilot · Pull Request #4250 · graphql-java/graphql-java · GitHub

Open Graph Title: Add OneOf Inhabitability validation by Copilot · Pull Request #4250 · graphql-java/graphql-java

X Title: Add OneOf Inhabitability validation by Copilot · Pull Request #4250 · graphql-java/graphql-java

Description: 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: # Uninhabited - no way to construct a finite value input A @oneOf { self: A } # Also uninhabited - cycle with no escape input A @oneOf { b: B } input B @oneOf { a: A } # Inhabited - list provides escape path input A @oneOf { self: [A] } # Inhabited - scalar provides escape path input A @oneOf { b: B, escape: String } 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 prompt Context 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): @Override public TraversalControl visitGraphQLInputObjectType(GraphQLInputObjectType inputObjectType, TraverserContext context) { if (!inputObjectType.isOneOf()) { return TraversalControl.CONTINUE; } SchemaValidationErrorCollector errorCollector = context.getVarFromParents(SchemaValidationErrorCollector.class); if (!canBeProvidedAFiniteValue(inputObjectType, new LinkedHashSet<>())) { String message = format("OneOf Input Object %s must be inhabited but all fields recursively reference only other OneOf Input Objects forming an unresolvable cycle.", inputObjectType.getName()); errorCollector.addError(new SchemaValidationError(SchemaValidationErrorType.OneOfNotInhabited, message)); } return TraversalControl.CONTINUE; } private boolean canBeProvidedAFiniteValue(GraphQLInputObjectType oneOfInputObject, Set visited) { if (visited.contains(oneOfInputObject)) { return false; } Set nextVisited = new LinkedHashSet<>(visited); nextVisited.add(oneOfInputObject); for (GraphQLInputObjectField field : oneOfInputObject.getFieldDefinitions()) { GraphQLType fieldType = field.getType(); if (GraphQLTypeUtil.isList(fieldType)) { return true; } GraphQLUnmodifiedType namedFieldType = GraphQLTypeUtil.unwrapAll(fieldType); if (!(namedFieldType instanceof GraphQLInputObjectType)) { return true; } GraphQLInputObjectType inputFieldType = (GraphQLInputObjectType) namedFieldType; if (!inputFieldType.isOneOf()) { return true; } if (canBeProvidedAFiniteValue(inputFieldType, nextVisited)) { return true; } } return false; } New imports needed: import graphql.schema.GraphQLType; import graphql.schema.GraphQLUnmodifiedType; import java.util.LinkedHashSet; import java.util.Set; 3. src/test/groovy/graphql/schema/validation/OneOfInputObjectRulesTest.groovy Add the following 10 test cases after the existing tests: "oneOf with scalar fields is inhabited" - input A @oneOf { a: String, b: Int } → no exception "oneOf with enum field is inhabited" - input A @oneOf { a: Color } with enum Color { RED GREEN BLUE } → no exception "oneOf with list field is inhabited" - input A @oneOf { a: [A] } → no exception "oneOf referencing non-oneOf input is inhabited" - input A @oneOf { a: RegularInput } with input RegularInput { x: String } → no exception "oneOf with escape field is inhabited" - input A @oneOf { b: B, escape: String } with input B @oneOf { a: A } → no exception "mutually referencing oneOf types with scalar escape is inhabited" - input A @oneOf { b: B } with input B @oneOf { a: A, escape: Int } → no exception "oneOf referencing non-oneOf with back-reference is inhabited" - input A @oneOf { b: RegularInput } with input RegularInput { back: A } → no exception "multiple fields with chained oneOf escape is inhabited" - input A @oneOf { b: B, c: C }, input B @oneOf { a: A }, input C @oneOf { a: A, escape: String } → no exception "single oneOf self-reference cycle is not inhabited" - input A @oneOf { self: A } → InvalidSchemaException with 1 error of type OneOfNotInhabited "multiple oneOf types forming cycle are not inhabited" - input A @oneOf { b: B }, `input B @oneo... 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.

Open Graph Description: 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 f...

X Description: 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 f...

Opengraph URL: https://github.com/graphql-java/graphql-java/pull/4250

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:dec13bf0-30b0-4fde-b735-aa7590b8baee
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9A78:154D88:19889CB:20962BA:6B018B4C
html-safe-nonce36f6ef24a11d8c317fd9b9716527aa971c3c83acd44061e2e9102584ca9d6656
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTc4OjE1NEQ4ODoxOTg4OUNCOjIwOTYyQkE6NkIwMThCNEMiLCJ2aXNpdG9yX2lkIjoiNDAyNzAzNDQ0NzQ1ODE3NTgyMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac36616c1707c957fc3ee993334f99bfbeb080359fb5030ad4705d1e107e176b64
hovercard-subject-tagpull_request:3301052233
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/graphql-java/graphql-java/pull/4250/files
twitter:imagehttps://avatars.githubusercontent.com/in/1143301?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/in/1143301?s=400&v=4
og:image:altImplements 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 f...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git
octolytics-dimension-user_id14289921
octolytics-dimension-user_logingraphql-java
octolytics-dimension-repository_id38602457
octolytics-dimension-repository_nwographql-java/graphql-java
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id38602457
octolytics-dimension-repository_network_root_nwographql-java/graphql-java
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/graphql-java/graphql-java/pull/4250/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgraphql-java%2Fgraphql-java%2Fpull%2F4250%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgraphql-java%2Fgraphql-java%2Fpull%2F4250%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=graphql-java%2Fgraphql-java
Reloadhttps://github.com/graphql-java/graphql-java/pull/4250/files
Reloadhttps://github.com/graphql-java/graphql-java/pull/4250/files
Reloadhttps://github.com/graphql-java/graphql-java/pull/4250/files
graphql-javahttps://github.com/graphql-java
graphql-javahttps://github.com/graphql-java/graphql-java
Codehttps://github.com/graphql-java/graphql-java
Issues27 (27)https://github.com/graphql-java/graphql-java/issues
Pull requests35 (35)https://github.com/graphql-java/graphql-java/pulls
Discussionshttps://github.com/graphql-java/graphql-java/discussions
Actionshttps://github.com/graphql-java/graphql-java/actions
Projectshttps://github.com/graphql-java/graphql-java/projects
Wikihttps://github.com/graphql-java/graphql-java/wiki
Security and qualityhttps://github.com/graphql-java/graphql-java/security
Insightshttps://github.com/graphql-java/graphql-java/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fgraphql-java%2Fgraphql-java%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgraphql-java%2Fgraphql-java%2Fissues%2Fnew%2Fchoose
Copilothttps://github.com/apps/copilot-swe-agent
validation-refactorhttps://github.com/graphql-java/graphql-java/tree/validation-refactor
copilot/validate-oneof-inhabited-typeshttps://github.com/graphql-java/graphql-java/tree/copilot/validate-oneof-inhabited-types
Conversation 4 https://github.com/graphql-java/graphql-java/pull/4250
Commits 3 https://github.com/graphql-java/graphql-java/pull/4250/commits
Checks 1 https://github.com/graphql-java/graphql-java/pull/4250/checks
Files changed https://github.com/graphql-java/graphql-java/pull/4250/files
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4250/files
Add OneOf Inhabitability validation https://github.com/graphql-java/graphql-java/pull/4250/files#top
Show all changes 3 commits https://github.com/graphql-java/graphql-java/pull/4250/files
c7eea39 Initial plan Copilot Feb 19, 2026 https://github.com/graphql-java/graphql-java/pull/4250/commits/c7eea39b1731e3fef32f54c88d59793b163887a0
defeda1 Add OneOf inhabitability validation Copilot Feb 19, 2026 https://github.com/graphql-java/graphql-java/pull/4250/commits/defeda11933a335b06d6d8bcfed8f156bcb7de2a
4890f7f Inline OneOf validation rules into TypeAndFieldRule Copilot Feb 19, 2026 https://github.com/graphql-java/graphql-java/pull/4250/commits/4890f7f548364a477938670d54427bbcc3e0f033
Clear filters https://github.com/graphql-java/graphql-java/pull/4250/files
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4250/files
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4250/files
OneOfInputObjectRules.java https://github.com/graphql-java/graphql-java/pull/4250/files#diff-1054a5fe3d39926e85101f3083311046b9f87a32071cbdf50869cbfaac178df4
SchemaValidationErrorType.java https://github.com/graphql-java/graphql-java/pull/4250/files#diff-e015b8eb00c7046bc43599f58d9919c119cf35d33f2177e18d608fd1bb9ab4f8
SchemaValidator.java https://github.com/graphql-java/graphql-java/pull/4250/files#diff-c61128ed45b5042860e141f937a41901bfd98ce1561c282107e8f51c7d762035
TypeAndFieldRule.java https://github.com/graphql-java/graphql-java/pull/4250/files#diff-1a19e9c91e2618b7797153d31bfc12a385008518f41ce94371ceb1eb3c68e704
OneOfInputObjectRulesTest.groovy https://github.com/graphql-java/graphql-java/pull/4250/files#diff-73a57b8d707e6307bb5c76418aa9e107fb960fc5932481f73cb5e9a6d3a37bea
SchemaValidatorTest.groovy https://github.com/graphql-java/graphql-java/pull/4250/files#diff-05d8104f949be383f380a7f78a265bda004f807396548ff874d6b2337376db70
src/main/java/graphql/schema/validation/OneOfInputObjectRules.javahttps://github.com/graphql-java/graphql-java/pull/4250/files#diff-1054a5fe3d39926e85101f3083311046b9f87a32071cbdf50869cbfaac178df4
View file https://github.com/graphql-java/graphql-java/blob/051f73ddc446654389fbbbf94a259085b3db5ef0/src/main/java/graphql/schema/validation/OneOfInputObjectRules.java
Open in desktop https://desktop.github.com
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4250/files
src/main/java/graphql/schema/validation/SchemaValidationErrorType.javahttps://github.com/graphql-java/graphql-java/pull/4250/files#diff-e015b8eb00c7046bc43599f58d9919c119cf35d33f2177e18d608fd1bb9ab4f8
View file https://github.com/graphql-java/graphql-java/blob/4890f7f548364a477938670d54427bbcc3e0f033/src/main/java/graphql/schema/validation/SchemaValidationErrorType.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/graphql-java/graphql-java/pull/4250/{{ revealButtonHref }}
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-e015b8eb00c7046bc43599f58d9919c119cf35d33f2177e18d608fd1bb9ab4f8
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-e015b8eb00c7046bc43599f58d9919c119cf35d33f2177e18d608fd1bb9ab4f8
src/main/java/graphql/schema/validation/SchemaValidator.javahttps://github.com/graphql-java/graphql-java/pull/4250/files#diff-c61128ed45b5042860e141f937a41901bfd98ce1561c282107e8f51c7d762035
View file https://github.com/graphql-java/graphql-java/blob/4890f7f548364a477938670d54427bbcc3e0f033/src/main/java/graphql/schema/validation/SchemaValidator.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/graphql-java/graphql-java/pull/4250/{{ revealButtonHref }}
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-c61128ed45b5042860e141f937a41901bfd98ce1561c282107e8f51c7d762035
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-c61128ed45b5042860e141f937a41901bfd98ce1561c282107e8f51c7d762035
src/main/java/graphql/schema/validation/TypeAndFieldRule.javahttps://github.com/graphql-java/graphql-java/pull/4250/files#diff-1a19e9c91e2618b7797153d31bfc12a385008518f41ce94371ceb1eb3c68e704
View file https://github.com/graphql-java/graphql-java/blob/4890f7f548364a477938670d54427bbcc3e0f033/src/main/java/graphql/schema/validation/TypeAndFieldRule.java
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/graphql-java/graphql-java/pull/4250/{{ revealButtonHref }}
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-1a19e9c91e2618b7797153d31bfc12a385008518f41ce94371ceb1eb3c68e704
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-1a19e9c91e2618b7797153d31bfc12a385008518f41ce94371ceb1eb3c68e704
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-1a19e9c91e2618b7797153d31bfc12a385008518f41ce94371ceb1eb3c68e704
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-1a19e9c91e2618b7797153d31bfc12a385008518f41ce94371ceb1eb3c68e704
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-1a19e9c91e2618b7797153d31bfc12a385008518f41ce94371ceb1eb3c68e704
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-1a19e9c91e2618b7797153d31bfc12a385008518f41ce94371ceb1eb3c68e704
src/test/groovy/graphql/schema/validation/OneOfInputObjectRulesTest.groovyhttps://github.com/graphql-java/graphql-java/pull/4250/files#diff-73a57b8d707e6307bb5c76418aa9e107fb960fc5932481f73cb5e9a6d3a37bea
View file https://github.com/graphql-java/graphql-java/blob/4890f7f548364a477938670d54427bbcc3e0f033/src/test/groovy/graphql/schema/validation/OneOfInputObjectRulesTest.groovy
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/graphql-java/graphql-java/pull/4250/{{ revealButtonHref }}
https://github.com/graphql-java/graphql-java/pull/4250/files#diff-73a57b8d707e6307bb5c76418aa9e107fb960fc5932481f73cb5e9a6d3a37bea
Please reload this pagehttps://github.com/graphql-java/graphql-java/pull/4250/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.