Skip to content

Commit c9837a4

Browse files
committed
Change ExecuteSelectionSet to ExecuteGroupedFieldSet
1 parent b76671b commit c9837a4

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

spec/Section 6 -- Execution.md

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

327+
First, the selection set is turned into a grouped field set; then, we execute
328+
this grouped field set and return the resulting {data} and {errors}.
329+
327330
ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
328331
serial):
329332

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

338-
## Executing Selection Sets
343+
## Executing a Grouped Field Set
339344

340-
To execute a _selection set_, the object value being evaluated and the object
345+
To execute a grouped field set, the object value being evaluated and the object
341346
type need to be known, as well as whether it must be executed serially, or may
342347
be executed in parallel.
343348

344-
First, the selection set is turned into a grouped field set; then, each
345-
represented field in the grouped field set produces an entry into a response
346-
map.
349+
Each represented field in the grouped field set produces an entry into a
350+
response map.
347351

348-
ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
352+
ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
353+
variableValues):
349354

350-
- Let {groupedFieldSet} be the result of {CollectFields(objectType,
351-
selectionSet, variableValues)}.
352355
- Initialize {resultMap} to an empty ordered map.
353356
- For each {groupedFieldSet} as {responseKey} and {fields}:
354357
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
@@ -366,8 +369,8 @@ is explained in greater detail in the Field Collection section below.
366369

367370
**Errors and Non-Null Fields**
368371

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

373376
If this occurs, any sibling fields which have not yet executed or have not yet
@@ -707,8 +710,9 @@ CompleteValue(fieldType, fields, result, variableValues):
707710
- Let {objectType} be {fieldType}.
708711
- Otherwise if {fieldType} is an Interface or Union type.
709712
- Let {objectType} be {ResolveAbstractType(fieldType, result)}.
710-
- Let {subSelectionSet} be the result of calling {MergeSelectionSets(fields)}.
711-
- Return the result of evaluating {ExecuteSelectionSet(subSelectionSet,
713+
- Let {groupedFieldSet} be the result of calling {CollectSubfields(objectType,
714+
fields, variableValues)}.
715+
- Return the result of evaluating {ExecuteGroupedFieldSet(groupedFieldSet,
712716
objectType, result, variableValues)} _normally_ (allowing for
713717
parallelization).
714718

@@ -755,9 +759,10 @@ ResolveAbstractType(abstractType, objectValue):
755759

756760
**Merging Selection Sets**
757761

758-
When more than one field of the same name is executed in parallel, the
759-
_selection set_ for each of the fields are merged together when completing the
760-
value in order to continue execution of the sub-selection sets.
762+
When more than one field of the same name is executed in parallel, during value
763+
completion each related _selection set_ is collected together to produce a
764+
single grouped field set in order to continue execution of the sub-selection
765+
sets.
761766

762767
An example operation illustrating parallel fields with the same name with
763768
sub-selections.
@@ -776,14 +781,19 @@ sub-selections.
776781
After resolving the value for `me`, the selection sets are merged together so
777782
`firstName` and `lastName` can be resolved for one value.
778783

779-
MergeSelectionSets(fields):
784+
CollectSubfields(objectType, fields, variableValues):
780785

781-
- Let {selectionSet} be an empty list.
786+
- Let {groupedFieldSet} be an empty map.
782787
- For each {field} in {fields}:
783788
- Let {fieldSelectionSet} be the selection set of {field}.
784789
- If {fieldSelectionSet} is null or empty, continue to the next field.
785-
- Append all selections in {fieldSelectionSet} to {selectionSet}.
786-
- Return {selectionSet}.
790+
- Let {subGroupedFieldSet} be the result of {CollectFields(objectType,
791+
fieldSelectionSet, variableValues)}.
792+
- For each {subGroupedFieldSet} as {responseKey} and {subfields}:
793+
- Let {groupForResponseKey} be the list in {groupedFieldSet} for
794+
{responseKey}; if no such list exists, create it as an empty list.
795+
- Append all fields in {subfields} to {groupForResponseKey}.
796+
- Return {groupedFieldSet}.
787797

788798
### Handling Field Errors
789799

0 commit comments

Comments
 (0)