-
-
Notifications
You must be signed in to change notification settings - Fork 96
add beforeQueryHelper #189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I'll try to review it after several hours. I had a fast look and your improvement quite interesting 👍 |
Yep, graphql-compose-mongoose needs in this changes 👍🔥 My thoughts1) I think that we need to pass mongoose model to- const res = await beforeQueryHelper(resolveParams).exec();
+ const res = await beforeQueryHelper(resolveParams, model).exec();
It helps to recreate query from scratch, make additional queries, check what models are using for cases when one 2) We need to hide
|
|
Nice! Thanks for the quick response. I'll take a look at this right now |
|
Hi @nodkz! Do you see any disadvantages in put the model in |
|
@antoniopresto Yep, put the |
|
implemented more tests :) I think its complete |
| it('should call `beforeQuery` method with non-executed `query` as arg', async () => { | ||
| const mongooseActions = []; | ||
|
|
||
| UserModel.base.set('debug', function debugMongoose(...args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice👍 didn't know such spying way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discovered this week haha
src/resolvers/findById.js
Outdated
| resolveParams.model = model; // eslint-disable-line | ||
| projectionHelper(resolveParams); | ||
| return resolveParams.query.exec(); | ||
| return beforeQueryHelper(resolveParams, model); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to remove second arg (model)?
All resolvers affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch :)
|
Great work! 👍 PS. Any example in readme will be very appreciated but not obligatory. |
validate beforeQueryHelper returning query beforeQueryHelper: hide exec + pass mongoose model improve tests
|
Thanks! Your work is inspiring. I can try to help with the readme, but my english doesn't help much hehe |
|
Very cool PR! Thanks! 🙏 |
|
🎉 This PR is included in version 7.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I'll update tests, for now, is this acceptable?
I need beforeQuery to handle custom user/regions/etc rules.