mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-22 13:59:51 +03:00
fix: test client is updated to be asyncio and not promises
resolves #1296
This commit is contained in:
parent
2e87ebe5fc
commit
8e5354157c
|
@ -1,6 +1,6 @@
|
||||||
from promise import Promise, is_thenable
|
|
||||||
from graphql.error import format_error as format_graphql_error
|
from graphql.error import format_error as format_graphql_error
|
||||||
from graphql.error import GraphQLError
|
from graphql.error import GraphQLError
|
||||||
|
from graphql.pyutils import is_awaitable
|
||||||
|
|
||||||
from graphene.types.schema import Schema
|
from graphene.types.schema import Schema
|
||||||
|
|
||||||
|
@ -32,7 +32,14 @@ class Client:
|
||||||
|
|
||||||
def execute(self, *args, **kwargs):
|
def execute(self, *args, **kwargs):
|
||||||
executed = self.schema.execute(*args, **dict(self.execute_options, **kwargs))
|
executed = self.schema.execute(*args, **dict(self.execute_options, **kwargs))
|
||||||
if is_thenable(executed):
|
if is_awaitable(executed):
|
||||||
return Promise.resolve(executed).then(self.format_result)
|
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)
|
return self.format_result(executed)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user