You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to wire up the existing model methods and statics with resolve functions?
i.e. if my model User has a method User.statics.findSimilar() is there a way for me to expose this as a GraphQL type?
If this was a new application I would use pre and post hooks but theres TONNES of existing business logic within the mongoose statics that I would rather not replicate by hand!
Any thoughts?
The text was updated successfully, but these errors were encountered:
In a lot of cases existing Mongoose schemas have business logic implemented as schema statics which I think become instance methods by default when a model is instantiated.
I think it makes sense for graffiti-mongoose to automatically add a Animal.search as a resolve function instead of requiring me to re-implement Animal.search manually, to give you some idea the schema I'm working on has 50+ models and most models have 30+ methods / statics with very specific logic and I'm sure I'm not the only one!
Is there a way to wire up the existing model methods and statics with resolve functions?
i.e. if my model
User
has a methodUser.statics.findSimilar()
is there a way for me to expose this as a GraphQL type?If this was a new application I would use pre and post hooks but theres TONNES of existing business logic within the mongoose statics that I would rather not replicate by hand!
Any thoughts?
The text was updated successfully, but these errors were encountered: