@@ -4,11 +4,12 @@ import {
44 isCompositeType ,
55 isAbstractType ,
66 GraphQLEnumType ,
7- GraphQLList ,
87 GraphQLNonNull ,
98 GraphQLInputObjectType ,
109 GraphQLObjectType ,
11- GraphQLUnionType
10+ GraphQLUnionType ,
11+ isListType ,
12+ isNonNullType
1213} from "graphql" ;
1314
1415import { wrap } from "apollo-codegen-core/lib/utilities/printing" ;
@@ -187,10 +188,10 @@ export function interfaceVariablesDeclarationForOperation(
187188}
188189
189190function getObjectTypeName ( type : GraphQLType ) : string {
190- if ( type instanceof GraphQLList ) {
191+ if ( isListType ( type ) ) {
191192 return getObjectTypeName ( type . ofType ) ;
192193 }
193- if ( type instanceof GraphQLNonNull ) {
194+ if ( isNonNullType ( type ) ) {
194195 return getObjectTypeName ( type . ofType ) ;
195196 }
196197 if ( type instanceof GraphQLObjectType ) {
@@ -355,17 +356,12 @@ export function propertyFromField(
355356 const typeName = typeNameFromGraphQLType ( context , fieldType ) ;
356357 let isArray = false ;
357358 let isArrayElementNullable = null ;
358- if ( fieldType instanceof GraphQLList ) {
359+ if ( isListType ( fieldType ) ) {
359360 isArray = true ;
360- isArrayElementNullable = ! ( fieldType . ofType instanceof GraphQLNonNull ) ;
361- } else if (
362- fieldType instanceof GraphQLNonNull &&
363- fieldType . ofType instanceof GraphQLList
364- ) {
361+ isArrayElementNullable = ! isNonNullType ( fieldType . ofType ) ;
362+ } else if ( isNonNullType ( fieldType ) && isListType ( fieldType . ofType ) ) {
365363 isArray = true ;
366- isArrayElementNullable = ! (
367- fieldType . ofType . ofType instanceof GraphQLNonNull
368- ) ;
364+ isArrayElementNullable = ! isNonNullType ( fieldType . ofType . ofType ) ;
369365 }
370366 return {
371367 ...property ,
0 commit comments