From 5ff73e6cce2a690b4e2a4804884f498c3db638ae Mon Sep 17 00:00:00 2001 From: Arun Suresh Kumar Date: Tue, 11 Apr 2023 18:05:09 +0530 Subject: [PATCH] Bug Fix on connection_resolver --- graphene_mongo/fields.py | 3 +-- graphene_mongo/tests/test_relay_query.py | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/graphene_mongo/fields.py b/graphene_mongo/fields.py index d568ce34..e248732b 100644 --- a/graphene_mongo/fields.py +++ b/graphene_mongo/fields.py @@ -563,8 +563,7 @@ async def connection_resolver(cls, resolver, connection_type, root, info, **args connection_type = connection_type.of_type if Promise.is_thenable(iterable): on_resolve = partial(cls.resolve_connection, connection_type, args) - return Promise.resolve(iterable).then(on_resolve) - + iterable = Promise.resolve(iterable).then(on_resolve).value return await sync_to_async(cls.resolve_connection, thread_sensitive=False, executor=ThreadPoolExecutor())(connection_type, args, iterable) diff --git a/graphene_mongo/tests/test_relay_query.py b/graphene_mongo/tests/test_relay_query.py index c9b3dfec..dcc1897d 100644 --- a/graphene_mongo/tests/test_relay_query.py +++ b/graphene_mongo/tests/test_relay_query.py @@ -1,6 +1,7 @@ import os import json import base64 + import graphene import pytest @@ -268,12 +269,9 @@ class Query(graphene.ObjectType): } } schema = graphene.Schema(query=Query) - try: - result = await schema.execute_async(query) - assert not result.errors - assert result.data == expected - except Exception as error: - a = error + result = await schema.execute_async(query) + assert not result.errors + assert result.data == expected @pytest.mark.asyncio