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

0.8.x breaking change with errors thrown from scalar resolvers #821

Closed
thebigredgeek opened this issue Apr 21, 2017 · 2 comments
Closed

Comments

@thebigredgeek
Copy link

thebigredgeek commented Apr 21, 2017

It appears that 0.8.x introduced a breaking change with errors thrown from scalar resolvers. Upon upgrading, it appears that errors thrown from scalar resolvers (exclusively) have, by the time they have reached formatErrors, been transformed into a shape like:

[1] [1]   message: 'Variable "$input" got invalid value {"stripeCardName":"asdasdada","stripeCardNumber":"42424242424223113","stripeCardExp":"00/00","stripeCardCVC":"233"}.\nIn field "stripeCardNumber": Expected type "CreditCardNumber", found "42424242424223113": The credit card number you entered appears to be invalid.',
[1] [1]   locations: [ { line: 1, column: 28 } ],
[1] [1]   path: undefined }

where the original error message was "The credit card number you entered appears to be invalid", and the original error object contained a bunch of useful meta data as an error created with apollo-errors that instructed the client about validation issues (in this case, a credit card number that isn't valid according to ccn validation algorithms).

Was this intended? It seems strange to force an error format like this, especially as a breaking change.

It looks like this might have been the change, according to the v0.8.0 release changelog

@helfer
Copy link
Contributor

helfer commented Apr 22, 2017

@thebigredgeek the PR in question is this one, and I believe it was very much intentional. Just looking at the error message and the PR, I'm guessing that maybe the error isn't being thrown from a resolver, but from parseValue?

@thebigredgeek
Copy link
Author

Yes, you are correct. Is parseValue not part of the scalar's resolver, though?

leebyron added a commit that referenced this issue Dec 14, 2017
This generalizes the "arguments of correct type" and "default values of correct type" to a single rule "values of correct type" which has been re-written to rely on a traversal rather than the utility function `isValidLiteralValue`. To reduce breaking scope, this does not remove that utility even though it's no longer used directly within the library. Since the default values rule included another validation rule that rule was renamed to a more apt "variable default value allowed".

This also includes the original errors from custom scalars in the validation error output, solving the remainder of #821.

Closes #821
leebyron added a commit that referenced this issue Dec 14, 2017
This generalizes the "arguments of correct type" and "default values of correct type" to a single rule "values of correct type" which has been re-written to rely on a traversal rather than the utility function `isValidLiteralValue`. To reduce breaking scope, this does not remove that utility even though it's no longer used directly within the library. Since the default values rule included another validation rule that rule was renamed to a more apt "variable default value allowed".

This also includes the original errors from custom scalars in the validation error output, solving the remainder of #821.

Closes #821
leebyron added a commit that referenced this issue Dec 14, 2017
This generalizes the "arguments of correct type" and "default values of correct type" to a single rule "values of correct type" which has been re-written to rely on a traversal rather than the utility function `isValidLiteralValue`. To reduce breaking scope, this does not remove that utility even though it's no longer used directly within the library. Since the default values rule included another validation rule that rule was renamed to a more apt "variable default value allowed".

This also includes the original errors from custom scalars in the validation error output, solving the remainder of #821.

Closes #821
leebyron added a commit that referenced this issue Dec 14, 2017
This generalizes the "arguments of correct type" and "default values of correct type" to a single rule "values of correct type" which has been re-written to rely on a traversal rather than the utility function `isValidLiteralValue`. To reduce breaking scope, this does not remove that utility even though it's no longer used directly within the library. Since the default values rule included another validation rule that rule was renamed to a more apt "variable default value allowed".

This also includes the original errors from custom scalars in the validation error output, solving the remainder of #821.

Closes #821
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

No branches or pull requests

2 participants