Skip to content

Validate directive definition cycles#4365

Draft
jbellenger wants to merge 2 commits intographql-java:masterfrom
jbellenger:jbellenger/directive-cycle-validation
Draft

Validate directive definition cycles#4365
jbellenger wants to merge 2 commits intographql-java:masterfrom
jbellenger:jbellenger/directive-cycle-validation

Conversation

@jbellenger
Copy link
Copy Markdown
Contributor

Summary

  • add schema validation for directive definition cycles, including indirect cycles through input types
  • keep a minimal SDL pre-check to stop recursive directive construction before schema validation can run
  • add SDL and programmatic schema tests covering direct and indirect directive cycles

Testing

  • ./gradlew test --tests graphql.schema.idl.SchemaTypeDirectivesCheckerTest --tests graphql.schema.validation.DirectiveReferencesAreValidTest --tests graphql.schema.validation.SchemaValidatorTest
  • ./gradlew clean test (run locally with a temporary init-script workaround to remove duplicate main output directories from the test classpath; vanilla ./gradlew test in this workspace currently hits an unrelated ArchUnit classpath issue)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 11 5738 (+6 🟢) 5682 (+6 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 17 5738 (+6 🟢) 5681 (+6 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 21 5738 (+6 🟢) 5681 (+6 🟢) 0 (±0) 0 (±0) 57 (±0)
Java 25 5738 (+6 🟢) 5681 (+6 🟢) 0 (±0) 0 (±0) 57 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 22984 (+24 🟢) 22757 (+24 🟢) 0 (±0) 0 (±0) 227 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 29078 3142 90.2% ±0.0%
Branches 8499 1527 84.8% -0.1% 🔴
Methods 7759 1222 86.4% ±0.0%

Changed Class Coverage (3 classes)

Class Line Branch Method
g.s.i.SchemaTypeDirectivesChecker -6.9% 🔴 -13.5% 🔴 ±0.0%
g.s.v.DirectiveCycleDetector +89.3% 🟢 +77.8% 🟢 +100.0% 🟢
g.s.v.DirectiveReferencesAreValid +100.0% 🟢 +100.0% 🟢 +100.0% 🟢
SchemaTypeDirectivesChecker — method details
Method Line Branch
findDirectiveCycle new 100.0%
findCycleFromInputValueDefinitions new 100.0% 100.0%
findCycleFromDirectives new 100.0% 100.0%
findCycleFromDirectiveReference new 83.3% 66.7%
findCycleFromInputType new 100.0% 100.0%
findCycleFromScalarType new 50.0% 33.3%
findCycleFromEnumType new 75.0% 60.0%
findCycleFromEnumValues new 83.3% 75.0%
findCycleFromInputObjectType new 81.3% 70.0%
addToPath new 100.0%
addToVisited new 100.0%
cyclePath new 100.0%
directiveName new 100.0%
lambda$commonCheck$1 removed removed

Full HTML report: build artifact jacoco-html-report

Updated: 2026-04-08 20:56:37 UTC

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