Open oleo65 opened 1 year ago
Any word on this issue?
Hey @iacobfred and @oleo65
Wow, I did miss that issue when it got opened. I'm not really sure what might be happening, specially because after moving from graphene I stopped using django_filters and relied on filter lookups provided by this lib.
I'll soon take a look and try to replicate the issue to try to discover what might be going on.
obs. does that only happens when using this lib together with Strawberry-django-plus
? Or does it happen with this alone?
I'm struggling to remember the exact circumstances for this issue but believe that it was including django_strawberry_plus
.
Thanks for looking into it.
When doing a search for django_filters
in this repo only this issue and a record in the CHANGELOG come up about the introduction of the django_filter
support. But it's nowhere in the docs. Was django_filter
support put on pause?
Context
I am coming from graphene and have been migrating multiple projects to strawberry with the current being a fairly large api project. The current project relies heavily on
django_filters
for streamlining the filtering experience.As far as I can tell from past issue and merge requests
strawberry_django
and combination withstrawberry_django_plus
should support filtering models byFilterSet
classes. (This is what I found here among others: #15 #20 )The declared filters have been working in combination with graphene and are valid django_filters which should work in strawberry context as well.
After hours of debugging I am somewhat stuck in finding the root cause of this issue. 🤷
Long story short, they get properly applied to the schema definition and to the field. But they do not get applied to the queryset during resolving of the objects and therefore being ignored.
Expected behaviour
If I declare a
FilterSet
class which I either apply to thestrawberry.django.type
or the field directly it should honor the declared filters during resolving of the fields.Minimal example
I put together a minimal example showing some custom filtering with lookup expressions valid to django querysets.
I suspect that there is some issue with instanciation of the actual
FilterSet
class instance and further down applying it to the queryset. Inspecting with the debugger it seems to me that the class instance is not properly initialized and the__init__
method won't be hit.Any help here is appreciated. If you need more info please let me know. 😃
Upvote & Fund