From 8e5354157c18e3f65b1ca3b47d21f8cc03c48292 Mon Sep 17 00:00:00 2001 From: Cameron Hurst Date: Tue, 5 Jan 2021 06:26:22 -0500 Subject: [PATCH] fix: test client is updated to be asyncio and not promises resolves #1296 --- graphene/test/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/graphene/test/__init__.py b/graphene/test/__init__.py index 8591dc06..3f42a7bd 100644 --- a/graphene/test/__init__.py +++ b/graphene/test/__init__.py @@ -1,6 +1,6 @@ -from promise import Promise, is_thenable from graphql.error import format_error as format_graphql_error from graphql.error import GraphQLError +from graphql.pyutils import is_awaitable from graphene.types.schema import Schema @@ -32,7 +32,14 @@ class Client: def execute(self, *args, **kwargs): executed = self.schema.execute(*args, **dict(self.execute_options, **kwargs)) - if is_thenable(executed): - return Promise.resolve(executed).then(self.format_result) + if is_awaitable(executed): + executed = asyncio.run(executed) + + return self.format_result(executed) + + async def execute_async(self, *args, **kwargs): + executed = self.schema.execute(*args, **dict(self.execute_options, **kwargs)) + if is_awaitable(executed): + executed = await asyncio.run(executed) return self.format_result(executed)