@@ -321,31 +321,34 @@ Executing the root selection set works similarly for queries (parallel),
321
321
mutations (serial), and subscriptions (where it is executed for each event in
322
322
the underlying Source Stream).
323
323
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
+
324
327
ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
325
328
serial):
326
329
327
330
- 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,
329
334
objectType, initialValue, variableValues)} _ serially_ if {serial} is {true},
330
335
_ normally_ (allowing parallelization) otherwise.
331
336
- Let {errors} be the list of all _ field error_ raised while executing the
332
337
selection set.
333
338
- Return an unordered map containing {data} and {errors}.
334
339
335
- ## Executing Selection Sets
340
+ ## Executing a Grouped Field Set
336
341
337
- To execute a selection set, the object value being evaluated and the object type
338
- need to be known, as well as whether it must be executed serially, or may be
339
- executed in parallel.
342
+ To execute a grouped field set, the object value being evaluated and the object
343
+ type need to be known, as well as whether it must be executed serially, or may
344
+ be executed in parallel.
340
345
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.
344
348
345
- ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
349
+ ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
350
+ variableValues):
346
351
347
- - Let {groupedFieldSet} be the result of {CollectFields(objectType,
348
- selectionSet, variableValues)}.
349
352
- Initialize {resultMap} to an empty ordered map.
350
353
- For each {groupedFieldSet} as {responseKey} and {fields}:
351
354
- 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.
363
366
364
367
** Errors and Non-Null Fields**
365
368
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,
368
371
either resolving to {null} if allowed or further propagated to a parent field.
369
372
370
373
If this occurs, any sibling fields which have not yet executed or have not yet
@@ -702,8 +705,9 @@ CompleteValue(fieldType, fields, result, variableValues):
702
705
- Let {objectType} be {fieldType}.
703
706
- Otherwise if {fieldType} is an Interface or Union type.
704
707
- Let {objectType} be {ResolveAbstractType(fieldType, result)}.
705
- - Let {subSelectionSet} be the result of calling {MergeSelectionSets(fields)}.
706
- - Return the result of evaluating {ExecuteSelectionSet(subSelectionSet,
708
+ - Let {groupedFieldSet} be the result of calling {CollectSubfields(objectType,
709
+ fields, variableValues)}.
710
+ - Return the result of evaluating {ExecuteGroupedFieldSet(groupedFieldSet,
707
711
objectType, result, variableValues)} _ normally_ (allowing for
708
712
parallelization).
709
713
@@ -750,9 +754,9 @@ ResolveAbstractType(abstractType, objectValue):
750
754
751
755
** Merging Selection Sets**
752
756
753
- When more than one field of the same name is executed in parallel, their
754
- selection sets are merged together when completing the value in order to
755
- continue execution of the sub-selection sets.
757
+ When more than one field of the same name is executed in parallel, during value
758
+ completion their selection sets are collected together to produce a single
759
+ grouped field set in order to continue execution of the sub-selection sets.
756
760
757
761
An example operation illustrating parallel fields with the same name with
758
762
sub-selections.
@@ -771,14 +775,19 @@ sub-selections.
771
775
After resolving the value for ` me ` , the selection sets are merged together so
772
776
` firstName ` and ` lastName ` can be resolved for one value.
773
777
774
- MergeSelectionSets( fields):
778
+ CollectSubfields(objectType, fields, variableValues ):
775
779
776
- - Let {selectionSet } be an empty list .
780
+ - Let {groupedFieldSet } be an empty map .
777
781
- For each {field} in {fields}:
778
782
- Let {fieldSelectionSet} be the selection set of {field}.
779
783
- If {fieldSelectionSet} is null or empty, continue to the next field.
780
- - Append all selections in {fieldSelectionSet} to {selectionSet}.
781
- - Return {selectionSet}.
784
+ - Let {subGroupedFieldSet} be the result of {CollectFields(objectType,
785
+ fieldSelectionSet, variableValues)}.
786
+ - For each {subGroupedFieldSet} as {responseKey} and {subfields}:
787
+ - Let {groupForResponseKey} be the list in {groupedFieldSet} for
788
+ {responseKey}; if no such list exists, create it as an empty list.
789
+ - Append all fields in {subfields} to {groupForResponseKey}.
790
+ - Return {groupedFieldSet}.
782
791
783
792
### Handling Field Errors
784
793
0 commit comments