Skip to content

Commit c5c33a0

Browse files
benjieyaacovCR
authored andcommitted
Change ExecuteSelectionSet to ExecuteGroupedFieldSet
1 parent 160315d commit c5c33a0

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

spec/Section 6 -- Execution.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -321,31 +321,34 @@ Executing the root selection set works similarly for queries (parallel),
321321
mutations (serial), and subscriptions (where it is executed for each event in
322322
the underlying Source Stream).
323323

324+
First, the selection set is turned into a grouped field set; then, we execute
325+
this grouped field set and return the resulting {data} and {errors}.
326+
324327
ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
325328
serial):
326329

327330
- If {serial} is not provided, initialize it to {false}.
328-
- Let {data} be the result of running {ExecuteSelectionSet(selectionSet,
331+
- Let {groupedFieldSet} be the result of {CollectFields(objectType,
332+
selectionSet, variableValues)}.
333+
- Let {data} be the result of running {ExecuteGroupedFieldSet(groupedFieldSet,
329334
objectType, initialValue, variableValues)} _serially_ if {serial} is {true},
330335
_normally_ (allowing parallelization) otherwise.
331336
- Let {errors} be the list of all _field error_ raised while executing the
332337
selection set.
333338
- Return an unordered map containing {data} and {errors}.
334339

335-
## Executing Selection Sets
340+
## Executing a Grouped Field Set
336341

337-
To execute a _selection set_, the object value being evaluated and the object
342+
To execute a grouped field set, the object value being evaluated and the object
338343
type need to be known, as well as whether it must be executed serially, or may
339344
be executed in parallel.
340345

341-
First, the selection set is turned into a grouped field set; then, each
342-
represented field in the grouped field set produces an entry into a response
343-
map.
346+
Each represented field in the grouped field set produces an entry into a
347+
response map.
344348

345-
ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
349+
ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
350+
variableValues):
346351

347-
- Let {groupedFieldSet} be the result of {CollectFields(objectType,
348-
selectionSet, variableValues)}.
349352
- Initialize {resultMap} to an empty ordered map.
350353
- For each {groupedFieldSet} as {responseKey} and {fields}:
351354
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
@@ -363,8 +366,8 @@ is explained in greater detail in the Field Collection section below.
363366

364367
**Errors and Non-Null Fields**
365368

366-
If during {ExecuteSelectionSet()} a field with a non-null {fieldType} raises a
367-
_field error_ then that error must propagate to this entire selection set,
369+
If during {ExecuteGroupedFieldSet()} a field with a non-null {fieldType} raises
370+
a _field error_ then that error must propagate to this entire selection set,
368371
either resolving to {null} if allowed or further propagated to a parent field.
369372

370373
If this occurs, any sibling fields which have not yet executed or have not yet
@@ -704,8 +707,9 @@ CompleteValue(fieldType, fields, result, variableValues):
704707
- Let {objectType} be {fieldType}.
705708
- Otherwise if {fieldType} is an Interface or Union type.
706709
- Let {objectType} be {ResolveAbstractType(fieldType, result)}.
707-
- Let {subSelectionSet} be the result of calling {MergeSelectionSets(fields)}.
708-
- Return the result of evaluating {ExecuteSelectionSet(subSelectionSet,
710+
- Let {groupedFieldSet} be the result of calling {CollectSubfields(objectType,
711+
fields, variableValues)}.
712+
- Return the result of evaluating {ExecuteGroupedFieldSet(groupedFieldSet,
709713
objectType, result, variableValues)} _normally_ (allowing for
710714
parallelization).
711715

@@ -752,9 +756,9 @@ ResolveAbstractType(abstractType, objectValue):
752756

753757
**Merging Selection Sets**
754758

755-
When more than one field of the same name is executed in parallel, the
756-
_selection set_ for each of the fields are merged together when completing the
757-
value in order to continue execution of the sub-selection sets.
759+
When more than one field of the same name is executed in parallel, during value
760+
completion their selection sets are collected together to produce a single
761+
grouped field set in order to continue execution of the sub-selection sets.
758762

759763
An example operation illustrating parallel fields with the same name with
760764
sub-selections.
@@ -773,14 +777,19 @@ sub-selections.
773777
After resolving the value for `me`, the selection sets are merged together so
774778
`firstName` and `lastName` can be resolved for one value.
775779

776-
MergeSelectionSets(fields):
780+
CollectSubfields(objectType, fields, variableValues):
777781

778-
- Let {selectionSet} be an empty list.
782+
- Let {groupedFieldSet} be an empty map.
779783
- For each {field} in {fields}:
780784
- Let {fieldSelectionSet} be the selection set of {field}.
781785
- If {fieldSelectionSet} is null or empty, continue to the next field.
782-
- Append all selections in {fieldSelectionSet} to {selectionSet}.
783-
- Return {selectionSet}.
786+
- Let {subGroupedFieldSet} be the result of {CollectFields(objectType,
787+
fieldSelectionSet, variableValues)}.
788+
- For each {subGroupedFieldSet} as {responseKey} and {subfields}:
789+
- Let {groupForResponseKey} be the list in {groupedFieldSet} for
790+
{responseKey}; if no such list exists, create it as an empty list.
791+
- Append all fields in {subfields} to {groupForResponseKey}.
792+
- Return {groupedFieldSet}.
784793

785794
### Handling Field Errors
786795

0 commit comments

Comments
 (0)