import { GraphQLObjectType , GraphQLInterfaceType } from 'graphql' ; import { IMiddlewareResolver , IMiddlewareWithOptions , IMiddlewareFunction , IMiddlewareGenerator , } from './types' ; import { MiddlewareGenerator } from './generator' ; export function isMiddlewareResolver < TSource , TContext , TArgs > ( obj ) { return ( typeof obj === 'function' || ( typeof obj === 'object' && obj . then !== undefined ) ) ; } export function isMiddlewareWithFragment < TSource , TContext , TArgs > ( obj ) { return ( ( typeof obj . fragment === 'string' || typeof obj . fragments === 'object' ) && isMiddlewareResolver ( obj . resolve ) ) ; } export function isMiddlewareFunction < TSource , TContext , TArgs > ( obj ) { return isMiddlewareWithFragment ( obj ) || isMiddlewareResolver ( obj ) ; } export function isMiddlewareGenerator < TSource , TContext , TArgs > ( x ) { return x instanceof MiddlewareGenerator ; } export function isGraphQLObjectType ( obj ) { return obj instanceof GraphQLObjectType || obj instanceof GraphQLInterfaceType ; }