File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,7 @@ export {
97
97
isLeafType ,
98
98
isCompositeType ,
99
99
isAbstractType ,
100
+ isNamedType ,
100
101
101
102
// Assertions
102
103
assertType ,
@@ -105,6 +106,7 @@ export {
105
106
assertLeafType ,
106
107
assertCompositeType ,
107
108
assertAbstractType ,
109
+ assertNamedType ,
108
110
109
111
// Un-modifiers
110
112
getNullableType ,
Original file line number Diff line number Diff line change @@ -225,6 +225,25 @@ export type GraphQLNamedType =
225
225
GraphQLEnumType |
226
226
GraphQLInputObjectType ;
227
227
228
+ export function isNamedType ( type : ?GraphQLType ) : boolean {
229
+ return (
230
+ type instanceof GraphQLScalarType ||
231
+ type instanceof GraphQLObjectType ||
232
+ type instanceof GraphQLInterfaceType ||
233
+ type instanceof GraphQLUnionType ||
234
+ type instanceof GraphQLEnumType ||
235
+ type instanceof GraphQLInputObjectType
236
+ ) ;
237
+ }
238
+
239
+ export function assertNamedType ( type : ?GraphQLType ) : GraphQLNamedType {
240
+ invariant (
241
+ isNamedType ( type ) ,
242
+ `Expected ${ String ( type ) } to be a GraphQL named type.` ,
243
+ ) ;
244
+ return ( type : any ) ;
245
+ }
246
+
228
247
export function getNamedType ( type : ?GraphQLType ) : ?GraphQLNamedType {
229
248
let unmodifiedType = type ;
230
249
while (
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export {
19
19
isLeafType ,
20
20
isCompositeType ,
21
21
isAbstractType ,
22
+ isNamedType ,
22
23
23
24
// Assertions
24
25
assertType ,
@@ -27,6 +28,7 @@ export {
27
28
assertLeafType ,
28
29
assertCompositeType ,
29
30
assertAbstractType ,
31
+ assertNamedType ,
30
32
31
33
// Un-modifiers
32
34
getNullableType ,
You can’t perform that action at this time.
0 commit comments