@@ -2,7 +2,7 @@ import type { SchemaComposer, Resolver } from 'graphql-compose';
2
2
import { schemaComposer as globalSchemaComposer , ObjectTypeComposer } from 'graphql-compose' ;
3
3
import type { Model , Document } from 'mongoose' ;
4
4
import { convertModelToGraphQL } from './fieldsConverter' ;
5
- import { allResolvers } from './resolvers' ;
5
+ import { resolverFactory } from './resolvers' ;
6
6
import MongoID from './types/MongoID' ;
7
7
import {
8
8
prepareFields ,
@@ -29,15 +29,15 @@ export type GenerateResolverType<TDoc extends Document, TContext = any> = {
29
29
// Get all available resolver generators, then leave only 3rd arg – opts
30
30
// because first two args will be attached via bind() method at runtime:
31
31
// 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 ]
34
34
) => // Also we should patch generics of the returned Resolver
35
35
// attach TContext TDoc from the code which will bind at runtime
36
36
// and allow user to attach TSource via generic at call
37
37
// For this case we are using `extends infer` construction
38
38
// it helps to extract any Generic from existed method
39
39
// 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 >
41
41
? Resolver < TSource , TContext , TArgs , TDoc >
42
42
: any ;
43
43
} ;
@@ -87,8 +87,8 @@ export function composeMongoose<TDoc extends Document, TContext = any>(
87
87
tc . makeFieldNonNull ( '_id' ) ;
88
88
89
89
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 ) ;
92
92
} ) ;
93
93
( tc as any ) . mongooseResolvers = mongooseResolvers ;
94
94
0 commit comments