@@ -410,8 +410,9 @@ subsequentPayloads, asyncRecord):
410
410
411
411
- If {path} is not provided, initialize it to an empty list.
412
412
- If {subsequentPayloads} is not provided, initialize it to the empty set.
413
- - Let {groupedFieldSet} be the result of {CollectFields(objectType, objectValue,
414
- selectionSet, variableValues, path subsequentPayloads, asyncRecord)}.
413
+ - Let {groupedFieldSet} and {deferredGroupedFieldsList} be the result of
414
+ {CollectFields(objectType, objectValue, selectionSet, variableValues, path,
415
+ asyncRecord)}.
415
416
- Initialize {resultMap} to an empty ordered map.
416
417
- For each {groupedFieldSet} as {responseKey} and {fields}:
417
418
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
@@ -422,6 +423,10 @@ subsequentPayloads, asyncRecord):
422
423
- Let {responseValue} be {ExecuteField(objectType, objectValue, fieldType,
423
424
fields, variableValues, path, subsequentPayloads, asyncRecord)}.
424
425
- Set {responseValue} as the value for {responseKey} in {resultMap}.
426
+ - For each {deferredGroupFieldSet} and {label} in {deferredGroupedFieldsList}
427
+ - Call {ExecuteDeferredFragment(label, objectType, objectValue,
428
+ deferredGroupFieldSet, path, variableValues, asyncRecord,
429
+ subsequentPayloads)}
425
430
- Return {resultMap}.
426
431
427
432
Note: {resultMap} is ordered by which fields appear first in the operation. This
@@ -573,10 +578,12 @@ is maintained through execution, ensuring that fields appear in the executed
573
578
response in a stable and predictable order.
574
579
575
580
CollectFields(objectType, objectValue, selectionSet, variableValues, path,
576
- subsequentPayloads, asyncRecord, visitedFragments):
581
+ asyncRecord, visitedFragments, deferredGroupedFieldsList ):
577
582
578
583
- If {visitedFragments} is not provided, initialize it to the empty set.
579
584
- Initialize {groupedFields} to an empty ordered map of lists.
585
+ - If {deferredGroupedFieldsList} is not provided, initialize it to an empty
586
+ list.
580
587
- For each {selection} in {selectionSet}:
581
588
- If {selection} provides the directive ` @skip ` , let {skipDirective} be that
582
589
directive.
@@ -615,13 +622,17 @@ subsequentPayloads, asyncRecord, visitedFragments):
615
622
- If {deferDirective} is defined:
616
623
- Let {label} be the value or the variable to {deferDirective}'s {label}
617
624
argument.
618
- - Call {ExecuteDeferredFragment(label, objectType, objectValue,
619
- fragmentSelectionSet, path, variableValues, asyncRecord,
620
- subsequentPayloads)}.
625
+ - Let {deferredGroupedFields} be the result of calling
626
+ {CollectFields(objectType, objectValue, fragmentSelectionSet,
627
+ variableValues, path, asyncRecord, visitedFragments,
628
+ deferredGroupedFieldsList)}.
629
+ - Append a record containing {label} and {deferredGroupedFields} to
630
+ {deferredGroupedFieldsList}.
621
631
- Continue with the next {selection} in {selectionSet}.
622
632
- Let {fragmentGroupedFieldSet} be the result of calling
623
633
{CollectFields(objectType, objectValue, fragmentSelectionSet,
624
- variableValues, path, subsequentPayloads, asyncRecord, visitedFragments)}.
634
+ variableValues, path, asyncRecord, visitedFragments,
635
+ deferredGroupedFieldsList)}.
625
636
- For each {fragmentGroup} in {fragmentGroupedFieldSet}:
626
637
- Let {responseKey} be the response key shared by all fields in
627
638
{fragmentGroup}.
@@ -640,19 +651,24 @@ subsequentPayloads, asyncRecord, visitedFragments):
640
651
{variableValues} with the value {true}:
641
652
- Let {label} be the value or the variable to {deferDirective}'s {label}
642
653
argument.
643
- - Call {ExecuteDeferredFragment(label, objectType, objectValue,
644
- fragmentSelectionSet, path, asyncRecord, subsequentPayloads)}.
654
+ - Let {deferredGroupedFields} be the result of calling
655
+ {CollectFields(objectType, objectValue, fragmentSelectionSet,
656
+ variableValues, path, asyncRecord, visitedFragments,
657
+ deferredGroupedFieldsList)}.
658
+ - Append a record containing {label} and {deferredGroupedFields} to
659
+ {deferredGroupedFieldsList}.
645
660
- Continue with the next {selection} in {selectionSet}.
646
661
- Let {fragmentGroupedFieldSet} be the result of calling
647
662
{CollectFields(objectType, objectValue, fragmentSelectionSet,
648
- variableValues, path, subsequentPayloads, asyncRecord, visitedFragments)}.
663
+ variableValues, path, asyncRecord, visitedFragments,
664
+ deferredGroupedFieldsList)}.
649
665
- For each {fragmentGroup} in {fragmentGroupedFieldSet}:
650
666
- Let {responseKey} be the response key shared by all fields in
651
667
{fragmentGroup}.
652
668
- Let {groupForResponseKey} be the list in {groupedFields} for
653
669
{responseKey}; if no such list exists, create it as an empty list.
654
670
- Append all items in {fragmentGroup} to {groupForResponseKey}.
655
- - Return {groupedFields}.
671
+ - Return {groupedFields} and {deferredGroupedFieldsList} .
656
672
657
673
Note: The steps in {CollectFields()} evaluating the ` @skip ` and ` @include `
658
674
directives may be applied in either order since they apply commutatively.
@@ -686,22 +702,29 @@ All Async Payload Records are structures containing:
686
702
687
703
#### Execute Deferred Fragment
688
704
689
- ExecuteDeferredFragment(label, objectType, objectValue, fragmentSelectionSet ,
690
- path, variableValues, parentRecord, subsequentPayloads):
705
+ ExecuteDeferredFragment(label, objectType, objectValue, groupedFieldSet, path ,
706
+ variableValues, parentRecord, subsequentPayloads):
691
707
692
708
- Let {deferRecord} be an async payload record created from {label} and {path}.
693
709
- Initialize {errors} on {deferRecord} to an empty list.
694
710
- Let {dataExecution} be the asynchronous future value of:
695
711
- Let {payload} be an unordered map.
696
- - Let {data} be the result of {ExecuteSelectionSet(fragmentSelectionSet,
697
- objectType, objectValue, variableValues, path, subsequentPayloads,
698
- deferRecord)}.
712
+ - Initialize {resultMap} to an empty ordered map.
713
+ - For each {groupedFieldSet} as {responseKey} and {fields}:
714
+ - Let {fieldName} be the name of the first entry in {fields}. Note: This
715
+ value is unaffected if an alias is used.
716
+ - Let {fieldType} be the return type defined for the field {fieldName} of
717
+ {objectType}.
718
+ - If {fieldType} is defined:
719
+ - Let {responseValue} be {ExecuteField(objectType, objectValue, fieldType,
720
+ fields, variableValues, path, subsequentPayloads, asyncRecord)}.
721
+ - Set {responseValue} as the value for {responseKey} in {resultMap}.
699
722
- Append any encountered field errors to {errors}.
700
723
- If {parentRecord} is defined:
701
724
- Wait for the result of {dataExecution} on {parentRecord}.
702
725
- If {errors} is not empty:
703
726
- Add an entry to {payload} named ` errors ` with the value {errors}.
704
- - Add an entry to {payload} named ` data ` with the value {data }.
727
+ - Add an entry to {payload} named ` data ` with the value {resultMap }.
705
728
- Add an entry to {payload} named ` label ` with the value {label}.
706
729
- Add an entry to {payload} named ` path ` with the value {path}.
707
730
- Return {payload}.
0 commit comments