@@ -217,15 +217,16 @@ export class GraphQLScalarType<InternalType> {
217
217
this . description = config . description ;
218
218
invariant (
219
219
typeof config . serialize === 'function' ,
220
- `${ this } must provide "serialize" function. If this custom Scalar is ` +
221
- 'also used as an input type, ensure "parseValue" and "parseLiteral" ' +
220
+ `${ this . name } must provide "serialize" function. If this custom Scalar ` +
221
+ 'is also used as an input type, ensure "parseValue" and "parseLiteral" ' +
222
222
'functions are also provided.'
223
223
) ;
224
224
if ( config . parseValue || config . parseLiteral ) {
225
225
invariant (
226
226
typeof config . parseValue === 'function' &&
227
227
typeof config . parseLiteral === 'function' ,
228
- `${ this } must provide both "parseValue" and "parseLiteral" functions.`
228
+ `${ this . name } must provide both "parseValue" and "parseLiteral" ` +
229
+ 'functions.'
229
230
) ;
230
231
}
231
232
this . _scalarConfig = config ;
@@ -315,7 +316,7 @@ export class GraphQLObjectType {
315
316
if ( config . isTypeOf ) {
316
317
invariant (
317
318
typeof config . isTypeOf === 'function ',
318
- `${this } must provide "isTypeOf " as a function . `
319
+ `${this . name } must provide "isTypeOf " as a function . `
319
320
) ;
320
321
}
321
322
this . isTypeOf = config . isTypeOf ;
@@ -353,21 +354,22 @@ function defineInterfaces(
353
354
}
354
355
invariant (
355
356
Array . isArray ( interfaces ) ,
356
- `${type } interfaces must be an Array or a function which returns an Array . `
357
+ `${type . name } interfaces must be an Array or a function which returns ` +
358
+ 'an Array . '
357
359
) ;
358
360
interfaces . forEach ( iface => {
359
361
invariant (
360
362
iface instanceof GraphQLInterfaceType ,
361
- `${type } may only implement Interface types , it cannot ` +
362
- `implement : ${iface } . `
363
+ `${type . name } may only implement Interface types , it cannot ` +
364
+ `implement : ${iface . name } . `
363
365
) ;
364
366
if ( typeof iface . resolveType !== 'function ') {
365
367
invariant (
366
368
typeof type . isTypeOf === 'function ',
367
- `Interface Type ${iface } does not provide a "resolveType " function ` +
368
- `and implementing Type ${type } does not provide a " isTypeOf " ` +
369
- 'function . There is no way to resolve this implementing type ' +
370
- 'during execution . '
369
+ `Interface Type ${iface . name } does not provide a "resolveType " ` +
370
+ `function and implementing Type ${type . name } does not provide a ` +
371
+ '" isTypeOf " function . There is no way to resolve this implementing ' +
372
+ 'type during execution . '
371
373
) ;
372
374
}
373
375
} ) ;
@@ -381,14 +383,14 @@ function defineFieldMap(
381
383
const fieldMap : any = resolveMaybeThunk ( fields ) ;
382
384
invariant (
383
385
isPlainObj ( fieldMap ) ,
384
- `${type } fields must be an object with field names as keys or a ` +
386
+ `${type . name } fields must be an object with field names as keys or a ` +
385
387
'function which returns such an object . '
386
388
) ;
387
389
388
390
const fieldNames = Object . keys ( fieldMap ) ;
389
391
invariant (
390
392
fieldNames . length > 0 ,
391
- `${type } fields must be an object with field names as keys or a ` +
393
+ `${type . name } fields must be an object with field names as keys or a ` +
392
394
'function which returns such an object . '
393
395
) ;
394
396
@@ -401,29 +403,29 @@ function defineFieldMap(
401
403
} ;
402
404
invariant (
403
405
! field . hasOwnProperty ( 'isDeprecated ') ,
404
- `${type } . ${fieldName } should provide "deprecationReason " instead ` +
406
+ `${type . name } . ${fieldName } should provide "deprecationReason " instead ` +
405
407
'of "isDeprecated ". '
406
408
) ;
407
409
invariant (
408
410
isOutputType ( field . type ) ,
409
- `${type } . ${fieldName } field type must be Output Type but ` +
410
- `got : ${field . type } . `
411
+ `${type . name } . ${fieldName } field type must be Output Type but ` +
412
+ `got : ${String ( field . type ) } . `
411
413
) ;
412
414
if ( ! field . args ) {
413
415
field . args = [ ] ;
414
416
} else {
415
417
invariant (
416
418
isPlainObj ( field . args ) ,
417
- `${type } . ${fieldName } args must be an object with argument names ` +
418
- 'as keys . '
419
+ `${type . name } . ${fieldName } args must be an object with argument ` +
420
+ 'names as keys . '
419
421
) ;
420
422
field . args = Object . keys ( field . args ) . map ( argName => {
421
423
assertValidName ( argName ) ;
422
424
const arg = field . args [ argName ] ;
423
425
invariant (
424
426
isInputType ( arg . type ) ,
425
- `${type } . ${fieldName } ( ${argName } :) argument type must be ` +
426
- `Input Type but got : ${arg . type } . `
427
+ `${type . name } . ${fieldName } ( ${argName } :) argument type must be ` +
428
+ `Input Type but got : ${String ( arg . type ) } . `
427
429
) ;
428
430
return {
429
431
name : argName ,
@@ -564,7 +566,7 @@ export class GraphQLInterfaceType {
564
566
if ( config . resolveType ) {
565
567
invariant (
566
568
typeof config . resolveType === 'function ',
567
- `${this } must provide "resolveType " as a function . `
569
+ `${this . name } must provide "resolveType " as a function . `
568
570
) ;
569
571
}
570
572
this . resolveType = config . resolveType ;
@@ -635,7 +637,7 @@ export class GraphQLUnionType {
635
637
if ( config . resolveType ) {
636
638
invariant (
637
639
typeof config . resolveType === 'function ',
638
- `${this } must provide "resolveType " as a function . `
640
+ `${this . name } must provide "resolveType " as a function . `
639
641
) ;
640
642
}
641
643
this . resolveType = config . resolveType ;
@@ -646,13 +648,14 @@ export class GraphQLUnionType {
646
648
config . types . forEach ( type => {
647
649
invariant (
648
650
type instanceof GraphQLObjectType ,
649
- `${this } may only contain Object types , it cannot contain : ${type } . `
651
+ `${this . name } may only contain Object types , it cannot contain : ` +
652
+ `${String ( type ) } . `
650
653
) ;
651
654
if ( typeof this . resolveType !== 'function ') {
652
655
invariant (
653
656
typeof type . isTypeOf === 'function ',
654
- `Union Type ${this } does not provide a "resolveType " function ` +
655
- `and possible Type ${type } does not provide a "isTypeOf " ` +
657
+ `Union Type ${this . name } does not provide a "resolveType " function ` +
658
+ `and possible Type ${type . name } does not provide a "isTypeOf " ` +
656
659
'function . There is no way to resolve this possible type ' +
657
660
'during execution . '
658
661
) ;
@@ -783,24 +786,24 @@ function defineEnumValues(
783
786
) : Array < GraphQLEnumValueDefinition / * < T > * / > {
784
787
invariant (
785
788
isPlainObj ( valueMap ) ,
786
- `${type } values must be an object with value names as keys . `
789
+ `${type . name } values must be an object with value names as keys . `
787
790
) ;
788
791
const valueNames = Object . keys ( valueMap ) ;
789
792
invariant (
790
793
valueNames . length > 0 ,
791
- `${type } values must be an object with value names as keys . `
794
+ `${type . name } values must be an object with value names as keys . `
792
795
) ;
793
796
return valueNames . map ( valueName => {
794
797
assertValidName ( valueName ) ;
795
798
const value = valueMap [ valueName ] ;
796
799
invariant (
797
800
isPlainObj ( value ) ,
798
- `${type } . ${valueName } must refer to an object with a "value " key ` +
799
- `representing an internal value but got : ${value } . `
801
+ `${type . name } . ${valueName } must refer to an object with a "value " key ` +
802
+ `representing an internal value but got : ${String ( value ) } . `
800
803
) ;
801
804
invariant (
802
805
! value . hasOwnProperty ( 'isDeprecated ') ,
803
- `${type } . ${valueName } should provide "deprecationReason " instead ` +
806
+ `${type . name } . ${valueName } should provide "deprecationReason " instead ` +
804
807
'of "isDeprecated ". '
805
808
) ;
806
809
return {
@@ -880,13 +883,13 @@ export class GraphQLInputObjectType {
880
883
const fieldMap : any = resolveMaybeThunk ( this . _typeConfig . fields ) ;
881
884
invariant (
882
885
isPlainObj ( fieldMap ) ,
883
- `${this } fields must be an object with field names as keys or a ` +
886
+ `${this . name } fields must be an object with field names as keys or a ` +
884
887
'function which returns such an object . '
885
888
) ;
886
889
const fieldNames = Object . keys ( fieldMap ) ;
887
890
invariant (
888
891
fieldNames . length > 0 ,
889
- `${this } fields must be an object with field names as keys or a ` +
892
+ `${this . name } fields must be an object with field names as keys or a ` +
890
893
'function which returns such an object . '
891
894
) ;
892
895
const resultFieldMap = { } ;
@@ -898,8 +901,8 @@ export class GraphQLInputObjectType {
898
901
} ;
899
902
invariant (
900
903
isInputType ( field . type ) ,
901
- `${this } . ${fieldName } field type must be Input Type but ` +
902
- `got : ${field . type } . `
904
+ `${this . name } . ${fieldName } field type must be Input Type but ` +
905
+ `got : ${String ( field . type ) } . `
903
906
) ;
904
907
resultFieldMap [ fieldName ] = field ;
905
908
} ) ;
@@ -966,7 +969,7 @@ export class GraphQLList<T: GraphQLType> {
966
969
constructor ( type : T ) {
967
970
invariant (
968
971
isType ( type ) ,
969
- `Can only create List of a GraphQLType but got : ${type } . `
972
+ `Can only create List of a GraphQLType but got : ${String ( type ) } . `
970
973
) ;
971
974
this . ofType = type ;
972
975
}
@@ -1003,7 +1006,8 @@ export class GraphQLNonNull<T: GraphQLNullableType> {
1003
1006
constructor ( type : T ) {
1004
1007
invariant (
1005
1008
isType ( type ) && ! ( type instanceof GraphQLNonNull ) ,
1006
- `Can only create NonNull of a Nullable GraphQLType but got : ${type } . `
1009
+ 'Can only create NonNull of a Nullable GraphQLType but got : ' +
1010
+ `${String ( type ) } . `
1007
1011
) ;
1008
1012
this . ofType = type ;
1009
1013
}
0 commit comments