From 69cec060d8d5b9bc5e6403e608079eadf77d1655 Mon Sep 17 00:00:00 2001 From: Cameron Dawson Date: Fri, 21 Jul 2017 11:23:16 -0700 Subject: [PATCH 1/2] Fix select_related with filtering --- graphene_django/filter/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene_django/filter/fields.py b/graphene_django/filter/fields.py index a80d8d7..b93977b 100644 --- a/graphene_django/filter/fields.py +++ b/graphene_django/filter/fields.py @@ -61,7 +61,7 @@ class DjangoFilterConnectionField(DjangoConnectionField): low = default_queryset.query.low_mark or queryset.query.low_mark high = default_queryset.query.high_mark or queryset.query.high_mark default_queryset.query.clear_limits() - queryset = default_queryset & queryset + queryset = queryset & default_queryset queryset.query.set_limits(low, high) return queryset From 1d76db8164a2a3723e41141209a8923bad5044bd Mon Sep 17 00:00:00 2001 From: Jacob Date: Mon, 9 Oct 2017 23:00:09 -0500 Subject: [PATCH 2/2] Use super for base queryset logic --- graphene_django/filter/fields.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/graphene_django/filter/fields.py b/graphene_django/filter/fields.py index b93977b..62c50d9 100644 --- a/graphene_django/filter/fields.py +++ b/graphene_django/filter/fields.py @@ -43,8 +43,8 @@ class DjangoFilterConnectionField(DjangoConnectionField): def filtering_args(self): return get_filtering_args_from_filterset(self.filterset_class, self.node_type) - @staticmethod - def merge_querysets(default_queryset, queryset): + @classmethod + def merge_querysets(cls, default_queryset, queryset): # There could be the case where the default queryset (returned from the filterclass) # and the resolver queryset have some limits on it. # We only would be able to apply one of those, but not both @@ -61,7 +61,9 @@ class DjangoFilterConnectionField(DjangoConnectionField): low = default_queryset.query.low_mark or queryset.query.low_mark high = default_queryset.query.high_mark or queryset.query.high_mark default_queryset.query.clear_limits() - queryset = queryset & default_queryset + + queryset = super(cls, cls).merge_querysets(default_queryset, queryset) + queryset.query.set_limits(low, high) return queryset