@@ -64,45 +64,45 @@ describe('Type System: Specified scalar types', () => {
64
64
) ;
65
65
} ) ;
66
66
67
- it ( 'parseConstLiteral ' , ( ) => {
68
- function parseConstLiteral ( str : string ) {
67
+ it ( 'coerceInputLiteral ' , ( ) => {
68
+ function coerceInputLiteral ( str : string ) {
69
69
/* @ts -expect-error to be removed in v18 when all custom scalars will have default method */
70
- return GraphQLInt . parseConstLiteral ( parseConstValue ( str ) ) ;
70
+ return GraphQLInt . coerceInputLiteral ( parseConstValue ( str ) ) ;
71
71
}
72
72
73
- expect ( parseConstLiteral ( '1' ) ) . to . equal ( 1 ) ;
74
- expect ( parseConstLiteral ( '0' ) ) . to . equal ( 0 ) ;
75
- expect ( parseConstLiteral ( '-1' ) ) . to . equal ( - 1 ) ;
73
+ expect ( coerceInputLiteral ( '1' ) ) . to . equal ( 1 ) ;
74
+ expect ( coerceInputLiteral ( '0' ) ) . to . equal ( 0 ) ;
75
+ expect ( coerceInputLiteral ( '-1' ) ) . to . equal ( - 1 ) ;
76
76
77
- expect ( ( ) => parseConstLiteral ( '9876504321' ) ) . to . throw (
77
+ expect ( ( ) => coerceInputLiteral ( '9876504321' ) ) . to . throw (
78
78
'Int cannot represent non 32-bit signed integer value: 9876504321' ,
79
79
) ;
80
- expect ( ( ) => parseConstLiteral ( '-9876504321' ) ) . to . throw (
80
+ expect ( ( ) => coerceInputLiteral ( '-9876504321' ) ) . to . throw (
81
81
'Int cannot represent non 32-bit signed integer value: -9876504321' ,
82
82
) ;
83
83
84
- expect ( ( ) => parseConstLiteral ( '1.0' ) ) . to . throw (
84
+ expect ( ( ) => coerceInputLiteral ( '1.0' ) ) . to . throw (
85
85
'Int cannot represent non-integer value: 1.0' ,
86
86
) ;
87
- expect ( ( ) => parseConstLiteral ( 'null' ) ) . to . throw (
87
+ expect ( ( ) => coerceInputLiteral ( 'null' ) ) . to . throw (
88
88
'Int cannot represent non-integer value: null' ,
89
89
) ;
90
- expect ( ( ) => parseConstLiteral ( '""' ) ) . to . throw (
90
+ expect ( ( ) => coerceInputLiteral ( '""' ) ) . to . throw (
91
91
'Int cannot represent non-integer value: ""' ,
92
92
) ;
93
- expect ( ( ) => parseConstLiteral ( '"123"' ) ) . to . throw (
93
+ expect ( ( ) => coerceInputLiteral ( '"123"' ) ) . to . throw (
94
94
'Int cannot represent non-integer value: "123"' ,
95
95
) ;
96
- expect ( ( ) => parseConstLiteral ( 'false' ) ) . to . throw (
96
+ expect ( ( ) => coerceInputLiteral ( 'false' ) ) . to . throw (
97
97
'Int cannot represent non-integer value: false' ,
98
98
) ;
99
- expect ( ( ) => parseConstLiteral ( '[1]' ) ) . to . throw (
99
+ expect ( ( ) => coerceInputLiteral ( '[1]' ) ) . to . throw (
100
100
'Int cannot represent non-integer value: [1]' ,
101
101
) ;
102
- expect ( ( ) => parseConstLiteral ( '{ value: 1 }' ) ) . to . throw (
102
+ expect ( ( ) => coerceInputLiteral ( '{ value: 1 }' ) ) . to . throw (
103
103
'Int cannot represent non-integer value: { value: 1 }' ,
104
104
) ;
105
- expect ( ( ) => parseConstLiteral ( 'ENUM_VALUE' ) ) . to . throw (
105
+ expect ( ( ) => coerceInputLiteral ( 'ENUM_VALUE' ) ) . to . throw (
106
106
'Int cannot represent non-integer value: ENUM_VALUE' ,
107
107
) ;
108
108
} ) ;
@@ -227,40 +227,40 @@ describe('Type System: Specified scalar types', () => {
227
227
) ;
228
228
} ) ;
229
229
230
- it ( 'parseConstLiteral ' , ( ) => {
231
- function parseConstLiteral ( str : string ) {
230
+ it ( 'coerceInputLiteral ' , ( ) => {
231
+ function coerceInputLiteral ( str : string ) {
232
232
/* @ts -expect-error to be removed in v18 when all custom scalars will have default method */
233
- return GraphQLFloat . parseConstLiteral ( parseConstValue ( str ) ) ;
233
+ return GraphQLFloat . coerceInputLiteral ( parseConstValue ( str ) ) ;
234
234
}
235
235
236
- expect ( parseConstLiteral ( '1' ) ) . to . equal ( 1 ) ;
237
- expect ( parseConstLiteral ( '0' ) ) . to . equal ( 0 ) ;
238
- expect ( parseConstLiteral ( '-1' ) ) . to . equal ( - 1 ) ;
239
- expect ( parseConstLiteral ( '0.1' ) ) . to . equal ( 0.1 ) ;
240
- expect ( parseConstLiteral ( Math . PI . toString ( ) ) ) . to . equal ( Math . PI ) ;
236
+ expect ( coerceInputLiteral ( '1' ) ) . to . equal ( 1 ) ;
237
+ expect ( coerceInputLiteral ( '0' ) ) . to . equal ( 0 ) ;
238
+ expect ( coerceInputLiteral ( '-1' ) ) . to . equal ( - 1 ) ;
239
+ expect ( coerceInputLiteral ( '0.1' ) ) . to . equal ( 0.1 ) ;
240
+ expect ( coerceInputLiteral ( Math . PI . toString ( ) ) ) . to . equal ( Math . PI ) ;
241
241
242
- expect ( ( ) => parseConstLiteral ( 'null' ) ) . to . throw (
242
+ expect ( ( ) => coerceInputLiteral ( 'null' ) ) . to . throw (
243
243
'Float cannot represent non numeric value: null' ,
244
244
) ;
245
- expect ( ( ) => parseConstLiteral ( '""' ) ) . to . throw (
245
+ expect ( ( ) => coerceInputLiteral ( '""' ) ) . to . throw (
246
246
'Float cannot represent non numeric value: ""' ,
247
247
) ;
248
- expect ( ( ) => parseConstLiteral ( '"123"' ) ) . to . throw (
248
+ expect ( ( ) => coerceInputLiteral ( '"123"' ) ) . to . throw (
249
249
'Float cannot represent non numeric value: "123"' ,
250
250
) ;
251
- expect ( ( ) => parseConstLiteral ( '"123.5"' ) ) . to . throw (
251
+ expect ( ( ) => coerceInputLiteral ( '"123.5"' ) ) . to . throw (
252
252
'Float cannot represent non numeric value: "123.5"' ,
253
253
) ;
254
- expect ( ( ) => parseConstLiteral ( 'false' ) ) . to . throw (
254
+ expect ( ( ) => coerceInputLiteral ( 'false' ) ) . to . throw (
255
255
'Float cannot represent non numeric value: false' ,
256
256
) ;
257
- expect ( ( ) => parseConstLiteral ( '[0.1]' ) ) . to . throw (
257
+ expect ( ( ) => coerceInputLiteral ( '[0.1]' ) ) . to . throw (
258
258
'Float cannot represent non numeric value: [0.1]' ,
259
259
) ;
260
- expect ( ( ) => parseConstLiteral ( '{ value: 0.1 }' ) ) . to . throw (
260
+ expect ( ( ) => coerceInputLiteral ( '{ value: 0.1 }' ) ) . to . throw (
261
261
'Float cannot represent non numeric value: { value: 0.1 }' ,
262
262
) ;
263
- expect ( ( ) => parseConstLiteral ( 'ENUM_VALUE' ) ) . to . throw (
263
+ expect ( ( ) => coerceInputLiteral ( 'ENUM_VALUE' ) ) . to . throw (
264
264
'Float cannot represent non numeric value: ENUM_VALUE' ,
265
265
) ;
266
266
} ) ;
@@ -338,34 +338,34 @@ describe('Type System: Specified scalar types', () => {
338
338
) ;
339
339
} ) ;
340
340
341
- it ( 'parseConstLiteral ' , ( ) => {
342
- function parseConstLiteral ( str : string ) {
341
+ it ( 'coerceInputLiteral ' , ( ) => {
342
+ function coerceInputLiteral ( str : string ) {
343
343
/* @ts -expect-error to be removed in v18 when all custom scalars will have default method */
344
- return GraphQLString . parseConstLiteral ( parseConstValue ( str ) ) ;
344
+ return GraphQLString . coerceInputLiteral ( parseConstValue ( str ) ) ;
345
345
}
346
346
347
- expect ( parseConstLiteral ( '"foo"' ) ) . to . equal ( 'foo' ) ;
348
- expect ( parseConstLiteral ( '"""bar"""' ) ) . to . equal ( 'bar' ) ;
347
+ expect ( coerceInputLiteral ( '"foo"' ) ) . to . equal ( 'foo' ) ;
348
+ expect ( coerceInputLiteral ( '"""bar"""' ) ) . to . equal ( 'bar' ) ;
349
349
350
- expect ( ( ) => parseConstLiteral ( 'null' ) ) . to . throw (
350
+ expect ( ( ) => coerceInputLiteral ( 'null' ) ) . to . throw (
351
351
'String cannot represent a non string value: null' ,
352
352
) ;
353
- expect ( ( ) => parseConstLiteral ( '1' ) ) . to . throw (
353
+ expect ( ( ) => coerceInputLiteral ( '1' ) ) . to . throw (
354
354
'String cannot represent a non string value: 1' ,
355
355
) ;
356
- expect ( ( ) => parseConstLiteral ( '0.1' ) ) . to . throw (
356
+ expect ( ( ) => coerceInputLiteral ( '0.1' ) ) . to . throw (
357
357
'String cannot represent a non string value: 0.1' ,
358
358
) ;
359
- expect ( ( ) => parseConstLiteral ( 'false' ) ) . to . throw (
359
+ expect ( ( ) => coerceInputLiteral ( 'false' ) ) . to . throw (
360
360
'String cannot represent a non string value: false' ,
361
361
) ;
362
- expect ( ( ) => parseConstLiteral ( '["foo"]' ) ) . to . throw (
362
+ expect ( ( ) => coerceInputLiteral ( '["foo"]' ) ) . to . throw (
363
363
'String cannot represent a non string value: ["foo"]' ,
364
364
) ;
365
- expect ( ( ) => parseConstLiteral ( '{ value: "foo" }' ) ) . to . throw (
365
+ expect ( ( ) => coerceInputLiteral ( '{ value: "foo" }' ) ) . to . throw (
366
366
'String cannot represent a non string value: { value: "foo" }' ,
367
367
) ;
368
- expect ( ( ) => parseConstLiteral ( 'ENUM_VALUE' ) ) . to . throw (
368
+ expect ( ( ) => coerceInputLiteral ( 'ENUM_VALUE' ) ) . to . throw (
369
369
'String cannot represent a non string value: ENUM_VALUE' ,
370
370
) ;
371
371
} ) ;
@@ -448,40 +448,40 @@ describe('Type System: Specified scalar types', () => {
448
448
) ;
449
449
} ) ;
450
450
451
- it ( 'parseConstLiteral ' , ( ) => {
452
- function parseConstLiteral ( str : string ) {
451
+ it ( 'coerceInputLiteral ' , ( ) => {
452
+ function coerceInputLiteral ( str : string ) {
453
453
/* @ts -expect-error to be removed in v18 when all custom scalars will have default method */
454
- return GraphQLBoolean . parseConstLiteral ( parseConstValue ( str ) ) ;
454
+ return GraphQLBoolean . coerceInputLiteral ( parseConstValue ( str ) ) ;
455
455
}
456
456
457
- expect ( parseConstLiteral ( 'true' ) ) . to . equal ( true ) ;
458
- expect ( parseConstLiteral ( 'false' ) ) . to . equal ( false ) ;
457
+ expect ( coerceInputLiteral ( 'true' ) ) . to . equal ( true ) ;
458
+ expect ( coerceInputLiteral ( 'false' ) ) . to . equal ( false ) ;
459
459
460
- expect ( ( ) => parseConstLiteral ( 'null' ) ) . to . throw (
460
+ expect ( ( ) => coerceInputLiteral ( 'null' ) ) . to . throw (
461
461
'Boolean cannot represent a non boolean value: null' ,
462
462
) ;
463
- expect ( ( ) => parseConstLiteral ( '0' ) ) . to . throw (
463
+ expect ( ( ) => coerceInputLiteral ( '0' ) ) . to . throw (
464
464
'Boolean cannot represent a non boolean value: 0' ,
465
465
) ;
466
- expect ( ( ) => parseConstLiteral ( '1' ) ) . to . throw (
466
+ expect ( ( ) => coerceInputLiteral ( '1' ) ) . to . throw (
467
467
'Boolean cannot represent a non boolean value: 1' ,
468
468
) ;
469
- expect ( ( ) => parseConstLiteral ( '0.1' ) ) . to . throw (
469
+ expect ( ( ) => coerceInputLiteral ( '0.1' ) ) . to . throw (
470
470
'Boolean cannot represent a non boolean value: 0.1' ,
471
471
) ;
472
- expect ( ( ) => parseConstLiteral ( '""' ) ) . to . throw (
472
+ expect ( ( ) => coerceInputLiteral ( '""' ) ) . to . throw (
473
473
'Boolean cannot represent a non boolean value: ""' ,
474
474
) ;
475
- expect ( ( ) => parseConstLiteral ( '"false"' ) ) . to . throw (
475
+ expect ( ( ) => coerceInputLiteral ( '"false"' ) ) . to . throw (
476
476
'Boolean cannot represent a non boolean value: "false"' ,
477
477
) ;
478
- expect ( ( ) => parseConstLiteral ( '[false]' ) ) . to . throw (
478
+ expect ( ( ) => coerceInputLiteral ( '[false]' ) ) . to . throw (
479
479
'Boolean cannot represent a non boolean value: [false]' ,
480
480
) ;
481
- expect ( ( ) => parseConstLiteral ( '{ value: false }' ) ) . to . throw (
481
+ expect ( ( ) => coerceInputLiteral ( '{ value: false }' ) ) . to . throw (
482
482
'Boolean cannot represent a non boolean value: { value: false }' ,
483
483
) ;
484
- expect ( ( ) => parseConstLiteral ( 'ENUM_VALUE' ) ) . to . throw (
484
+ expect ( ( ) => coerceInputLiteral ( 'ENUM_VALUE' ) ) . to . throw (
485
485
'Boolean cannot represent a non boolean value: ENUM_VALUE' ,
486
486
) ;
487
487
} ) ;
@@ -561,44 +561,44 @@ describe('Type System: Specified scalar types', () => {
561
561
) ;
562
562
} ) ;
563
563
564
- it ( 'parseConstLiteral ' , ( ) => {
565
- function parseConstLiteral ( str : string ) {
564
+ it ( 'coerceInputLiteral ' , ( ) => {
565
+ function coerceInputLiteral ( str : string ) {
566
566
/* @ts -expect-error to be removed in v18 when all custom scalars will have default method */
567
- return GraphQLID . parseConstLiteral ( parseConstValue ( str ) ) ;
567
+ return GraphQLID . coerceInputLiteral ( parseConstValue ( str ) ) ;
568
568
}
569
569
570
- expect ( parseConstLiteral ( '""' ) ) . to . equal ( '' ) ;
571
- expect ( parseConstLiteral ( '"1"' ) ) . to . equal ( '1' ) ;
572
- expect ( parseConstLiteral ( '"foo"' ) ) . to . equal ( 'foo' ) ;
573
- expect ( parseConstLiteral ( '"""foo"""' ) ) . to . equal ( 'foo' ) ;
574
- expect ( parseConstLiteral ( '1' ) ) . to . equal ( '1' ) ;
575
- expect ( parseConstLiteral ( '0' ) ) . to . equal ( '0' ) ;
576
- expect ( parseConstLiteral ( '-1' ) ) . to . equal ( '-1' ) ;
570
+ expect ( coerceInputLiteral ( '""' ) ) . to . equal ( '' ) ;
571
+ expect ( coerceInputLiteral ( '"1"' ) ) . to . equal ( '1' ) ;
572
+ expect ( coerceInputLiteral ( '"foo"' ) ) . to . equal ( 'foo' ) ;
573
+ expect ( coerceInputLiteral ( '"""foo"""' ) ) . to . equal ( 'foo' ) ;
574
+ expect ( coerceInputLiteral ( '1' ) ) . to . equal ( '1' ) ;
575
+ expect ( coerceInputLiteral ( '0' ) ) . to . equal ( '0' ) ;
576
+ expect ( coerceInputLiteral ( '-1' ) ) . to . equal ( '-1' ) ;
577
577
578
578
// Support arbitrary long numbers even if they can't be represented in JS
579
- expect ( parseConstLiteral ( '90071992547409910' ) ) . to . equal (
579
+ expect ( coerceInputLiteral ( '90071992547409910' ) ) . to . equal (
580
580
'90071992547409910' ,
581
581
) ;
582
- expect ( parseConstLiteral ( '-90071992547409910' ) ) . to . equal (
582
+ expect ( coerceInputLiteral ( '-90071992547409910' ) ) . to . equal (
583
583
'-90071992547409910' ,
584
584
) ;
585
585
586
- expect ( ( ) => parseConstLiteral ( 'null' ) ) . to . throw (
586
+ expect ( ( ) => coerceInputLiteral ( 'null' ) ) . to . throw (
587
587
'ID cannot represent a non-string and non-integer value: null' ,
588
588
) ;
589
- expect ( ( ) => parseConstLiteral ( '0.1' ) ) . to . throw (
589
+ expect ( ( ) => coerceInputLiteral ( '0.1' ) ) . to . throw (
590
590
'ID cannot represent a non-string and non-integer value: 0.1' ,
591
591
) ;
592
- expect ( ( ) => parseConstLiteral ( 'false' ) ) . to . throw (
592
+ expect ( ( ) => coerceInputLiteral ( 'false' ) ) . to . throw (
593
593
'ID cannot represent a non-string and non-integer value: false' ,
594
594
) ;
595
- expect ( ( ) => parseConstLiteral ( '["1"]' ) ) . to . throw (
595
+ expect ( ( ) => coerceInputLiteral ( '["1"]' ) ) . to . throw (
596
596
'ID cannot represent a non-string and non-integer value: ["1"]' ,
597
597
) ;
598
- expect ( ( ) => parseConstLiteral ( '{ value: "1" }' ) ) . to . throw (
598
+ expect ( ( ) => coerceInputLiteral ( '{ value: "1" }' ) ) . to . throw (
599
599
'ID cannot represent a non-string and non-integer value: { value: "1" }' ,
600
600
) ;
601
- expect ( ( ) => parseConstLiteral ( 'ENUM_VALUE' ) ) . to . throw (
601
+ expect ( ( ) => coerceInputLiteral ( 'ENUM_VALUE' ) ) . to . throw (
602
602
'ID cannot represent a non-string and non-integer value: ENUM_VALUE' ,
603
603
) ;
604
604
} ) ;
0 commit comments