File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -534,6 +534,8 @@ describe('Type System: Specified scalar types', () => {
534
534
expect ( parseValue ( 1 ) ) . to . equal ( '1' ) ;
535
535
expect ( parseValue ( 0 ) ) . to . equal ( '0' ) ;
536
536
expect ( parseValue ( - 1 ) ) . to . equal ( '-1' ) ;
537
+ expect ( parseValue ( BigInt ( 123 ) ) ) . to . equal ( '123' ) ;
538
+ expect ( parseValue ( 1n ) ) . to . equal ( '1' ) ;
537
539
538
540
// Maximum and minimum safe numbers in JS
539
541
expect ( parseValue ( 9007199254740991 ) ) . to . equal ( '9007199254740991' ) ;
@@ -614,6 +616,8 @@ describe('Type System: Specified scalar types', () => {
614
616
expect ( serialize ( 123 ) ) . to . equal ( '123' ) ;
615
617
expect ( serialize ( 0 ) ) . to . equal ( '0' ) ;
616
618
expect ( serialize ( - 1 ) ) . to . equal ( '-1' ) ;
619
+ expect ( serialize ( BigInt ( 123 ) ) ) . to . equal ( '123' ) ;
620
+ expect ( serialize ( 1n ) ) . to . equal ( '1' ) ;
617
621
618
622
const valueOf = ( ) => 'valueOf ID' ;
619
623
const toJSON = ( ) => 'toJSON ID' ;
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ export const GraphQLID = new GraphQLScalarType<string>({
252
252
if ( typeof coercedValue === 'string' ) {
253
253
return coercedValue ;
254
254
}
255
- if ( Number . isInteger ( coercedValue ) ) {
255
+ if ( Number . isInteger ( coercedValue ) || typeof coercedValue === 'bigint' ) {
256
256
return String ( coercedValue ) ;
257
257
}
258
258
throw new GraphQLError (
@@ -267,6 +267,9 @@ export const GraphQLID = new GraphQLScalarType<string>({
267
267
if ( typeof inputValue === 'number' && Number . isInteger ( inputValue ) ) {
268
268
return inputValue . toString ( ) ;
269
269
}
270
+ if ( typeof inputValue === 'bigint' ) {
271
+ return inputValue . toString ( ) ;
272
+ }
270
273
throw new GraphQLError ( `ID cannot represent value: ${ inspect ( inputValue ) } ` ) ;
271
274
} ,
272
275
You can’t perform that action at this time.
0 commit comments