@@ -83,6 +83,7 @@ def on_resolve(data):
83
83
if isinstance (data , Observable ):
84
84
return data
85
85
86
+ tracing_middleware .end ()
86
87
extensions = dict (tracing = tracing_middleware .tracing_dict )
87
88
88
89
if not context .errors :
@@ -121,7 +122,7 @@ def execute_operation(exe_context, operation, root_value):
121
122
)
122
123
return subscribe_fields (exe_context , type , root_value , fields )
123
124
124
- return execute_fields (exe_context , type , root_value , fields )
125
+ return execute_fields (exe_context , type , root_value , fields , None )
125
126
126
127
127
128
def execute_fields_serially (exe_context , parent_type , source_value , fields ):
@@ -152,14 +153,13 @@ def execute_field(prev_promise, response_name):
152
153
return functools .reduce (execute_field , fields .keys (), Promise .resolve (collections .OrderedDict ()))
153
154
154
155
155
- def execute_fields (exe_context , parent_type , source_value , fields ):
156
+ def execute_fields (exe_context , parent_type , source_value , fields , info ):
156
157
contains_promise = False
157
158
158
159
final_results = OrderedDict ()
159
160
160
161
for response_name , field_asts in fields .items ():
161
- result = resolve_field (exe_context , parent_type ,
162
- source_value , field_asts )
162
+ result = resolve_field (exe_context , parent_type , source_value , field_asts , info )
163
163
if result is Undefined :
164
164
continue
165
165
@@ -211,7 +211,7 @@ def catch_error(error):
211
211
return Observable .merge (observables )
212
212
213
213
214
- def resolve_field (exe_context , parent_type , source , field_asts ):
214
+ def resolve_field (exe_context , parent_type , source , field_asts , parent_info ):
215
215
field_ast = field_asts [0 ]
216
216
field_name = field_ast .name .value
217
217
@@ -246,12 +246,12 @@ def resolve_field(exe_context, parent_type, source, field_asts):
246
246
root_value = exe_context .root_value ,
247
247
operation = exe_context .operation ,
248
248
variable_values = exe_context .variable_values ,
249
- context = context
249
+ context = context ,
250
+ path = parent_info .path + [field_name ] if parent_info else [field_name ]
250
251
)
251
252
252
253
executor = exe_context .executor
253
- result = resolve_or_error (resolve_fn_middleware ,
254
- source , info , args , executor )
254
+ result = resolve_or_error (resolve_fn_middleware , source , info , args , executor )
255
255
256
256
return complete_value_catching_error (
257
257
exe_context ,
@@ -377,7 +377,6 @@ def complete_value(exe_context, return_type, field_asts, info, result):
377
377
"""
378
378
# If field type is NonNull, complete for inner type, and throw field error
379
379
# if result is null.
380
-
381
380
if is_thenable (result ):
382
381
return Promise .resolve (result ).then (
383
382
lambda resolved : complete_value (
@@ -432,13 +431,16 @@ def complete_list_value(exe_context, return_type, field_asts, info, result):
432
431
item_type = return_type .of_type
433
432
completed_results = []
434
433
contains_promise = False
434
+ index = 0
435
435
for item in result :
436
- completed_item = complete_value_catching_error (
437
- exe_context , item_type , field_asts , info , item )
436
+ new_info = info .clone ()
437
+ new_info .path += [index ]
438
+ completed_item = complete_value_catching_error (exe_context , item_type , field_asts , new_info , item )
438
439
if not contains_promise and is_thenable (completed_item ):
439
440
contains_promise = True
440
441
441
442
completed_results .append (completed_item )
443
+ index += 1
442
444
443
445
return Promise .all (completed_results ) if contains_promise else completed_results
444
446
@@ -514,7 +516,7 @@ def complete_object_value(exe_context, return_type, field_asts, info, result):
514
516
515
517
# Collect sub-fields to execute to complete this value.
516
518
subfield_asts = exe_context .get_sub_fields (return_type , field_asts )
517
- return execute_fields (exe_context , return_type , result , subfield_asts )
519
+ return execute_fields (exe_context , return_type , result , subfield_asts , info )
518
520
519
521
520
522
def complete_nonnull_value (exe_context , return_type , field_asts , info , result ):
0 commit comments