You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alteration (enhancement/optimization) of existing feature(s)
New behavior
Description
We use InheritanceManager from django-model-utils for polymorphism. To get the subclasses of a polymorphic model you need to call the special .select_subclasses() queryset method on the base class.
I've defined an interface for the base class and types for the subclasses in Strawberry. The problem is the subclasses don't get downcasted because there's no way to call .select_subclasses() on the interface. This is different behavior than django-polymorphic which provides subclasses via the .all() queryset method.
As a result, I get this error message:
I've experimented with hacky workarounds like calling .select_subclasses() before hand in a prefetch as well as using the dataloader. But both break the optimizer and create n+1 queries for nested connection fields within the resolved subclass object that have a filter applied.
This feature request is to request a way to somehow make polymorphism work with django-model-utils' InheritanceManager's .select_subclasses(). django-polymorphic was at one point abandoned and Strawberry should allow the leading alternative to be used.
Upvote & Fund
We're using Polar.sh so you can upvote and help fund this issue.
We receive the funding once the issue is completed & confirmed by you.
Thank you in advance for helping prioritize & fund our backlog.
The text was updated successfully, but these errors were encountered:
But I still haven't found a solution to nested fields still losing their prefetch cache when applying a filter. Closing this feature request since theres a workable solution, and opening an issue for the nested field filter problem.
Feature Request Type
Description
We use InheritanceManager from django-model-utils for polymorphism. To get the subclasses of a polymorphic model you need to call the special
.select_subclasses()
queryset method on the base class.I've defined an interface for the base class and types for the subclasses in Strawberry. The problem is the subclasses don't get downcasted because there's no way to call
.select_subclasses()
on the interface. This is different behavior than django-polymorphic which provides subclasses via the.all()
queryset method.As a result, I get this error message:
I've experimented with hacky workarounds like calling
.select_subclasses()
before hand in a prefetch as well as using the dataloader. But both break the optimizer and create n+1 queries for nested connection fields within the resolved subclass object that have a filter applied.This feature request is to request a way to somehow make polymorphism work with django-model-utils' InheritanceManager's
.select_subclasses()
. django-polymorphic was at one point abandoned and Strawberry should allow the leading alternative to be used.Upvote & Fund
The text was updated successfully, but these errors were encountered: