Closed moritz89 closed 1 month ago
Hey @moritz89 ,
Thanks for the report.
It wasn't actually that line, as one is the get_queryset
from the field and the other from the type, but I found the issue :)
Should be fixed in the next release that I'm going to make in a few minutes
When implementing types that override the
get_queryset()
method as well as using relay connection, theget_queryset()
method is called twice. This has the result, that when applying filters to the queryset they are applied twice. Since they are idempotent it does not change the query output, but adds unnecessary overhead.Describe the Bug
The core of bug appears to be
strawberry_django/fields/field.py:283-289
inStrawberryDjangoField:get_queryset()
. When not using the relay connection the bug does not appear, but with it the if statement resolves to Trueand it is also called on the next line with
System Information
Additional Context
This behavior is reproducible in the example app. If you already have a relay app, simply add a print in the overriding get_queryset method.
Attached is the diff, applied to commit 21c14e4
bug.zip
Upvote & Fund