From 60a9e7f7a8ad3803d11bc2351be07d1e33efaf43 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 | 12 ++++++------ 2 files changed, 7 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..aec9ace6 100644 --- a/graphene_mongo/tests/test_relay_query.py +++ b/graphene_mongo/tests/test_relay_query.py @@ -1,8 +1,11 @@ import os import json import base64 +from concurrent.futures import ThreadPoolExecutor + import graphene import pytest +from asgiref.sync import sync_to_async from graphene.relay import Node from graphql_relay.node.node import to_global_id @@ -268,12 +271,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