Open diesieben07 opened 4 months ago
Some guidance on the test failures would be great. I am not 100% sure what the correct approach would be for the changed GraphQL schema.
Attention: Patch coverage is 83.01887%
with 9 lines
in your changes are missing coverage. Please review.
Project coverage is 88.21%. Comparing base (
5c999e9
) to head (746ec95
). Report is 20 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
strawberry_django/optimizer.py | 83.01% | 9 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@bellini666 I think all the linting and type errors should be resolved now and the snapshot test fixed.
Description
Currently the QuerySet optimizer is oblivious to custom
prefetch_related
like the following:The current optimizer cannot understand how to optimize "through" this prefetch, because it cannot find the model field (
milestones
inProject
) that the field uses. This results in the optimization essentially stopping at thenext_milestones
field and any further nested relations will cause N+1 issues.This pull request attempts to address this shortcoming.
Types of Changes
Now the optimizer first inspects the field configuration to find any custom
Prefetch
. A custom prefetch is one which has a customto_attr
set. The optimizer then uses these custom Prefetches to perform further optimization instead of stopping here.Issues Fixed or Closed by This PR
Checklist