17
17
collect_fields , default_resolve_fn , get_field_def ,
18
18
get_operation_root_type )
19
19
from .executors .sync import SyncExecutor
20
- from .experimental .executor import execute as experimental_execute
21
20
from .middleware import MiddlewareManager
22
21
23
22
logger = logging .getLogger (__name__ )
24
23
25
24
26
- use_experimental_executor = False
27
-
28
-
29
25
def execute (schema , document_ast , root_value = None , context_value = None ,
30
26
variable_values = None , operation_name = None , executor = None ,
31
27
return_promise = False , middleware = None ):
32
- if use_experimental_executor :
33
- return experimental_execute (
34
- schema , document_ast , root_value , context_value ,
35
- variable_values , operation_name , executor ,
36
- return_promise , middleware
37
- )
38
-
39
28
assert schema , 'Must provide schema'
40
29
assert isinstance (schema , GraphQLSchema ), (
41
30
'Schema must be an instance of GraphQLSchema. Also ensure that there are ' +
@@ -182,10 +171,11 @@ def resolve_field(exe_context, parent_type, source, field_asts):
182
171
root_value = exe_context .root_value ,
183
172
operation = exe_context .operation ,
184
173
variable_values = exe_context .variable_values ,
174
+ context = context
185
175
)
186
176
187
177
executor = exe_context .executor
188
- result = resolve_or_error (resolve_fn_middleware , source , args , context , info , executor )
178
+ result = resolve_or_error (resolve_fn_middleware , source , info , args , executor )
189
179
190
180
return complete_value_catching_error (
191
181
exe_context ,
@@ -196,9 +186,9 @@ def resolve_field(exe_context, parent_type, source, field_asts):
196
186
)
197
187
198
188
199
- def resolve_or_error (resolve_fn , source , args , context , info , executor ):
189
+ def resolve_or_error (resolve_fn , source , info , args , executor ):
200
190
try :
201
- return executor .execute (resolve_fn , source , args , context , info )
191
+ return executor .execute (resolve_fn , source , info , ** args )
202
192
except Exception as e :
203
193
logger .exception ("An error occurred while resolving field {}.{}" .format (
204
194
info .parent_type .name , info .field_name
@@ -334,9 +324,9 @@ def complete_abstract_value(exe_context, return_type, field_asts, info, result):
334
324
# Field type must be Object, Interface or Union and expect sub-selections.
335
325
if isinstance (return_type , (GraphQLInterfaceType , GraphQLUnionType )):
336
326
if return_type .resolve_type :
337
- runtime_type = return_type .resolve_type (result , exe_context . context_value , info )
327
+ runtime_type = return_type .resolve_type (result , info )
338
328
else :
339
- runtime_type = get_default_resolve_type_fn (result , exe_context . context_value , info , return_type )
329
+ runtime_type = get_default_resolve_type_fn (result , info , return_type )
340
330
341
331
if isinstance (runtime_type , string_types ):
342
332
runtime_type = info .schema .get_type (runtime_type )
@@ -363,18 +353,18 @@ def complete_abstract_value(exe_context, return_type, field_asts, info, result):
363
353
return complete_object_value (exe_context , runtime_type , field_asts , info , result )
364
354
365
355
366
- def get_default_resolve_type_fn (value , context , info , abstract_type ):
356
+ def get_default_resolve_type_fn (value , info , abstract_type ):
367
357
possible_types = info .schema .get_possible_types (abstract_type )
368
358
for type in possible_types :
369
- if callable (type .is_type_of ) and type .is_type_of (value , context , info ):
359
+ if callable (type .is_type_of ) and type .is_type_of (value , info ):
370
360
return type
371
361
372
362
373
363
def complete_object_value (exe_context , return_type , field_asts , info , result ):
374
364
"""
375
365
Complete an Object value by evaluating all sub-selections.
376
366
"""
377
- if return_type .is_type_of and not return_type .is_type_of (result , exe_context . context_value , info ):
367
+ if return_type .is_type_of and not return_type .is_type_of (result , info ):
378
368
raise GraphQLError (
379
369
u'Expected value of type "{}" but got: {}.' .format (return_type , type (result ).__name__ ),
380
370
field_asts
0 commit comments