Preserving custom scalars validation messages and adding validation errors metadata as extensions (#1686) #1727
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.
This addresses #1686 .
Custom scalars coercion error messages are preserved in the resulting error.
Also, validation messages have been simplified so they no longer carry concatenated pieces of relevant information to be parsed by clients (arguably making the message less coherent). The relevant information is provided as extensions to the resulting errors.
As an example, instead of:
"Validation error of type WrongType: argument 'arg.foo' with value 'StringValue{value='string'}' is not a valid 'Boolean'"
The validation message would be:
"'string' is not a valid Boolean"
(the original message from the failed scalar coercion) and other aspects of the validation are provided in the error extensions for clients to use directly as values:
or in another example, instead of:
"Validation error of type FieldsConflict: scalar: they return differing types Int and String @ 'boxUnion'"
The message would be:
"scalar: they return differing types Int and String"
and the extensions would include:
All in accordance with GraphQL errors spec.
Disclaimer: I worked on this before having seen #1725 . I will submit another PR merging the 2 PRs as I see the value of both.
This change is