graphql-js
graphql-js copied to clipboard
Support for bigint in ID
It's desirable to represent an ID on the server as a bigint instead of a number.
Currently, the ID scalar type supports serializing number to string, but not bigint.
I'd like to see support for serialization of bigint to string similar to number.
I think it would require changing this code https://github.com/graphql/graphql-js/blob/d766c8eb34fb03c5ee63c51380f2b012924e970c/src/type/scalars.ts#L225-L227 to
if (Number.isInteger(coercedValue) || typeof coercedValue == "bigint") {
return String(coercedValue);
}
This is correct, the spec supports 128-bit numbers https://spec.graphql.org/draft/#sec-ID