File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,31 @@ def resolve_reporter(self, info):
6060 assert result .data == {"reporter" : {"id" : "1" }}
6161
6262
63+ def test_should_query_wrapped_simplelazy_objects ():
64+ class ReporterType (DjangoObjectType ):
65+ class Meta :
66+ model = Reporter
67+ fields = ("id" ,)
68+
69+ class Query (graphene .ObjectType ):
70+ reporter = graphene .Field (ReporterType )
71+
72+ def resolve_reporter (self , info ):
73+ return SimpleLazyObject (lambda : SimpleLazyObject (lambda : Reporter (id = 1 )))
74+
75+ schema = graphene .Schema (query = Query )
76+ query = """
77+ query {
78+ reporter {
79+ id
80+ }
81+ }
82+ """
83+ result = schema .execute (query )
84+ assert not result .errors
85+ assert result .data == {"reporter" : {"id" : "1" }}
86+
87+
6388def test_should_query_well ():
6489 class ReporterType (DjangoObjectType ):
6590 class Meta :
Original file line number Diff line number Diff line change @@ -272,12 +272,9 @@ def resolve_id(self, info):
272272
273273 @classmethod
274274 def is_type_of (cls , root , info ):
275- if isinstance (root , SimpleLazyObject ):
276- root ._setup ()
277- root = root ._wrapped
278275 if isinstance (root , cls ):
279276 return True
280- if not is_valid_django_model (type ( root ) ):
277+ if not is_valid_django_model (root . __class__ ):
281278 raise Exception (('Received incompatible instance "{}".' ).format (root ))
282279
283280 if cls ._meta .model ._meta .proxy :
You can’t perform that action at this time.
0 commit comments