Skip to content

Commit 99dca99

Browse files
committed
Allow for serializing int as BigInt
1 parent 50607e4 commit 99dca99

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/type/__tests__/scalars-test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ describe('Type System: Specified scalar types', () => {
614614
expect(serialize(123)).to.equal('123');
615615
expect(serialize(0)).to.equal('0');
616616
expect(serialize(-1)).to.equal('-1');
617+
expect(serialize(BigInt(123))).to.equal('123');
617618

618619
const valueOf = () => 'valueOf ID';
619620
const toJSON = () => 'toJSON ID';

src/type/scalars.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export const GraphQLID = new GraphQLScalarType<string>({
252252
if (typeof coercedValue === 'string') {
253253
return coercedValue;
254254
}
255-
if (Number.isInteger(coercedValue)) {
255+
if (Number.isInteger(coercedValue) || typeof coercedValue === 'bigint') {
256256
return String(coercedValue);
257257
}
258258
throw new GraphQLError(

0 commit comments

Comments
 (0)