-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Int
input value coercion from floating point JSON literal value
#827
Comments
I think you've read it correctly, @OlegIlyenko, and that the reference implementation is probably wrong (rather than coercing input types to |
This would be definitely an important thing to consider. Though as the first step I think it would helpful to look on the issue on itself, and brainstorm on the best definition. At the moment I feel that the way it's specified in the spec is quite good. Allowing server to coerce |
I think you're right, and that's my sense too (that's why the spec text seems so "intentional" about it). |
The section immediately above the Int section in the spec discusses coercing a floating point value to an int as it's "canonical" example. We should probably also make sure the spec agrees with itself. |
@mjmahone: Are you referring to "Result Coercion" section under 3.1.1 Scalars?
I don't think that's in conflict, as the thing we're talking about here is "Input Coercion". |
This fixes an issue with coercing Int values when provided a floating point value which disagrees with the spec definition. Updates test cases which were along the same incorrect line. Note: this is technically a breaking change Fixes #827
I agree, @OlegIlyenko - the spec language is nicer than what's implemented here. I've put up a PR if we decide to fix this in the library vs proposing a change to spec. |
This fixes an issue with coercing Int values when provided a floating point value which disagrees with the spec definition. Updates test cases which were along the same incorrect line. Note: this is technically a breaking change Fixes #827
According to the spec (https://facebook.github.io/graphql/#sec-Scalars):
Based on this description, when I define a value in JSON for a variable of an
Int
type:123.0
must be considered a valid value and coerce to123
123.456
must be considered an invalid value and should result in error based onInt
input value coercion rules (https://facebook.github.io/graphql/#sec-Int):Do I understand it correctly?
I discovered that reference implementation allows
123.456
value for a variable ofInt
type which does not comply to the mentioned parts of the spec. Here is the line that successfully drops fraction digits:https://github.com/graphql/graphql-js/blob/master/src/type/scalars.js#L30
The text was updated successfully, but these errors were encountered: