@@ -72,12 +72,13 @@ export type GraphQLInputType =
72
72
GraphQLList < GraphQLInputType >
73
73
> ;
74
74
75
- export function isInputType ( type : ?GraphQLType ) : boolean {
76
- const namedType = getNamedType ( type ) ;
75
+ export function isInputType ( type : ?GraphQLType ) : boolean % checks {
77
76
return (
78
- namedType instanceof GraphQLScalarType ||
79
- namedType instanceof GraphQLEnumType ||
80
- namedType instanceof GraphQLInputObjectType
77
+ type instanceof GraphQLScalarType ||
78
+ type instanceof GraphQLEnumType ||
79
+ type instanceof GraphQLInputObjectType ||
80
+ type instanceof GraphQLNonNull && isInputType ( type . ofType ) ||
81
+ type instanceof GraphQLList && isInputType ( type . ofType )
81
82
) ;
82
83
}
83
84
@@ -86,7 +87,7 @@ export function assertInputType(type: ?GraphQLType): GraphQLInputType {
86
87
isInputType ( type ) ,
87
88
`Expected ${ String ( type ) } to be a GraphQL input type.`
88
89
) ;
89
- return ( type : any ) ;
90
+ return type ;
90
91
}
91
92
92
93
/**
@@ -108,14 +109,15 @@ export type GraphQLOutputType =
108
109
GraphQLList < GraphQLOutputType >
109
110
> ;
110
111
111
- export function isOutputType ( type : ?GraphQLType ) : boolean {
112
- const namedType = getNamedType ( type ) ;
112
+ export function isOutputType ( type : ?GraphQLType ) : boolean % checks {
113
113
return (
114
- namedType instanceof GraphQLScalarType ||
115
- namedType instanceof GraphQLObjectType ||
116
- namedType instanceof GraphQLInterfaceType ||
117
- namedType instanceof GraphQLUnionType ||
118
- namedType instanceof GraphQLEnumType
114
+ type instanceof GraphQLScalarType ||
115
+ type instanceof GraphQLObjectType ||
116
+ type instanceof GraphQLInterfaceType ||
117
+ type instanceof GraphQLUnionType ||
118
+ type instanceof GraphQLEnumType ||
119
+ type instanceof GraphQLNonNull && isOutputType ( type . ofType ) ||
120
+ type instanceof GraphQLList && isOutputType ( type . ofType )
119
121
) ;
120
122
}
121
123
@@ -124,7 +126,7 @@ export function assertOutputType(type: ?GraphQLType): GraphQLOutputType {
124
126
isOutputType ( type ) ,
125
127
`Expected ${ String ( type ) } to be a GraphQL output type.` ,
126
128
) ;
127
- return ( type : any ) ;
129
+ return type ;
128
130
}
129
131
130
132
/**
@@ -134,7 +136,7 @@ export type GraphQLLeafType =
134
136
GraphQLScalarType |
135
137
GraphQLEnumType ;
136
138
137
- export function isLeafType ( type : ?GraphQLType ) : boolean {
139
+ export function isLeafType ( type : ?GraphQLType ) : boolean % checks {
138
140
return (
139
141
type instanceof GraphQLScalarType ||
140
142
type instanceof GraphQLEnumType
@@ -146,7 +148,7 @@ export function assertLeafType(type: ?GraphQLType): GraphQLLeafType {
146
148
isLeafType ( type ) ,
147
149
`Expected ${ String ( type ) } to be a GraphQL leaf type.` ,
148
150
) ;
149
- return ( type : any ) ;
151
+ return type ;
150
152
}
151
153
152
154
/**
@@ -157,7 +159,7 @@ export type GraphQLCompositeType =
157
159
GraphQLInterfaceType |
158
160
GraphQLUnionType ;
159
161
160
- export function isCompositeType ( type : ?GraphQLType ) : boolean {
162
+ export function isCompositeType ( type : ?GraphQLType ) : boolean % checks {
161
163
return (
162
164
type instanceof GraphQLObjectType ||
163
165
type instanceof GraphQLInterfaceType ||
@@ -170,7 +172,7 @@ export function assertCompositeType(type: ?GraphQLType): GraphQLCompositeType {
170
172
isCompositeType ( type ) ,
171
173
`Expected ${ String ( type ) } to be a GraphQL composite type.` ,
172
174
) ;
173
- return ( type : any ) ;
175
+ return type ;
174
176
}
175
177
176
178
/**
@@ -180,7 +182,7 @@ export type GraphQLAbstractType =
180
182
GraphQLInterfaceType |
181
183
GraphQLUnionType ;
182
184
183
- export function isAbstractType ( type : ?GraphQLType ) : boolean {
185
+ export function isAbstractType ( type : ?GraphQLType ) : boolean % checks {
184
186
return (
185
187
type instanceof GraphQLInterfaceType ||
186
188
type instanceof GraphQLUnionType
@@ -192,7 +194,7 @@ export function assertAbstractType(type: ?GraphQLType): GraphQLAbstractType {
192
194
isAbstractType ( type ) ,
193
195
`Expected ${ String ( type ) } to be a GraphQL abstract type.` ,
194
196
) ;
195
- return ( type : any ) ;
197
+ return type ;
196
198
}
197
199
198
200
/**
@@ -224,7 +226,7 @@ export type GraphQLNamedType =
224
226
GraphQLEnumType |
225
227
GraphQLInputObjectType ;
226
228
227
- export function isNamedType ( type : ?GraphQLType ) : boolean {
229
+ export function isNamedType ( type : ?GraphQLType ) : boolean % checks {
228
230
return (
229
231
type instanceof GraphQLScalarType ||
230
232
type instanceof GraphQLObjectType ||
@@ -240,18 +242,24 @@ export function assertNamedType(type: ?GraphQLType): GraphQLNamedType {
240
242
isNamedType ( type ) ,
241
243
`Expected ${ String ( type ) } to be a GraphQL named type.` ,
242
244
) ;
243
- return ( type : any ) ;
245
+ return type ;
244
246
}
245
247
246
- export function getNamedType ( type : ?GraphQLType ) : ?GraphQLNamedType {
247
- let unmodifiedType = type ;
248
- while (
249
- unmodifiedType instanceof GraphQLList ||
250
- unmodifiedType instanceof GraphQLNonNull
251
- ) {
252
- unmodifiedType = unmodifiedType . ofType ;
248
+ /* eslint-disable no-redeclare */
249
+ declare function getNamedType ( type : void | null ) : void ;
250
+ declare function getNamedType ( type : GraphQLType ) : GraphQLNamedType ;
251
+ export function getNamedType ( type ) {
252
+ /* eslint-enable no-redeclare */
253
+ if ( type ) {
254
+ let unmodifiedType = type ;
255
+ while (
256
+ unmodifiedType instanceof GraphQLList ||
257
+ unmodifiedType instanceof GraphQLNonNull
258
+ ) {
259
+ unmodifiedType = unmodifiedType . ofType ;
260
+ }
261
+ return unmodifiedType ;
253
262
}
254
- return unmodifiedType ;
255
263
}
256
264
257
265
@@ -556,7 +564,7 @@ function isPlainObj(obj) {
556
564
}
557
565
558
566
// If a resolver is defined, it must be a function.
559
- function isValidResolver ( resolver : any ) : boolean {
567
+ function isValidResolver ( resolver : mixed ) : boolean {
560
568
return ( resolver == null || typeof resolver === 'function' ) ;
561
569
}
562
570
0 commit comments