Skip to content

Commit 207f4eb

Browse files
committed
added a test and made the type property better
1 parent dc6e8f1 commit 207f4eb

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

graphene_django/filter/fields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import inspect
2+
13
from collections import OrderedDict
24
from functools import partial
35

@@ -21,7 +23,7 @@ def __init__(self, type, fields=None, order_by=None,
2123

2224
@property
2325
def node_type(self):
24-
if callable(self._type):
26+
if inspect.isfunction(self._type) or inspect.ismethod(self._type):
2527
return self._type()
2628
return self._type
2729

graphene_django/filter/tests/test_fields.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,20 @@ class Query(ObjectType):
350350
assert not result.errors
351351
# We should only get two reporters
352352
assert len(result.data['allReporters']['edges']) == 2
353+
354+
355+
def test_recursive_filter_connection():
356+
class ReporterFilterNode(DjangoObjectType):
357+
child_reporters = DjangoFilterConnectionField(lambda: ReporterFilterNode)
358+
359+
def resolve_child_reporters(self, args, context, info):
360+
return []
361+
362+
class Meta:
363+
model = Reporter
364+
interfaces = (Node, )
365+
366+
class Query(ObjectType):
367+
all_reporters = DjangoFilterConnectionField(ReporterFilterNode)
368+
369+
assert ReporterFilterNode._meta.fields['child_reporters'].node_type == ReporterFilterNode

0 commit comments

Comments
 (0)