diff --git a/src/type/__tests__/scalars-test.ts b/src/type/__tests__/scalars-test.ts index fbb2cd9087..b9ae73bc2d 100644 --- a/src/type/__tests__/scalars-test.ts +++ b/src/type/__tests__/scalars-test.ts @@ -614,6 +614,7 @@ describe('Type System: Specified scalar types', () => { expect(serialize(123)).to.equal('123'); expect(serialize(0)).to.equal('0'); expect(serialize(-1)).to.equal('-1'); + expect(serialize(BigInt(123))).to.equal('123'); const valueOf = () => 'valueOf ID'; const toJSON = () => 'toJSON ID'; diff --git a/src/type/scalars.ts b/src/type/scalars.ts index a9003f7d54..2f97272d8f 100644 --- a/src/type/scalars.ts +++ b/src/type/scalars.ts @@ -252,7 +252,7 @@ export const GraphQLID = new GraphQLScalarType({ if (typeof coercedValue === 'string') { return coercedValue; } - if (Number.isInteger(coercedValue)) { + if (Number.isInteger(coercedValue) || typeof coercedValue === 'bigint') { return String(coercedValue); } throw new GraphQLError(