Repository navigation
Clarify what Coercing.valueToLiteral receives and when it is called - #4561
Merged
bbakerman merged 2 commits intoNov 15, 2026
Merged
Conversation
The Javadoc did not say whether valueToLiteral gets an external or an internal value, and did not say when graphql-java calls it, so scalar authors could not tell whether they need to implement it. Document the external, internal and literal forms, state that valueToLiteral receives an external value (not a serialized one), and list the cases that call it: printing, introspection and validation of programmatic default and applied directive values, and normalized variables. Add a test that pins this behaviour. Fixes graphql-java#3558
bbakerman
enabled auto-merge
November 15, 2026 22:47
Contributor
Test ReportTest Results
Code Coverage (Java 25)
|
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.
Fixes #3558
The
CoercingJavadoc did not say whethervalueToLiteralgets an external or an internal value, or when graphql-java actually calls it, so scalar authors could not tell whether they need to implement it.This PR:
valueToLiteralreceives an external value (the same kindparseValueaccepts), not an internal value or the result ofserialize.SchemaPrinter), introspection and validation of external-state values set viadefaultValueProgrammatic(Object)orvalueProgrammatic(Object)on applied directive argumentsValuesResolver#getNormalizedVariableValues)defaultValueLiteral(Value)and the deprecateddefaultValue(Object)don't go through it, so schemas that only use those never hit the defaultUnsupportedOperationException.CoercingTestthat pins this behaviour.As discussed in #3558 (comment). The earlier comment that it is only called via
getNormalizedVariableValuesis no longer accurate, which the new test shows.Ran
./gradlew test --tests graphql.schema.CoercingTest: 6 tests, 0 failures.