strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
https://strawberry.rocks/docs/django
MIT License
406 stars 117 forks source link

Optimizer ignores/disables nested pagination #563

Closed aprams closed 3 months ago

aprams commented 3 months ago

Using nested pagination worked in previous versions, but seems to not work with the optimizer anymore after 0.44.0

Describe the Bug

Example query:

query {
    departments {
        id
        name
        users (pagination: {limit: 1}, order: {name: ASC}) {
            id
            name
        }
    }

This used to return a nested pagination. With the DjangoOptimizerExtension on 0.44.0+, this pagination is however ignored and all users are returned.

System Information

Additional Context

Upvote & Fund

Fund with Polar

bellini666 commented 3 months ago

@aprams I just released https://github.com/strawberry-graphql/strawberry-django/releases/tag/v0.46.0 to fix the other issue you reported and I'm wondering if it will fix this one as well?

Please let me know as I'm currently unable to reproduce this. We even have a test case for nested prefetching with filters, and those tests are passing fine.

If the issue still exists in 0.46.0, would you be able to produce an MRE? It can be in the form of a unit test inside strawberry-django itself

aprams commented 3 months ago

Hi @bellini666, thanks for the quick response. I tried it locally, didn't work, I'll try to create a MRE as a unit test and get back to you!

aprams commented 3 months ago

@bellini666 Here we go! Took me a bit to pin down the enable_only_optimization being the parameter that makes or breaks the test. You can find the MRE here: https://github.com/strawberry-graphql/strawberry-django/pull/569/files (made it a PR to comment).

Our use case to turn off the only optimization is that we also use django-multitenant (https://github.com/citusdata/django-multitenant) to separate tenants. With only_optimization on, our tenant field is not automatically returned from the DB, which caused issues.

Any idea how the only optimization influences this?