Closed bellini666 closed 4 months ago
This pull request addresses issue #572 by refactoring the optimizer to convert select_related into Prefetch when the type defines a custom get_queryset. Key changes include the introduction of a helper function to resolve Django types, updates to the optimizer logic, and the addition of new tests to verify the behavior.
Files | Changes |
---|---|
strawberry_django/optimizer.py strawberry_django/fields/field.py |
Refactored optimizer to use Prefetch when a custom get_queryset is defined and added optimization flag to default_resolver. |
tests/test_optimizer.py tests/projects/schema.py |
Added tests to verify the new Prefetch behavior and updated schema definitions accordingly. |
Attention: Patch coverage is 88.88889%
with 2 lines
in your changes missing coverage. Please review.
Project coverage is 88.90%. Comparing base (
3aa993a
) to head (538dbe5
).
Files | Patch % | Lines |
---|---|---|
strawberry_django/optimizer.py | 88.23% | 2 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Fix #572 Initial resolution for #549
Summary by Sourcery
This pull request addresses a bug where select_related was not respecting custom get_queryset methods by converting them into Prefetch. It also introduces a helper function to streamline type retrieval and updates the optimizer to avoid optimizing fields with a base resolver unless auto-generated. Additionally, a new test was added to verify the fallback behavior.