15
15
16
16
17
17
class Executor (object ):
18
- def __init__ (self , schema , execution_middlewares = None ):
18
+ def __init__ (self , schema , execution_middlewares = None , default_resolver = default_resolve_fn ):
19
19
self .execution_middlewares = execution_middlewares or []
20
+ self .default_resolve_fn = default_resolver
20
21
self .schema = schema
21
22
22
23
def execute (self , request = '' , root = None , args = None , operation_name = None , execute_serially = False , validate_ast = True ):
@@ -35,8 +36,8 @@ def execute(self, request='', root=None, args=None, operation_name=None, execute
35
36
36
37
return curried_execution_function ()
37
38
38
- def _execute (self , request = '' , root = None , args = None , operation_name = None , execute_serially = False ,
39
- validate_ast = True ):
39
+ def _execute (self , request = '' , root = None , args = None , operation_name = None , request_context = None ,
40
+ execute_serially = False , validate_ast = True ):
40
41
if not isinstance (request , ast .Document ):
41
42
if not isinstance (request , Source ):
42
43
request = Source (request , 'GraphQL request' )
@@ -56,10 +57,11 @@ def _execute(self, request='', root=None, args=None, operation_name=None, execut
56
57
request ,
57
58
operation_name ,
58
59
args or {},
60
+ request_context or {},
59
61
execute_serially )
60
62
61
- def _execute_graphql_query (self , root , ast , operation_name , args , execute_serially = False ):
62
- ctx = ExecutionContext (self .schema , root , ast , operation_name , args )
63
+ def _execute_graphql_query (self , root , ast , operation_name , args , request_context , execute_serially = False ):
64
+ ctx = ExecutionContext (self .schema , root , ast , operation_name , args , request_context )
63
65
64
66
return defer (self ._execute_operation , ctx , root , ctx .operation , execute_serially ) \
65
67
.add_errback (
@@ -127,7 +129,7 @@ def _resolve_field(self, execution_context, parent_type, source, field_asts):
127
129
return Undefined
128
130
129
131
return_type = field_def .type
130
- resolve_fn = field_def .resolver or default_resolve_fn
132
+ resolve_fn = field_def .resolver or self . default_resolve_fn
131
133
132
134
# Build a dict of arguments from the field.arguments AST, using the variables scope to
133
135
# fulfill any variable references.
0 commit comments