Skip to content

Commit afa6b93

Browse files
committed
use groupedFieldSet as variable name
Replicates graphql/graphql-js@a074400
1 parent 600db31 commit afa6b93

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

src/graphql/execution/collect_fields.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ class PatchFields(NamedTuple):
5252
"""Optionally labelled set of fields to be used as a patch."""
5353

5454
label: str | None
55-
fields: GroupedFieldSet
55+
grouped_field_set: GroupedFieldSet
5656

5757

5858
class FieldsAndPatches(NamedTuple):
5959
"""Tuple of collected fields and patches to be applied."""
6060

61-
fields: GroupedFieldSet
61+
grouped_field_set: GroupedFieldSet
6262
patches: list[PatchFields]
6363

6464

@@ -79,7 +79,7 @@ def collect_fields(
7979
8080
For internal use only.
8181
"""
82-
fields: dict[str, list[FieldNode]] = defaultdict(list)
82+
grouped_field_set: dict[str, list[FieldNode]] = defaultdict(list)
8383
patches: list[PatchFields] = []
8484
collect_fields_impl(
8585
schema,
@@ -88,11 +88,11 @@ def collect_fields(
8888
operation,
8989
runtime_type,
9090
operation.selection_set,
91-
fields,
91+
grouped_field_set,
9292
patches,
9393
set(),
9494
)
95-
return FieldsAndPatches(fields, patches)
95+
return FieldsAndPatches(grouped_field_set, patches)
9696

9797

9898
def collect_subfields(
@@ -114,11 +114,11 @@ def collect_subfields(
114114
115115
For internal use only.
116116
"""
117-
sub_field_nodes: dict[str, list[FieldNode]] = defaultdict(list)
117+
sub_grouped_field_set: dict[str, list[FieldNode]] = defaultdict(list)
118118
visited_fragment_names: set[str] = set()
119119

120120
sub_patches: list[PatchFields] = []
121-
sub_fields_and_patches = FieldsAndPatches(sub_field_nodes, sub_patches)
121+
sub_fields_and_patches = FieldsAndPatches(sub_grouped_field_set, sub_patches)
122122

123123
for node in field_group:
124124
if node.selection_set:
@@ -129,7 +129,7 @@ def collect_subfields(
129129
operation,
130130
return_type,
131131
node.selection_set,
132-
sub_field_nodes,
132+
sub_grouped_field_set,
133133
sub_patches,
134134
visited_fragment_names,
135135
)
@@ -143,7 +143,7 @@ def collect_fields_impl(
143143
operation: OperationDefinitionNode,
144144
runtime_type: GraphQLObjectType,
145145
selection_set: SelectionSetNode,
146-
fields: dict[str, list[FieldNode]],
146+
grouped_field_set: dict[str, list[FieldNode]],
147147
patches: list[PatchFields],
148148
visited_fragment_names: set[str],
149149
) -> None:
@@ -154,7 +154,7 @@ def collect_fields_impl(
154154
if isinstance(selection, FieldNode):
155155
if not should_include_node(variable_values, selection):
156156
continue
157-
fields[get_field_entry_key(selection)].append(selection)
157+
grouped_field_set[get_field_entry_key(selection)].append(selection)
158158
elif isinstance(selection, InlineFragmentNode):
159159
if not should_include_node(
160160
variable_values, selection
@@ -184,7 +184,7 @@ def collect_fields_impl(
184184
operation,
185185
runtime_type,
186186
selection.selection_set,
187-
fields,
187+
grouped_field_set,
188188
patches,
189189
visited_fragment_names,
190190
)
@@ -229,7 +229,7 @@ def collect_fields_impl(
229229
operation,
230230
runtime_type,
231231
fragment.selection_set,
232-
fields,
232+
grouped_field_set,
233233
patches,
234234
visited_fragment_names,
235235
)

src/graphql/execution/execute.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ def execute_operation(self) -> AwaitableOrValue[dict[str, Any]]:
813813
)
814814
raise GraphQLError(msg, operation)
815815

816-
root_fields, patches = collect_fields(
816+
grouped_field_set, patches = collect_fields(
817817
schema,
818818
self.fragments,
819819
self.variable_values,
@@ -827,12 +827,12 @@ def execute_operation(self) -> AwaitableOrValue[dict[str, Any]]:
827827
self.execute_fields_serially
828828
if operation.operation == OperationType.MUTATION
829829
else self.execute_fields
830-
)(root_type, root_value, None, root_fields) # type: ignore
830+
)(root_type, root_value, None, grouped_field_set) # type: ignore
831831

832832
for patch in patches:
833-
label, patch_fields = patch
833+
label, patch_grouped_filed_set = patch
834834
self.execute_deferred_fragment(
835-
root_type, root_value, patch_fields, label, None
835+
root_type, root_value, patch_grouped_filed_set, label, None
836836
)
837837

838838
return result
@@ -1604,10 +1604,12 @@ def collect_and_execute_subfields(
16041604
async_payload_record: AsyncPayloadRecord | None,
16051605
) -> AwaitableOrValue[dict[str, Any]]:
16061606
"""Collect sub-fields to execute to complete this value."""
1607-
sub_field_nodes, sub_patches = self.collect_subfields(return_type, field_group)
1607+
sub_grouped_field_set, sub_patches = self.collect_subfields(
1608+
return_type, field_group
1609+
)
16081610

16091611
sub_fields = self.execute_fields(
1610-
return_type, result, path, sub_field_nodes, async_payload_record
1612+
return_type, result, path, sub_grouped_field_set, async_payload_record
16111613
)
16121614

16131615
for sub_patch in sub_patches:
@@ -2503,14 +2505,14 @@ def execute_subscription(
25032505
msg = "Schema is not configured to execute subscription operation."
25042506
raise GraphQLError(msg, context.operation)
25052507

2506-
root_fields = collect_fields(
2508+
grouped_field_set = collect_fields(
25072509
schema,
25082510
context.fragments,
25092511
context.variable_values,
25102512
root_type,
25112513
context.operation,
2512-
).fields
2513-
first_root_field = next(iter(root_fields.items()))
2514+
).grouped_field_set
2515+
first_root_field = next(iter(grouped_field_set.items()))
25142516
response_name, field_group = first_root_field
25152517
field_name = field_group[0].name.value
25162518
field_def = schema.get_field(root_type, field_name)

src/graphql/validation/rules/single_field_subscriptions.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ def enter_operation_definition(
4242
for definition in document.definitions
4343
if isinstance(definition, FragmentDefinitionNode)
4444
}
45-
fields = collect_fields(
45+
grouped_field_set = collect_fields(
4646
schema,
4747
fragments,
4848
variable_values,
4949
subscription_type,
5050
node,
51-
).fields
52-
if len(fields) > 1:
53-
field_selection_lists = list(fields.values())
51+
).grouped_field_set
52+
if len(grouped_field_set) > 1:
53+
field_selection_lists = list(grouped_field_set.values())
5454
extra_field_selection_lists = field_selection_lists[1:]
5555
extra_field_selection = [
5656
field
@@ -72,7 +72,7 @@ def enter_operation_definition(
7272
extra_field_selection,
7373
)
7474
)
75-
for field_group in fields.values():
75+
for field_group in grouped_field_set.values():
7676
field_name = field_group[0].name.value
7777
if field_name.startswith("__"):
7878
self.report_error(

0 commit comments

Comments
 (0)