graphql-compose / graphql-compose/graphql-compose-mongoose

beforeQuery populate

Open
#298 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
706
Forks
98
PR merge metrics
No merged PRs in 30d

Description

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' }
});```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.