Skip to content

Commit ab8c9ba

Browse files
committed
scalars: ID and String support for serializing BigInt
1 parent 9b0514a commit ab8c9ba

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/type/__tests__/scalars-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ describe('Type System: Specified scalar types', () => {
620620
expect(serialize(123)).to.equal('123');
621621
expect(serialize(0)).to.equal('0');
622622
expect(serialize(-1)).to.equal('-1');
623+
// $FlowFixMe[bigint-unsupported];
624+
expect(serialize(1n)).to.equal('1');
623625

624626
const valueOf = () => 'valueOf ID';
625627
const toJSON = () => 'toJSON ID';

src/type/scalars.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ function serializeObject(outputValue: mixed): mixed {
143143
return outputValue.toJSON();
144144
}
145145
}
146+
// $FlowFixMe[illegal-typeof]
147+
if (typeof outputValue === 'bigint') {
148+
// $FlowFixMe[incompatible-use]
149+
return outputValue.toString();
150+
}
151+
146152
return outputValue;
147153
}
148154

0 commit comments

Comments
 (0)