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):
60
60
assert result .data == {"reporter" : {"id" : "1" }}
61
61
62
62
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
+
63
88
def test_should_query_well ():
64
89
class ReporterType (DjangoObjectType ):
65
90
class Meta :
Original file line number Diff line number Diff line change @@ -272,12 +272,9 @@ def resolve_id(self, info):
272
272
273
273
@classmethod
274
274
def is_type_of (cls , root , info ):
275
- if isinstance (root , SimpleLazyObject ):
276
- root ._setup ()
277
- root = root ._wrapped
278
275
if isinstance (root , cls ):
279
276
return True
280
- if not is_valid_django_model (type ( root ) ):
277
+ if not is_valid_django_model (root . __class__ ):
281
278
raise Exception (('Received incompatible instance "{}".' ).format (root ))
282
279
283
280
if cls ._meta .model ._meta .proxy :
You can’t perform that action at this time.
0 commit comments