File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -534,6 +534,7 @@ describe('Type System: Specified scalar types', () => {
534534 expect ( parseValue ( 1 ) ) . to . equal ( '1' ) ;
535535 expect ( parseValue ( 0 ) ) . to . equal ( '0' ) ;
536536 expect ( parseValue ( - 1 ) ) . to . equal ( '-1' ) ;
537+ expect ( parseValue ( BigInt ( 123 ) ) ) . to . equal ( '123' ) ;
537538
538539 // Maximum and minimum safe numbers in JS
539540 expect ( parseValue ( 9007199254740991 ) ) . to . equal ( '9007199254740991' ) ;
@@ -614,6 +615,7 @@ describe('Type System: Specified scalar types', () => {
614615 expect ( serialize ( 123 ) ) . to . equal ( '123' ) ;
615616 expect ( serialize ( 0 ) ) . to . equal ( '0' ) ;
616617 expect ( serialize ( - 1 ) ) . to . equal ( '-1' ) ;
618+ expect ( serialize ( BigInt ( 123 ) ) ) . to . equal ( '123' ) ;
617619
618620 const valueOf = ( ) => 'valueOf ID' ;
619621 const toJSON = ( ) => 'toJSON ID' ;
Original file line number Diff line number Diff 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 (
@@ -267,6 +267,9 @@ export const GraphQLID = new GraphQLScalarType<string>({
267267 if ( typeof inputValue === 'number' && Number . isInteger ( inputValue ) ) {
268268 return inputValue . toString ( ) ;
269269 }
270+ if ( typeof inputValue === 'bigint' ) {
271+ return inputValue . toString ( ) ;
272+ }
270273 throw new GraphQLError ( `ID cannot represent value: ${ inspect ( inputValue ) } ` ) ;
271274 } ,
272275
You can’t perform that action at this time.
0 commit comments