-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_queryset() is not called #488
Comments
Hi @alimony , Can you provide a MRE or at least give more information about how you are using using that type? Because there are some differences between using it directly on a root type (e.g. |
It looks something like this: @strawberry_django.type(
Customer,
filters=CustomerFilter,
fields=[
"name",
...
],
)
class CustomerType:
name: auto
org: OrgType
@classmethod
def get_queryset(
cls, queryset: QuerySet[Customer], info: Info, **kwargs
) -> QuerySet[Customer]:
return queryset.filter(...) (Edited for NDA reasons.) I can make a proper test case next week if needed. |
@alimony I mean, some examples of where that For example, is is used in a root query like this? @strawberry.type
class Query:
customers: list[CustomerType] = strawberry_django.field() Or in a nested django type: @strawberry_type.type(SomeModel)
class SomeModelType:
customers: list[CustomerType] = strawberry_django.field()
# or like this
@strawberry_django.field
def customers(self) -> list[CustomerType]:
... |
It's at the root, if I understand your question correctly. At the top level I have something like this: @strawberry.type
class Query:
customers: CustomerType | None = strawberry_django.field(extensions=[auth_required])
...
schema = strawberry.Schema(
query=Query,
mutation=Mutation,
extensions=schema_extensions,
) and then this: @strawberry_django.type(
Customer,
filters=CustomerFilter,
fields=[
"name",
...
],
)
class CustomerType:
name: auto
org: OrgType
...
@classmethod
def get_queryset(cls, queryset: QuerySet[Customer], info: Info, **kwargs) -> QuerySet[Customer]:
print('calling custom get_queryset') # this never gets called
return queryset.filter(...) |
Hey @alimony , I'm trying to replicate the issue in here but it is working correctly on my tests. Take a look at this test for example: 7b5ee33#diff-723b95803cbfa95b72fb2bc64e3000c86c7cf4920592b4dec6e15cc2ae08e821R167 . I defined it just like your example and The only major difference I can see is that you have |
I'm trying to add a
.get_queryset()
class method to one of my types, but it is never called when querying. I just put a print on top of the method and it never happens. Fields on the type behave normally so I know the type is in use.I can't get even the simple example from the docs to work:
What could be going on here?
I'm on version 0.28.2.
Upvote & Fund
The text was updated successfully, but these errors were encountered: