import { IFieldResolver } from 'graphql-tools' ; export interface FieldResolver extends IFieldResolver < any , any > { } export interface ResolverObject { [ key ] : FieldResolver ; } export interface ResolverMappings { [ key ] : ResolverObject ; } export type ResolverWrapper = ( resolver : FieldResolver ) => FieldResolver ; export function wrapResolvers ( resolverMappings , resolverWrapper ) { const output = { } ; const typeKeys = Object . keys ( resolverMappings ) ; for ( const typeKey of typeKeys ) { output [ typeKey ] = { } ; const fieldResolversForType = resolverMappings [ typeKey ] ; const fieldKeysForType = Object . keys ( fieldResolversForType ) ; for ( const fieldKey of fieldKeysForType ) { const resolverForField = fieldResolversForType [ fieldKey ] ; if ( typeKey !== 'Subscription' ) { output [ typeKey ] [ fieldKey ] = resolverWrapper ( resolverForField ) ; } else { output [ typeKey ] [ fieldKey ] = resolverForField ; } } } return output ; }