Skip to content

Commit

Permalink
Merge e052d18 into e0d4bec
Browse files Browse the repository at this point in the history
  • Loading branch information
wakemaster39 committed Jan 5, 2021
2 parents e0d4bec + e052d18 commit 77512ee
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions graphene/test/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -32,7 +32,14 @@ def format_result(self, result):

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 executed

return self.format_result(executed)

0 comments on commit 77512ee

Please sign in to comment.