beforeQuery populate
I have virtual fields that I can populate on a mongoose model.
I'd like to have a resolver that uses populate instead of another resolved query.
This is due to the fact that relations are inefficient in certain cases --- consider:
query {
userMany {
roles {
permissions {
something
somethingElse
}
}
}
}
If I pull 100 users that all had the same permission, a relation would pull the 100 users in a many (1 query), and then pull the roles (roleMany) 100 times. Populate does 1 query for the user and one query for the role.
Moreover, I'd like then to be able to recursively populate in the GQL query... eg the relation to permissions... like:
User.
findMany({...}).
populate({
path: 'roles',
populate: { path: 'permissions' }
});```
You should use 'dataLoaderMany' resolver https://github.com/graphql-compose/graphql-compose-mongoose/pull/260#issue-480887824