From d4041f7acecbc0055ea49333830c8e9bbf09b74c Mon Sep 17 00:00:00 2001 From: Paul Craciunoiu Date: Sat, 9 May 2020 09:40:09 -0600 Subject: [PATCH] Add test. --- graphene_django/tests/test_query.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/graphene_django/tests/test_query.py b/graphene_django/tests/test_query.py index 698ca23..bb9cc88 100644 --- a/graphene_django/tests/test_query.py +++ b/graphene_django/tests/test_query.py @@ -60,6 +60,31 @@ def test_should_query_simplelazy_objects(): assert result.data == {"reporter": {"id": "1"}} +def test_should_query_wrapped_simplelazy_objects(): + class ReporterType(DjangoObjectType): + class Meta: + model = Reporter + fields = ("id",) + + class Query(graphene.ObjectType): + reporter = graphene.Field(ReporterType) + + def resolve_reporter(self, info): + return SimpleLazyObject(lambda: SimpleLazyObject(lambda: Reporter(id=1))) + + schema = graphene.Schema(query=Query) + query = """ + query { + reporter { + id + } + } + """ + result = schema.execute(query) + assert not result.errors + assert result.data == {"reporter": {"id": "1"}} + + def test_should_query_well(): class ReporterType(DjangoObjectType): class Meta: