Skip to content

Commit 0b3cb44

Browse files
committed
Fixed aliased fields in ResolveInfo path
1 parent ab73d5c commit 0b3cb44

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

graphql/execution/executor.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ def execute_field_callback(results, response_name):
142142
parent_type,
143143
source_value,
144144
field_asts,
145-
None
145+
None,
146+
[response_name]
146147
)
147148
if result is Undefined:
148149
return results
@@ -169,7 +170,7 @@ def execute_fields(exe_context, parent_type, source_value, fields, info):
169170
final_results = OrderedDict()
170171

171172
for response_name, field_asts in fields.items():
172-
result = resolve_field(exe_context, parent_type, source_value, field_asts, info)
173+
result = resolve_field(exe_context, parent_type, source_value, field_asts, info, (info.path if info else []) + [response_name])
173174
if result is Undefined:
174175
continue
175176

@@ -220,7 +221,7 @@ def catch_error(error):
220221
return Observable.merge(observables)
221222

222223

223-
def resolve_field(exe_context, parent_type, source, field_asts, parent_info):
224+
def resolve_field(exe_context, parent_type, source, field_asts, parent_info, field_path):
224225
field_ast = field_asts[0]
225226
field_name = field_ast.name.value
226227

@@ -256,7 +257,7 @@ def resolve_field(exe_context, parent_type, source, field_asts, parent_info):
256257
operation=exe_context.operation,
257258
variable_values=exe_context.variable_values,
258259
context=context,
259-
path=parent_info.path + [field_name] if parent_info else [field_name]
260+
path=field_path
260261
)
261262

262263
executor = exe_context.executor

graphql/execution/tests/test_executor.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,7 @@ def resolve(self, _next, root, info, *args, **kwargs):
758758
author {
759759
id
760760
name
761+
nameAlias: name
761762
}
762763
},
763764
}
@@ -781,7 +782,8 @@ def resolve(self, _next, root, info, *args, **kwargs):
781782
"body": "This is a post",
782783
"author": {
783784
"id": "123",
784-
"name": "John Smith"
785+
"name": "John Smith",
786+
"nameAlias": "John Smith"
785787
}
786788
},
787789
{
@@ -790,7 +792,8 @@ def resolve(self, _next, root, info, *args, **kwargs):
790792
"body": "This is a post",
791793
"author": {
792794
"id": "123",
793-
"name": "John Smith"
795+
"name": "John Smith",
796+
"nameAlias": "John Smith"
794797
}
795798
},
796799
],
@@ -809,6 +812,8 @@ def resolve(self, _next, root, info, *args, **kwargs):
809812
['feed', 1, 'author'],
810813
['feed', 0, 'author', 'id'],
811814
['feed', 0, 'author', 'name'],
815+
['feed', 0, 'author', 'nameAlias'],
812816
['feed', 1, 'author', 'id'],
813-
['feed', 1, 'author', 'name']
817+
['feed', 1, 'author', 'name'],
818+
['feed', 1, 'author', 'nameAlias'],
814819
]

0 commit comments

Comments
 (0)