import { Resolvers , ResolverDef } from '../types/resolver' ; import { Manager } from '../manager' ; import { ResolveFn } from '../types/common' ; import { buildContext } from '../helpers' ; export function createResolvers ( manager ) { const schema = { } ; manager . resolvers . forEach ( def => { const [ typeName , fieldName ] = def . path . split ( '.' ) ; if ( ! schema [ typeName ] ) { schema [ typeName ] = { } ; } schema [ typeName ] [ fieldName ] = createResolver ( def , manager ) ; } ) ; return schema ; } function createResolver ( def , manager ) { return ( parent , args , context ) => def . resolve ( parent , args , buildContext ( context , manager . getClient ( ) ) ) ; }