You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The coerce function for the integers is defined as
export var GraphQLInt = new GraphQLScalarType({
name: 'Int',
coerce(value) {
var num = +value;
return num === num && num <= MAX_INT && num >= MIN_INT ? num | 0 : null;
},
coerceLiteral(ast) {
if (ast.kind === Kind.INT) {
var num = parseInt(ast.value, 10);
if (num <= MAX_INT && num >= MIN_INT) {
return num;
}
}
}
});
Which means that if a number does not fit the 32 bits, then the significant bits will be truncated.
Which is generally a not expected behaviour, since the coercion must either produce a valid result, or a null.
@leebyron sorry for disturbing, but in es6/2015 there is a Math.trunc() that could help eliminate the entire (num < 0 ? Math.ceil : Math.floor) expression
The
coerce
function for the integers is defined asWhich means that if a number does not fit the 32 bits, then the significant bits will be truncated.
Which is generally a not expected behaviour, since the coercion must either produce a valid result, or a
null
.References:
The text was updated successfully, but these errors were encountered: