strawberry-django
strawberry-django copied to clipboard
feat: Avoid joins when only fetching an ID
Description
Consider the following query
query Query {
books {
id
author {
id
}
}
}
A join will be generated even though we really don't have to, as the required information already exists through book.author_id
.
The idea here is to try and optimize away this join, by constructing the Author
object in-memory using the value from book.author_id
.
I'm not very familiar with the code base, so I'm not sure if this is has other drawbacks.
Types of Changes
- [ ] Core
- [ ] Bugfix
- [ ] New feature
- [x] Enhancement/optimization
- [ ] Documentation
Checklist
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the CONTRIBUTING document.
- [ ] I have added tests to cover my changes.
- [ ] I have tested the changes and verified that they work and don't break anything (as well as I can manage).
@mselee want to check if you are waiting for help to update the PR?