Skip to content

Add support for @semanticNonNull#4401

Draft
martinbonnin wants to merge 3 commits into
graphql-java:masterfrom
martinbonnin:semantic-non-null
Draft

Add support for @semanticNonNull#4401
martinbonnin wants to merge 3 commits into
graphql-java:masterfrom
martinbonnin:semantic-non-null

Conversation

@martinbonnin

Copy link
Copy Markdown
Contributor

@semanticNonNull is the counterpart of onError.

  • onError is aimed to be merged in the spec and allow new services to use true nullability (!) without conflating nulls and errors.
  • @semanticNonNull is for the transition. It allows existing services that cannot change fields to non-nullable (!) because that would increase the blast radius of errors for older clients to still signal semantic nullability to newer clients.

See the @semanticNonNull GAP for more details.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 11 5890 (+9 🟢) 5834 (+9 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 17 5890 (+9 🟢) 5833 (+9 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 21 5890 (+9 🟢) 5833 (+9 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 25 5890 (+9 🟢) 5833 (+9 🟢) 0 (±0) 0 (±0) 57 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 23592 (+36 🟢) 23365 (+36 🟢) 0 (±0) 0 (±0) 227 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 29751 3131 90.5% ±0.0%
Branches 8744 1536 85.1% ±0.0%
Methods 7934 1210 86.8% ±0.0%

Changed Class Coverage (4 classes)

Class Line Branch Method
g.Directives +0.1% 🟢 ±0.0% +3.2% 🟢
g.e.NonNullableFieldValidator -2.2% 🔴 -15.4% 🔴 ±0.0%
g.e.ResultPath +1.9% 🟢 ±0.0% +6.7% 🟢
g.e.SemanticNonNullFieldWasNullError +70.0% 🟢 ±0.0% +50.0% 🟢
NonNullableFieldValidator — method details
Method Line Branch
checkSemanticNonNull new 100.0% 100.0%
listLevel new 100.0% 75.0%
semanticNonNullLevels new 83.3% 50.0%
addError new 100.0% 100.0%
<clinit> new 100.0%

Full HTML report: build artifact jacoco-html-report

Updated: 2026-06-05 08:30:20 UTC

Comment thread src/main/java/graphql/schema/idl/SchemaGeneratorHelper.java Outdated
Comment thread src/main/java/graphql/Directives.java
Comment thread src/test/groovy/graphql/execution/SemanticNonNullTest.groovy
def schema1 = schema("""
type Query {
foo(arg: Int): String
foo(arg: Float): String

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why Int to Float??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, sorry should have left a comment there. This is because the @semanticNonNull directive definition now puts the Int type by defaults in all schemas. So it's either we change to float, or we check operations.size() == 3 just below.

Since this class is about testing schema diffs, I thought keeping the diff as large as possible was the best way forward.

Comment thread src/main/java/graphql/execution/NonNullableFieldValidator.java
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.

2 participants