Skip to content

Use shared coercion and located errors for @skip and @include - #4541

Open
andimarek wants to merge 1 commit into
masterfrom
codex/conditional-directive-coercion
Open

andimarek wants to merge 1 commit into
masterfrom
codex/conditional-directive-coercion

Conversation

@andimarek

Copy link
Copy Markdown
Member

A nullable variable with a non-null default can legally be used in @skip(if:) or @include(if:). Passing explicit null overrides that default and currently causes an uncaught null-unboxing exception:

query ($flag: Boolean = true) {
  good
  parent { child @skip(if: $flag) }
}

With {"flag": null} and a nullable parent, this now returns {"good": ..., "parent": null} plus an error located at $flag, with path ["parent"].

  • Resolve conditional directive arguments through ValuesResolver.getArgumentValues(), reusing the existing Boolean! coercion rules.
  • Report root collection failures with data: null; nested failures preserve siblings and follow normal non-null propagation. Include the directive name, argument source location, and enclosing field path where applicable.
  • Return subscription event errors without terminating the stream, preserving event extensions. Retain the original error during deferred non-null propagation.
  • Preserve Boolean defaults/values, skip short-circuiting, and unknown-variable normalization.

Alternative to #4540: avoids an execution-wide AbortExecutionException. Complements #4522, which handles field arguments before invoking data fetchers; conditional directives are evaluated during field collection.

Validation: 57 new Spock cases cover queries, mutations, fragments, aliases, lists, async fetchers, subscriptions, defer, instrumentation, normalization, and all three DataLoader dispatch modes. ./gradlew --no-daemon test testng jacocoTestReport javadoc passes on Java 25 (6,352 cases, no failures). No per-class coverage regressions against test-baseline.json; the baseline is unchanged.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 17 6319 (+57 🟢) 6263 (+57 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 21 6319 (+57 🟢) 6263 (+57 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 25 6319 (+57 🟢) 6263 (+57 🟢) 0 (±0) 0 (±0) 56 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 18989 (+171 🟢) 18821 (+171 🟢) 0 (±0) 0 (±0) 168 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 30396 3073 90.8% ±0.0%
Branches 8989 1499 85.7% +0.1% 🟢
Methods 8108 1183 87.3% ±0.0%

Changed Class Coverage (10 classes)

Class Line Branch Method
g.e.c.ConditionalDirectiveCoercionException +100.0% 🟢 +100.0% 🟢 +100.0% 🟢
g.e.c.ConditionalNodes +2.8% 🟢 +4.4% 🟢 ±0.0%
g.e.Execution +0.2% 🟢 ±0.0% ±0.0%
g.e.ExecutionStrategy +0.3% 🟢 +1.0% 🟢 ±0.0%
g.e.FieldCollector ±0.0% +2.6% 🟢 ±0.0%
g.e.i.DeferredFragmentCall ±0.0% +4.2% 🟢 ±0.0%
g.e.SubscriptionExecutionStrategy +0.1% 🟢 +2.8% 🟢 ±0.0%
g.e.ValuesResolver ±0.0% +1.3% 🟢 ±0.0%
g.GraphqlErrorException +27.3% 🟢 ±0.0% +50.0% 🟢
g.GraphqlErrorException
$Builder
+50.0% 🟢 ±0.0% +50.0% 🟢

Full HTML report: build artifact jacoco-html-report

Updated: 2026-11-06 10:08:52 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