← 输入框|github.com|刷新
Skip to content

keep @oneOf and input value @deprecated in IntrospectionResultToSchema - #4514

Open
nab-iha3 wants to merge 1 commit into
graphql-java:masterfrom
nab-iha3:introspection-result-oneof
Open

nab-iha3 wants to merge 1 commit into
graphql-java:masterfrom
nab-iha3:introspection-result-oneof

Conversation

@nab-iha3

Copy link
Copy Markdown
Contributor

Spock, a schema with input UserLookup @oneOf { byId: ID byEmail: String } run through IntrospectionQuery.INTROSPECTION_QUERY, IntrospectionResultToSchema.createSchemaDefinition, AstPrinter and SchemaGenerator:

(rebuilt.getGraphQLSchema().getType("UserLookup") as GraphQLInputObjectType).isOneOf()
 |       |                  |                                                |
 |       |                  GraphQLInputObjectType{name='UserLookup', ...}   false

createInputObject never reads __Type.isOneOf, so the rebuilt schema has a plain input object and { user(lookup: {byId: "1", byEmail: "a@b.c"}) } passes validation and reaches the data fetcher, where the origin schema rejects it with Exactly one key must be specified for OneOf type 'UserLookup'. the default introspection query asks for isOneOf, and also for isDeprecated / deprecationReason on arguments and input fields, which createInputValueDefinitions drops the same way while fields, enum values and directive definitions keep theirs. graphql-js buildClientSchema carries isOneOf and input value deprecation over.

createInputObject now adds @oneOf when isOneOf is true and input values go through the existing createDeprecatedDirective. the regression tests in IntrospectionResultToSchemaTest fail before the change.

@github-actions

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 11 6055 (+4 🟢) 5999 (+4 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 17 6055 (+4 🟢) 5998 (+4 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 21 6055 (+4 🟢) 5998 (+4 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 25 6055 (+4 🟢) 5998 (+4 🟢) 0 (±0) 0 (±0) 57 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 24252 (+16 🟢) 24025 (+16 🟢) 0 (±0) 0 (±0) 227 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 30211 3082 90.7% ±0.0%
Branches 8865 1507 85.5% ±0.0%
Methods 8070 1188 87.2% ±0.0%

Changed Class Coverage (2 classes)

Class Line Branch Method
g.i.IntrospectionResultToSchema +0.6% 🟢 +1.6% 🟢 ±0.0%
g.l.AstPrinter +0.4% 🟢 +0.4% 🟢 ±0.0%

Full HTML report: build artifact jacoco-html-report

Updated: 2026-10-27 06:44:34 UTC

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant