1515
1616
1717class Executor (object ):
18- def __init__ (self , schema , execution_middlewares = None ):
18+ def __init__ (self , schema , execution_middlewares = None , default_resolver = default_resolve_fn ):
1919 self .execution_middlewares = execution_middlewares or []
20+ self .default_resolve_fn = default_resolver
2021 self .schema = schema
2122
2223 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
3536
3637 return curried_execution_function ()
3738
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 ):
4041 if not isinstance (request , ast .Document ):
4142 if not isinstance (request , Source ):
4243 request = Source (request , 'GraphQL request' )
@@ -56,10 +57,11 @@ def _execute(self, request='', root=None, args=None, operation_name=None, execut
5657 request ,
5758 operation_name ,
5859 args or {},
60+ request_context or {},
5961 execute_serially )
6062
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 )
6365
6466 return defer (self ._execute_operation , ctx , root , ctx .operation , execute_serially ) \
6567 .add_errback (
@@ -127,7 +129,7 @@ def _resolve_field(self, execution_context, parent_type, source, field_asts):
127129 return Undefined
128130
129131 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
131133
132134 # Build a dict of arguments from the field.arguments AST, using the variables scope to
133135 # fulfill any variable references.
0 commit comments