@@ -324,31 +324,34 @@ Executing the root selection set works similarly for queries (parallel),
324
324
mutations (serial), and subscriptions (where it is executed for each event in
325
325
the underlying Source Stream).
326
326
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
+
327
330
ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
328
331
serial):
329
332
330
333
- 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,
332
337
objectType, initialValue, variableValues)} _ serially_ if {serial} is {true},
333
338
_ normally_ (allowing parallelization) otherwise.
334
339
- Let {errors} be the list of all _ field error_ raised while executing the
335
340
selection set.
336
341
- Return an unordered map containing {data} and {errors}.
337
342
338
- ## Executing Selection Sets
343
+ ## Executing a Grouped Field Set
339
344
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
341
346
type need to be known, as well as whether it must be executed serially, or may
342
347
be executed in parallel.
343
348
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.
347
351
348
- ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
352
+ ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
353
+ variableValues):
349
354
350
- - Let {groupedFieldSet} be the result of {CollectFields(objectType,
351
- selectionSet, variableValues)}.
352
355
- Initialize {resultMap} to an empty ordered map.
353
356
- For each {groupedFieldSet} as {responseKey} and {fields}:
354
357
- 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.
366
369
367
370
** Errors and Non-Null Fields**
368
371
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,
371
374
either resolving to {null} if allowed or further propagated to a parent field.
372
375
373
376
If this occurs, any sibling fields which have not yet executed or have not yet
@@ -707,8 +710,9 @@ CompleteValue(fieldType, fields, result, variableValues):
707
710
- Let {objectType} be {fieldType}.
708
711
- Otherwise if {fieldType} is an Interface or Union type.
709
712
- 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,
712
716
objectType, result, variableValues)} _ normally_ (allowing for
713
717
parallelization).
714
718
@@ -755,9 +759,10 @@ ResolveAbstractType(abstractType, objectValue):
755
759
756
760
** Merging Selection Sets**
757
761
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.
761
766
762
767
An example operation illustrating parallel fields with the same name with
763
768
sub-selections.
@@ -776,14 +781,19 @@ sub-selections.
776
781
After resolving the value for ` me ` , the selection sets are merged together so
777
782
` firstName ` and ` lastName ` can be resolved for one value.
778
783
779
- MergeSelectionSets( fields):
784
+ CollectSubfields(objectType, fields, variableValues ):
780
785
781
- - Let {selectionSet } be an empty list .
786
+ - Let {groupedFieldSet } be an empty map .
782
787
- For each {field} in {fields}:
783
788
- Let {fieldSelectionSet} be the selection set of {field}.
784
789
- 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}.
787
797
788
798
### Handling Field Errors
789
799
0 commit comments