Skip to content

Hide deprecated schema elements from query validation when generateDeprecated is false - #3609

Merged
velo merged 2 commits into
masterfrom
graphql-apt-hide-deprecated
Oct 7, 2026
Merged

velo merged 2 commits into
masterfrom
graphql-apt-hide-deprecated

Conversation

@velo

@velo velo commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Problem

generateDeprecated = false only stopped the generator from emitting deprecated fields and enum constants. Queries were still validated against the full schema, so selecting a deprecated field compiled fine and the field was silently dropped from the generated record.

Change

When the effective generateDeprecated (class-level, or method-level Toggle override) is false, QueryValidator walks each query with graphql-java's QueryTraverser after normal validation and reports every deprecated element it uses: fields, arguments, input fields, enum values, including enum values in variable defaults. The error names the element and its @deprecated reason, e.g. Field 'email' is deprecated (use emails instead) and generateDeprecated is false.

An earlier revision stripped deprecated elements from a copy of the schema. That made graphql-java reject valid schemas (enum or input defaults that use a deprecated value, types whose fields are all deprecated, interface fields deprecated in an implementation) for every interface, so it was replaced.

Also removes the deprecated-field filter in TypeGenerator.buildResultType, which can no longer run, and documents the setting in graphql-apt/README.md.

Behaviour change

Interfaces that select deprecated fields with generateDeprecated = false used to compile (dropping the field) and now fail with a GraphQL validation error.

Tests

  • Parameterized cases for a deprecated field (literal and variable argument), argument, enum literal, enum variable default, and input-object field, each asserting its message, with the toggle set at class level and at method level; the same queries compile when enabled
  • deprecated-edge-schema.graphql fixture with the schema shapes that broke the stripping approach, compiled with the flag on and off
  • Removed assertions that could no longer fail

velo added 2 commits October 7, 2026 17:50
…precated is false

Signed-off-by: Marvin Froeder <velo.br@gmail.com>
…g them from the schema

Signed-off-by: Marvin Froeder <velo.br@gmail.com>
@velo
velo merged commit f48c707 into master Oct 7, 2026
7 checks passed
@velo
velo deleted the graphql-apt-hide-deprecated branch October 7, 2026 21:15
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