Closed
Description
Hello, I'm trying to use this package together with mongoose
and getting MongoDataSource constructor must be given a collection or Mongoose model
.
This is the way I'm creating datasource instance:
new ApolloServer({
// ...
dataSources: (): => ({
users: new Users(User),
}),
});
This is how I create models:
const schema = mongoose.Schema(...);
class User extends mongoose.Model {}
export default mongoose.model(User, schema);
The error is because of x.name === 'model'
from here:
If Mongoose model is compiled from class, it will inherit its constructor name. The name will be equal to model
only in case, when you pass a string as first arg to mongoose.model()
because in that case the constructor will be function model() {}
:
Metadata
Metadata
Assignees
Labels
No labels