@@ -72,12 +72,13 @@ export type GraphQLInputType =
7272 GraphQLList < GraphQLInputType >
7373 > ;
7474
75- export function isInputType ( type : ?GraphQLType ) : boolean {
76- const namedType = getNamedType ( type ) ;
75+ export function isInputType ( type : ?GraphQLType ) /* : boolean %checks */ {
7776 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 )
8182 ) ;
8283}
8384
@@ -86,7 +87,7 @@ export function assertInputType(type: ?GraphQLType): GraphQLInputType {
8687 isInputType ( type ) ,
8788 `Expected ${ String ( type ) } to be a GraphQL input type.`
8889 ) ;
89- return ( type : any ) ;
90+ return type ;
9091}
9192
9293/**
@@ -108,14 +109,15 @@ export type GraphQLOutputType =
108109 GraphQLList < GraphQLOutputType >
109110 > ;
110111
111- export function isOutputType ( type : ?GraphQLType ) : boolean {
112- const namedType = getNamedType ( type ) ;
112+ export function isOutputType ( type : ?GraphQLType ) /* : boolean %checks */ {
113113 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 )
119121 ) ;
120122}
121123
@@ -124,7 +126,7 @@ export function assertOutputType(type: ?GraphQLType): GraphQLOutputType {
124126 isOutputType ( type ) ,
125127 `Expected ${ String ( type ) } to be a GraphQL output type.` ,
126128 ) ;
127- return ( type : any ) ;
129+ return type ;
128130}
129131
130132/**
@@ -134,7 +136,7 @@ export type GraphQLLeafType =
134136 GraphQLScalarType |
135137 GraphQLEnumType ;
136138
137- export function isLeafType ( type : ?GraphQLType ) : boolean {
139+ export function isLeafType ( type : ?GraphQLType ) /* : boolean %checks */ {
138140 return (
139141 type instanceof GraphQLScalarType ||
140142 type instanceof GraphQLEnumType
@@ -146,7 +148,7 @@ export function assertLeafType(type: ?GraphQLType): GraphQLLeafType {
146148 isLeafType ( type ) ,
147149 `Expected ${ String ( type ) } to be a GraphQL leaf type.` ,
148150 ) ;
149- return ( type : any ) ;
151+ return type ;
150152}
151153
152154/**
@@ -157,7 +159,7 @@ export type GraphQLCompositeType =
157159 GraphQLInterfaceType |
158160 GraphQLUnionType ;
159161
160- export function isCompositeType ( type : ?GraphQLType ) : boolean {
162+ export function isCompositeType ( type : ?GraphQLType ) /* : boolean %checks */ {
161163 return (
162164 type instanceof GraphQLObjectType ||
163165 type instanceof GraphQLInterfaceType ||
@@ -170,7 +172,7 @@ export function assertCompositeType(type: ?GraphQLType): GraphQLCompositeType {
170172 isCompositeType ( type ) ,
171173 `Expected ${ String ( type ) } to be a GraphQL composite type.` ,
172174 ) ;
173- return ( type : any ) ;
175+ return type ;
174176}
175177
176178/**
@@ -180,7 +182,7 @@ export type GraphQLAbstractType =
180182 GraphQLInterfaceType |
181183 GraphQLUnionType ;
182184
183- export function isAbstractType ( type : ?GraphQLType ) : boolean {
185+ export function isAbstractType ( type : ?GraphQLType ) /* : boolean %checks */ {
184186 return (
185187 type instanceof GraphQLInterfaceType ||
186188 type instanceof GraphQLUnionType
@@ -192,7 +194,7 @@ export function assertAbstractType(type: ?GraphQLType): GraphQLAbstractType {
192194 isAbstractType ( type ) ,
193195 `Expected ${ String ( type ) } to be a GraphQL abstract type.` ,
194196 ) ;
195- return ( type : any ) ;
197+ return type ;
196198}
197199
198200/**
@@ -224,7 +226,7 @@ export type GraphQLNamedType =
224226 GraphQLEnumType |
225227 GraphQLInputObjectType ;
226228
227- export function isNamedType ( type : ?GraphQLType ) : boolean {
229+ export function isNamedType ( type : ?GraphQLType ) /* : boolean %checks */ {
228230 return (
229231 type instanceof GraphQLScalarType ||
230232 type instanceof GraphQLObjectType ||
@@ -240,18 +242,24 @@ export function assertNamedType(type: ?GraphQLType): GraphQLNamedType {
240242 isNamedType ( type ) ,
241243 `Expected ${ String ( type ) } to be a GraphQL named type.` ,
242244 ) ;
243- return ( type : any ) ;
245+ return type ;
244246}
245247
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 ;
253262 }
254- return unmodifiedType ;
255263}
256264
257265
@@ -545,7 +553,7 @@ function isPlainObj(obj) {
545553}
546554
547555// If a resolver is defined, it must be a function.
548- function isValidResolver ( resolver : any ) : boolean {
556+ function isValidResolver ( resolver : mixed ) : boolean {
549557 return ( resolver == null || typeof resolver === 'function' ) ;
550558}
551559
0 commit comments