mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-23 07:00:56 +03:00
added returns_promise flag to schema.execute
This commit is contained in:
parent
b5b66326a7
commit
2d7b788568
|
@ -118,7 +118,7 @@ class Schema(object):
|
|||
return self._types_names
|
||||
|
||||
def execute(self, request_string='', root_value=None, variable_values=None,
|
||||
context_value=None, operation_name=None, executor=None):
|
||||
context_value=None, operation_name=None, executor=None, return_promise=False):
|
||||
return graphql(
|
||||
schema=self.schema,
|
||||
request_string=request_string,
|
||||
|
@ -126,7 +126,8 @@ class Schema(object):
|
|||
context_value=context_value,
|
||||
variable_values=variable_values,
|
||||
operation_name=operation_name,
|
||||
executor=executor or self._executor
|
||||
executor=executor or self._executor,
|
||||
return_promise=return_promise
|
||||
)
|
||||
|
||||
def introspect(self):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from graphql import graphql
|
||||
from py.test import raises
|
||||
from promise import is_thenable
|
||||
|
||||
from graphene import Interface, List, ObjectType, Schema, String
|
||||
from graphene.core.fields import Field
|
||||
|
@ -88,6 +89,19 @@ def test_query_schema_execute():
|
|||
assert not result.errors
|
||||
assert result.data == expected
|
||||
|
||||
def test_schema_returns_promise():
|
||||
object()
|
||||
query = '''
|
||||
{
|
||||
name
|
||||
pet {
|
||||
type
|
||||
}
|
||||
}
|
||||
'''
|
||||
result = schema.execute(query, root_value=object(), return_promise=True)
|
||||
assert is_thenable(result)
|
||||
|
||||
|
||||
def test_schema_get_type_map():
|
||||
assert_equal_lists(
|
||||
|
|
Loading…
Reference in New Issue
Block a user