Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch mongodb datasource to correctly type the mongoose model
Ok, so I really didn't want to do this. It was a last resort... apollo-datasource-mongodb supports mongoose fine, in javascript. But the typing expects the model object type to extend Document from mongoose, so that it determine it to be a mongoose model, rather than a mongodb collection. But - not only is this recommended against, but it is not easily supported without a tonne more hacks whilst using codegen to generate the types based off of GraphQL types... As overriding types was not possible (in src/@types/environment.d.ts), only extending, this commit creates a package patch which removes the type inferrence and forces the datasource constructor parameter to be a Mongoose Model. This doesn't fix the root problem, that will have to be done on the type inferrence - ModelOrCollection. But I can safetly assume that we'll never use mongodb collections here - just mongoose models. 🫠V see: https://mongoosejs.com/docs/typescript.html#using-extends-document see: GraphQLGuide/apollo-datasource-mongodb#88
- Loading branch information