@@ -12,6 +12,9 @@ import {
1212 print ,
1313 parse ,
1414 validate ,
15+ isObjectType ,
16+ isInterfaceType ,
17+ isScalarType ,
1518} from 'graphql'
1619
1720import { Operation } from './types'
@@ -45,7 +48,7 @@ export function buildInfoForAllScalars(
4548 const namedType = getNamedType ( type )
4649
4750 let selections : FieldNode [ ] | undefined
48- if ( namedType instanceof GraphQLObjectType ) {
51+ if ( isInterfaceType ( namedType ) || isObjectType ( namedType ) ) {
4952 const fields = ( namedType as any ) . getFields ( )
5053 selections = Object . keys ( fields )
5154 . filter ( f => isScalar ( fields [ f ] . type ) )
@@ -161,7 +164,7 @@ export function makeSubInfo(
161164 fragment ?: string ,
162165) : GraphQLResolveInfo | null {
163166 const returnType = getDeepType ( info . returnType )
164- if ( returnType instanceof GraphQLScalarType ) {
167+ if ( isScalarType ( returnType ) ) {
165168 throw new Error ( `Can't make subInfo for type ${ info . returnType . toString ( ) } ` )
166169 }
167170
@@ -178,7 +181,7 @@ export function makeSubInfo(
178181
179182 while ( fieldsToTraverse . length > 0 ) {
180183 currentFieldName = fieldsToTraverse . shift ( ) !
181- if ( ! ( currentType instanceof GraphQLObjectType ) ) {
184+ if ( ! isObjectType ( currentType ) ) {
182185 throw new Error (
183186 `Can't get subInfo for type ${ currentType . toString ( ) } as needs to be a GraphQLObjectType` ,
184187 )
@@ -192,7 +195,7 @@ export function makeSubInfo(
192195 }
193196
194197 const currentFieldType = fields [ currentFieldName ] . type
195- if ( ! ( currentFieldType instanceof GraphQLObjectType ) ) {
198+ if ( ! isObjectType ( currentFieldType ) ) {
196199 throw new Error (
197200 `Can't get subInfo for type ${ currentFieldType } of field ${ currentFieldName } on type ${ currentType . toString ( ) } ` ,
198201 )
0 commit comments