Repository navigation
Hide deprecated schema elements from query validation when generateDeprecated is false - #3609
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
generateDeprecated = falseonly 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-levelToggleoverride) is false,QueryValidatorwalks each query with graphql-java'sQueryTraverserafter 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@deprecatedreason, 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 ingraphql-apt/README.md.Behaviour change
Interfaces that select deprecated fields with
generateDeprecated = falseused to compile (dropping the field) and now fail with aGraphQL validation error.Tests
deprecated-edge-schema.graphqlfixture with the schema shapes that broke the stripping approach, compiled with the flag on and off