Closed litewarp closed 2 years ago
The problem was in graphql-compose
package in this line https://github.com/graphql-compose/graphql-compose/blob/master/src/ObjectTypeComposer.ts#L109 (JUST FIXED):
export type ObjectTypeComposerFieldConfigDefinition<TSource, TContext, TArgs = any> =
| ThunkWithSchemaComposer<
ObjectTypeComposerFieldConfigAsObjectDefinition<TSource, TContext, TArgs>,
SchemaComposer<TContext>
>
| ThunkWithSchemaComposer<ComposeOutputTypeDefinition<TContext>, SchemaComposer<TContext>>
| Readonly<Resolver<TSource, TContext, any>>; // 🤕🤕🤕 ambiguous definition for TypeScript
Try to install the latest version of graphql-compose and check how it works.
If it does not populate TSource
automatically then you may pass it explicitly:
+ import { DocumentType } from '@typegoose/typegoose';
- export const UserTC = composeMongoose(UserModel, {})
+ export const UserTC = composeMongoose<DocumentType<User>>(UserModel, {})
UserTC.addFields({ ... });
Confirmed that it works after upgrading to graphql-compose@9.0.2
. Closing.
Took the suggestion in the examples to use Typegoose, but can't seem to get the resolve function below to correctly type the source object. Is there something I need to do to get the "source" object to be typed correctly instead of any?