GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — visit fragment fields on every spread in QueryTraverser by nab-iha3 · Pull Request #4543 · graphql-java/graphql-java

Conversation

@nab-iha3

@nab-iha3 nab-iha3 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Spock, MaxQueryDepthInstrumentation(6) on {f1: foo {...F} f2: foo {foo {foo {foo {...F}}}} } fragment F on Foo {foo {foo {scalar}}}, before the change:

MaxQueryDepthInstrumentationTest > throws exception if too deep through a fragment that was spread before FAILED
    Expected exception of type 'graphql.execution.AbortExecutionException', but no exception was thrown

the query is 7 deep. written inline it is rejected with maximum query depth exceeded 7 > 6.

QueryTraverser follows a spread by handing the shared FragmentDefinition node to graphql.util.Traverser, which enters a node only once and treats later encounters as back references. every spread of a fragment after the first is skipped together with the fields under it, even when it sits under a different parent field (#1695). MaxQueryComplexityInstrumentation, MaxQueryDepthInstrumentation and FieldValidationInstrumentation all run on QueryTraverser, so a client can put the expensive part of a query behind a fragment it spreads more than once and have it neither counted nor validated. with the default 1 + childComplexity calculator:

17 KB query, 1000 aliases each spreading one 20 field fragment
before: complexity 1040
after:  complexity 41000 (the fields actually requested)

NodeVisitorWithTypeTracking.visitFragmentDefinition now removes the fragment's nodes from the traverser's visited set when the definition is left, so the next spread is followed again. a spread of a fragment inside its own body still finds it visited while it is being traversed, so fragment cycles still terminate (covered by a test). this is what the QueryTraverser javadoc already describes (no field merging), and it is the same per spread counting OperationValidator uses for its field count limit, which also bounds how far repeated spreads can expand.

one behaviour change to be aware of: scores go up for queries that reuse fragments. the standard introspection query goes from 64 to 191 with the default calculator (depth stays at 13), so a MaxQueryComplexityInstrumentation limit set between those two values will start rejecting it.

the new tests in QueryTraverserTest, MaxQueryDepthInstrumentationTest and MaxQueryComplexityInstrumentationTest fail before the change. the full test and testng suites pass on Java 25, and the analysis tests pass on 17 and 21.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nab-iha3
visit fragment fields on every spread in QueryTraverser
003eac1
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Test Report

Test Results

Java Version Total Passed Failed Errors Skipped
Java 17 6266 (+4 🟢) 6210 (+4 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 21 6266 (+4 🟢) 6210 (+4 🟢) 0 (±0) 0 (±0) 56 (±0)
Java 25 6266 (+4 🟢) 6210 (+4 🟢) 0 (±0) 0 (±0) 56 (±0)
jcstress 32 (±0) 32 (±0) 0 (±0) 0 (±0) 0 (±0)
Total 18830 (+12 🟢) 18662 (+12 🟢) 0 (±0) 0 (±0) 168 (±0)

Code Coverage (Java 25)

Metric Covered Missed Coverage vs Master
Lines 30364 3078 90.8% ±0.0%
Branches 8974 1504 85.6% ±0.0%
Methods 8103 1186 87.2% ±0.0%

Changed Class Coverage (2 classes)

Class Line Branch Method
g.a.NodeVisitorWithTypeTracking +0.1% 🟢 +0.3% 🟢 ±0.0%
g.u.DefaultTraverserContext +1.3% 🟢 ±0.0% +3.3% 🟢

Full HTML report: build artifact jacoco-html-report

Updated: 2026-11-07 06:36:57 UTC

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@nab-iha3
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.