strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
MIT License
391 stars 115 forks source link

fix: Make sure the optimizer calls the type's `get_queryset` for nested lists/connections #568

Closed bellini666 closed 4 days ago

bellini666 commented 4 days ago

Fix #562

Summary by Sourcery

This pull request fixes an issue where the optimizer was not calling the type's get_queryset method for nested lists and connections. It also refactors the optimizer to use _default_manager for prefetching when prefetch_custom_queryset is enabled. Additionally, a new test is added to ensure the correct behavior.

sourcery-ai[bot] commented 4 days ago

Reviewer's Guide by Sourcery

This pull request addresses issue #562 by ensuring that the optimizer calls the type's get_queryset method for nested lists and connections. The changes include modifications to the optimizer logic in strawberry_django/optimizer.py, the addition of a new test in tests/test_optimizer.py, and an update to the GraphQL schema in tests/projects/schema.py.

File-Level Changes

Files Changes
tests/test_optimizer.py
strawberry_django/optimizer.py
Enhanced the optimizer to call the type's get_queryset for nested lists/connections and added corresponding tests to validate this behavior.

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.
codecov-commenter commented 4 days ago

Codecov Report

Attention: Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 89.00%. Comparing base (1023674) to head (2f85416).

Files Patch % Lines
strawberry_django/optimizer.py 75.00% 3 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #568 +/- ## ========================================== + Coverage 88.88% 89.00% +0.11% ========================================== Files 41 41 Lines 3545 3547 +2 ========================================== + Hits 3151 3157 +6 + Misses 394 390 -4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.