-
Notifications
You must be signed in to change notification settings - Fork 2k
Returning too large of a number from Int resolver results in hard to debug errors #391
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
Comments
I ran into this same problem and commented on another related issue. As I point out there, I think that behavior is in violation of the spec:
(emphasis added) Would you accept a patch fixing this behavior? |
As illustrated by #391, when a value is provided for a field of type Int which cannot be represented by Int (e.g. a 64bit value is provided to the 32bit Int type), then the spec claims a field-error should be raised however currently `null` is returned directly instead. Spec: https://facebook.github.io/graphql/#sec-Int This updates to throw meaningful error messages when invalid Int and Float values cannot be coerced without losing information.
Hey, I really apologize for letting this issue sit. You're absolutely correct @uhoh-itsmaciek that this is a real bug relative to the correct spec language. I've attached a PR to fix it. |
As illustrated by #391, when a value is provided for a field of type Int which cannot be represented by Int (e.g. a 64bit value is provided to the 32bit Int type), then the spec claims a field-error should be raised however currently `null` is returned directly instead. Spec: https://facebook.github.io/graphql/#sec-Int This updates to throw meaningful error messages when invalid Int and Float values cannot be coerced without losing information.
Awesome, thanks @leebyron! |
If I have a field that is supposed to return
GraphQLInt
, then there are two hard-to-debug things that can happen if I return a number that's not within the allowed range, for example1463692053071
(a timestamp):null
on the client with no errors at allCannot return null for non-nullable field Entry.createdAt.
This is extra misleading since I didn't actually returnnull
- I returned a Number that was simply too large.Sounds like this can just be fixed by adding an error in the coerceInt function instead of silently returning
null
.The text was updated successfully, but these errors were encountered: