apollo-datasource-mongodb icon indicating copy to clipboard operation
apollo-datasource-mongodb copied to clipboard

Requiring Model required to Extend Document - Goes against Mongoose Recommenction

Open gidich opened this issue 3 years ago • 3 comments

According to current Mongoose's documentation, interfaces should not extend document:

https://mongoosejs.com/docs/typescript.html#using-extends-document

However type guards in the library require this.

https://github.com/GraphQLGuide/apollo-datasource-mongodb/blob/4e1124d1ebb9665ae1dfeb80a92cf8eb9a5db3b7/index.d.ts#L14

Would you consider relaxing the type guards so that interfaces don't need to extend document?

gidich avatar Sep 09 '21 21:09 gidich

Sure, what are the options for relaxing?

lorensr avatar Sep 13 '21 03:09 lorensr

I believe you can just remove the type constraint noting that T must extend Document.

export type Model<T, U = MongooseModel<T>>

I'll try tweaking things on my end and see if this works..

gidich avatar Sep 30 '21 18:09 gidich

Thanks! Lmk how it goes

lorensr avatar Oct 02 '21 04:10 lorensr