graphql-compose / graphql-compose-mongoose

Mongoose model converter to GraphQL types with resolvers for graphql-compose https://github.com/nodkz/graphql-compose
MIT License
709 stars 94 forks source link

Mongoose 7 issue ( graphql type and doc validate ) #426

Closed meabed closed 1 year ago

meabed commented 1 year ago

https://github.com/Automattic/mongoose/blob/master/CHANGELOG.md

meabed commented 1 year ago

The temp fix for validate method is something like

// temporary patch for mongoose7
const oldValidate = mongoose.Document.prototype.validate;
mongoose.Document.prototype.validate = async function (cb = undefined) {
  if (cb && typeof cb === 'function') {
    return oldValidate.call(this).then(cb);
  }
  return oldValidate.call(this, ...arguments);
};