diff --git a/graphene_django/fields.py b/graphene_django/fields.py index a1b9a2cc..0fd66b43 100644 --- a/graphene_django/fields.py +++ b/graphene_django/fields.py @@ -251,9 +251,12 @@ def connection_resolver( return on_resolve(iterable) def wrap_resolve(self, parent_resolver): + # skip the wrap_resolve method on ConnectionField as it's already + # wrapping the connection_resolver, so we don't want to do it twice + resolver = super(ConnectionField, self).wrap_resolve(parent_resolver) return partial( self.connection_resolver, - parent_resolver, + resolver, self.connection_type, self.get_manager(), self.get_queryset_resolver(), diff --git a/graphene_django/tests/test_fields.py b/graphene_django/tests/test_fields.py index caaa6ddf..185cc223 100644 --- a/graphene_django/tests/test_fields.py +++ b/graphene_django/tests/test_fields.py @@ -748,3 +748,35 @@ class Query(ObjectType): match="DjangoConnectionField only accepts DjangoObjectType types as underlying type", ): Schema(query=Query) + + def test_can_use_custom_resolver(self): + def resolve_some_people(*args, **kwargs): + return PersonModel.objects.filter(name="Bob") + + class PersonType(DjangoObjectType): + class Meta: + model = PersonModel + interfaces = (Node,) + + class Query(ObjectType): + people = DjangoConnectionField(PersonType, resolver=resolve_some_people) + + schema = Schema(query=Query) + PersonModel.objects.create(name="Bob") + PersonModel.objects.create(name="Alice") + + query = """ + query { + people { + edges { + node { + name + } + } + } + } + """ + + result = schema.execute(query) + assert not result.errors + assert result.data == {"people": {"edges": [{"node": {"name": "Bob"}}]}}