8
8
*/
9
9
10
10
import instanceOf from '../jsutils/instanceOf' ;
11
+ import inspect from '../jsutils/inspect' ;
11
12
import invariant from '../jsutils/invariant' ;
12
13
import isInvalid from '../jsutils/isInvalid' ;
13
14
import keyMap from '../jsutils/keyMap' ;
@@ -63,7 +64,7 @@ export function isType(type: mixed): boolean %checks {
63
64
}
64
65
65
66
export function assertType ( type : mixed ) : GraphQLType {
66
- invariant ( isType ( type ) , `Expected ${ String ( type ) } to be a GraphQL type.` ) ;
67
+ invariant ( isType ( type ) , `Expected ${ inspect ( type ) } to be a GraphQL type.` ) ;
67
68
return ( type : any ) ;
68
69
}
69
70
@@ -81,7 +82,7 @@ export function isScalarType(type) {
81
82
export function assertScalarType ( type : mixed ) : GraphQLScalarType {
82
83
invariant (
83
84
isScalarType ( type ) ,
84
- `Expected ${ String ( type ) } to be a GraphQL Scalar type.` ,
85
+ `Expected ${ inspect ( type ) } to be a GraphQL Scalar type.` ,
85
86
) ;
86
87
return type ;
87
88
}
@@ -96,7 +97,7 @@ export function isObjectType(type) {
96
97
export function assertObjectType ( type : mixed ) : GraphQLObjectType {
97
98
invariant (
98
99
isObjectType ( type ) ,
99
- `Expected ${ String ( type ) } to be a GraphQL Object type.` ,
100
+ `Expected ${ inspect ( type ) } to be a GraphQL Object type.` ,
100
101
) ;
101
102
return type ;
102
103
}
@@ -111,7 +112,7 @@ export function isInterfaceType(type) {
111
112
export function assertInterfaceType ( type : mixed ) : GraphQLInterfaceType {
112
113
invariant (
113
114
isInterfaceType ( type ) ,
114
- `Expected ${ String ( type ) } to be a GraphQL Interface type.` ,
115
+ `Expected ${ inspect ( type ) } to be a GraphQL Interface type.` ,
115
116
) ;
116
117
return type ;
117
118
}
@@ -126,7 +127,7 @@ export function isUnionType(type) {
126
127
export function assertUnionType ( type : mixed ) : GraphQLUnionType {
127
128
invariant (
128
129
isUnionType ( type ) ,
129
- `Expected ${ String ( type ) } to be a GraphQL Union type.` ,
130
+ `Expected ${ inspect ( type ) } to be a GraphQL Union type.` ,
130
131
) ;
131
132
return type ;
132
133
}
@@ -141,7 +142,7 @@ export function isEnumType(type) {
141
142
export function assertEnumType ( type : mixed ) : GraphQLEnumType {
142
143
invariant (
143
144
isEnumType ( type ) ,
144
- `Expected ${ String ( type ) } to be a GraphQL Enum type.` ,
145
+ `Expected ${ inspect ( type ) } to be a GraphQL Enum type.` ,
145
146
) ;
146
147
return type ;
147
148
}
@@ -156,7 +157,7 @@ export function isInputObjectType(type) {
156
157
export function assertInputObjectType ( type : mixed ) : GraphQLInputObjectType {
157
158
invariant (
158
159
isInputObjectType ( type ) ,
159
- `Expected ${ String ( type ) } to be a GraphQL Input Object type.` ,
160
+ `Expected ${ inspect ( type ) } to be a GraphQL Input Object type.` ,
160
161
) ;
161
162
return type ;
162
163
}
@@ -171,7 +172,7 @@ export function isListType(type) {
171
172
export function assertListType ( type : mixed ) : GraphQLList < any > {
172
173
invariant (
173
174
isListType ( type ) ,
174
- `Expected ${ String ( type ) } to be a GraphQL List type.` ,
175
+ `Expected ${ inspect ( type ) } to be a GraphQL List type.` ,
175
176
) ;
176
177
return type ;
177
178
}
@@ -186,7 +187,7 @@ export function isNonNullType(type) {
186
187
export function assertNonNullType(type: mixed): GraphQLNonNull< any > {
187
188
invariant (
188
189
isNonNullType ( type ) ,
189
- `Expected ${ String ( type ) } to be a GraphQL Non-Null type.` ,
190
+ `Expected ${ inspect ( type ) } to be a GraphQL Non-Null type.` ,
190
191
) ;
191
192
return type ;
192
193
}
@@ -218,7 +219,7 @@ export function isInputType(type: mixed): boolean %checks {
218
219
export function assertInputType(type: mixed): GraphQLInputType {
219
220
invariant (
220
221
isInputType ( type ) ,
221
- `Expected ${ String ( type ) } to be a GraphQL input type.` ,
222
+ `Expected ${ inspect ( type ) } to be a GraphQL input type.` ,
222
223
) ;
223
224
return type ;
224
225
}
@@ -256,7 +257,7 @@ export function isOutputType(type: mixed): boolean %checks {
256
257
export function assertOutputType(type: mixed): GraphQLOutputType {
257
258
invariant (
258
259
isOutputType ( type ) ,
259
- `Expected ${ String ( type ) } to be a GraphQL output type.` ,
260
+ `Expected ${ inspect ( type ) } to be a GraphQL output type.` ,
260
261
) ;
261
262
return type ;
262
263
}
@@ -273,7 +274,7 @@ export function isLeafType(type: mixed): boolean %checks {
273
274
export function assertLeafType(type: mixed): GraphQLLeafType {
274
275
invariant (
275
276
isLeafType ( type ) ,
276
- `Expected ${ String ( type ) } to be a GraphQL leaf type.` ,
277
+ `Expected ${ inspect ( type ) } to be a GraphQL leaf type.` ,
277
278
) ;
278
279
return type ;
279
280
}
@@ -293,7 +294,7 @@ export function isCompositeType(type: mixed): boolean %checks {
293
294
export function assertCompositeType(type: mixed): GraphQLCompositeType {
294
295
invariant (
295
296
isCompositeType ( type ) ,
296
- `Expected ${ String ( type ) } to be a GraphQL composite type.` ,
297
+ `Expected ${ inspect ( type ) } to be a GraphQL composite type.` ,
297
298
) ;
298
299
return type ;
299
300
}
@@ -310,7 +311,7 @@ export function isAbstractType(type: mixed): boolean %checks {
310
311
export function assertAbstractType(type: mixed): GraphQLAbstractType {
311
312
invariant (
312
313
isAbstractType ( type ) ,
313
- `Expected ${ String ( type ) } to be a GraphQL abstract type.` ,
314
+ `Expected ${ inspect ( type ) } to be a GraphQL abstract type.` ,
314
315
) ;
315
316
return type ;
316
317
}
@@ -408,7 +409,7 @@ export function isWrappingType(type: mixed): boolean %checks {
408
409
export function assertWrappingType ( type : mixed ) : GraphQLWrappingType {
409
410
invariant (
410
411
isWrappingType ( type ) ,
411
- `Expected ${ String ( type ) } to be a GraphQL wrapping type.` ,
412
+ `Expected ${ inspect ( type ) } to be a GraphQL wrapping type.` ,
412
413
) ;
413
414
return type ;
414
415
}
@@ -432,7 +433,7 @@ export function isNullableType(type: mixed): boolean %checks {
432
433
export function assertNullableType ( type : mixed ) : GraphQLNullableType {
433
434
invariant (
434
435
isNullableType ( type ) ,
435
- `Expected ${ String ( type ) } to be a GraphQL nullable type.` ,
436
+ `Expected ${ inspect ( type ) } to be a GraphQL nullable type.` ,
436
437
) ;
437
438
return type ;
438
439
}
@@ -473,7 +474,7 @@ export function isNamedType(type: mixed): boolean %checks {
473
474
export function assertNamedType ( type : mixed ) : GraphQLNamedType {
474
475
invariant (
475
476
isNamedType ( type ) ,
476
- `Expected ${ String ( type ) } to be a GraphQL named type.` ,
477
+ `Expected ${ inspect ( type ) } to be a GraphQL named type.` ,
477
478
) ;
478
479
return type ;
479
480
}
@@ -736,7 +737,7 @@ function defineFieldMap<TSource, TContext>(
736
737
invariant (
737
738
isValidResolver ( field . resolve ) ,
738
739
`${ type . name } .${ fieldName } field resolver must be a function if ` +
739
- `provided, but got: ${ String ( field . resolve ) } .` ,
740
+ `provided, but got: ${ inspect ( field . resolve ) } .` ,
740
741
) ;
741
742
const argsConfig = fieldConfig . args ;
742
743
if ( ! argsConfig ) {
@@ -1148,7 +1149,7 @@ function defineEnumValues(
1148
1149
invariant (
1149
1150
isPlainObj ( value ) ,
1150
1151
`${ type . name } .${ valueName } must refer to an object with a "value" key ` +
1151
- `representing an internal value but got: ${ String ( value ) } .` ,
1152
+ `representing an internal value but got: ${ inspect ( value ) } .` ,
1152
1153
) ;
1153
1154
invariant (
1154
1155
! value . hasOwnProperty ( 'isDeprecated' ) ,
0 commit comments