Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserving custom scalars validation messages and adding validation errors metadata as extensions (#1686) #1727

Closed

Conversation

liqweed
Copy link

@liqweed liqweed commented Jan 6, 2020

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:

"extensions": {
    "argument": "arg.foo",
    "value": "string", 
  	"requiredType": "Boolean", 
  	"objectType": "ArgumentObjectType",
  	"validationErrorType": "WrongType"
}

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:

"extensions": {
    "queryPath": "boxUnion",
  	"validationErrorType": "FieldsConflict"
}

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 Reviewable

@bbakerman bbakerman self-requested a review January 13, 2020 00:22
@bbakerman bbakerman self-assigned this Jan 13, 2020
@bbakerman bbakerman added the Not to be merged spikes or other stuff that should never or not yet to be merged label May 17, 2022
@bbakerman
Copy link
Member

Closed as old, not to be merged and in conflict

@bbakerman bbakerman closed this Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not to be merged spikes or other stuff that should never or not yet to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants