diff --git a/graphene_django/filter/fields.py b/graphene_django/filter/fields.py index 9fa6130..7e632a7 100644 --- a/graphene_django/filter/fields.py +++ b/graphene_django/filter/fields.py @@ -1,3 +1,5 @@ +import inspect + from collections import OrderedDict from functools import partial @@ -21,7 +23,7 @@ class DjangoFilterConnectionField(DjangoConnectionField): @property def node_type(self): - if callable(self._type): + if inspect.isfunction(self._type) or inspect.ismethod(self._type): return self._type() return self._type diff --git a/graphene_django/filter/tests/test_fields.py b/graphene_django/filter/tests/test_fields.py index ab3d677..ba1d8fc 100644 --- a/graphene_django/filter/tests/test_fields.py +++ b/graphene_django/filter/tests/test_fields.py @@ -350,3 +350,20 @@ def test_filter_filterset_related_results(): assert not result.errors # We should only get two reporters assert len(result.data['allReporters']['edges']) == 2 + + +def test_recursive_filter_connection(): + class ReporterFilterNode(DjangoObjectType): + child_reporters = DjangoFilterConnectionField(lambda: ReporterFilterNode) + + def resolve_child_reporters(self, args, context, info): + return [] + + class Meta: + model = Reporter + interfaces = (Node, ) + + class Query(ObjectType): + all_reporters = DjangoFilterConnectionField(ReporterFilterNode) + + assert ReporterFilterNode._meta.fields['child_reporters'].node_type == ReporterFilterNode