-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
When resolving an output value through Int
scalar, NaN
causes an error to be thrown:
Int cannot represent non-integer value: NaN
const schema = makeExecutableSchema({
typeDefs: /* GraphQL */ `
type Query {
testInt: Int
}
`,
resolvers: {
Query: {
testInt: () => NaN,
},
},
});
const query = parse(/* GraphQL */ `query {
testInt
}`);
const result = executeSync({
schema,
document: query,
});
expect(result).toEqual({ data: { testInt: null }, errors: [expect.objectContaining({ message: 'Int cannot represent non-integer value: NaN' })] });
However, the GraphQL Specification states that NaN
should be coerced to null
and returned:
- If result is null (or another internal value similar to null such as undefined or NaN), return null.
Metadata
Metadata
Assignees
Labels
No labels