@@ -2,7 +2,7 @@ import type { SchemaComposer, Resolver } from 'graphql-compose';
22import { schemaComposer as globalSchemaComposer , ObjectTypeComposer } from 'graphql-compose' ;
33import type { Model , Document } from 'mongoose' ;
44import { convertModelToGraphQL } from './fieldsConverter' ;
5- import { allResolvers } from './resolvers' ;
5+ import { resolverFactory } from './resolvers' ;
66import MongoID from './types/MongoID' ;
77import {
88 prepareFields ,
@@ -29,15 +29,15 @@ export type GenerateResolverType<TDoc extends Document, TContext = any> = {
2929 // Get all available resolver generators, then leave only 3rd arg – opts
3030 // because first two args will be attached via bind() method at runtime:
3131 // count = count.bind(undefined, model, tc);
32- [ resolver in keyof typeof allResolvers ] : < TSource = any > (
33- opts ?: Parameters < typeof allResolvers [ resolver ] > [ 2 ]
32+ [ resolver in keyof typeof resolverFactory ] : < TSource = any > (
33+ opts ?: Parameters < typeof resolverFactory [ resolver ] > [ 2 ]
3434 ) => // Also we should patch generics of the returned Resolver
3535 // attach TContext TDoc from the code which will bind at runtime
3636 // and allow user to attach TSource via generic at call
3737 // For this case we are using `extends infer` construction
3838 // it helps to extract any Generic from existed method
3939 // and then construct new combined return type
40- typeof allResolvers [ resolver ] extends ( ...args : any ) => Resolver < any , any , infer TArgs , any >
40+ typeof resolverFactory [ resolver ] extends ( ...args : any ) => Resolver < any , any , infer TArgs , any >
4141 ? Resolver < TSource , TContext , TArgs , TDoc >
4242 : any ;
4343} ;
@@ -87,8 +87,8 @@ export function composeMongoose<TDoc extends Document, TContext = any>(
8787 tc . makeFieldNonNull ( '_id' ) ;
8888
8989 const mongooseResolvers = { } as any ;
90- Object . keys ( allResolvers ) . forEach ( ( name ) => {
91- mongooseResolvers [ name ] = ( allResolvers as any ) [ name ] . bind ( undefined , model , tc ) ;
90+ Object . keys ( resolverFactory ) . forEach ( ( name ) => {
91+ mongooseResolvers [ name ] = ( resolverFactory as any ) [ name ] . bind ( undefined , model , tc ) ;
9292 } ) ;
9393 ( tc as any ) . mongooseResolvers = mongooseResolvers ;
9494
0 commit comments