@@ -340,11 +340,12 @@ ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
340
340
- For each {groupedFieldSet} as {responseKey} and {fields}:
341
341
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
342
342
is unaffected if an alias is used.
343
+ - Let {fragmentVariableValues} be the fragment-variables value of the first entry in {fields}.
343
344
- Let {fieldType} be the return type defined for the field {fieldName} of
344
345
{objectType}.
345
346
- If {fieldType} is defined:
346
347
- Let {responseValue} be {ExecuteField(objectType, objectValue, fieldType,
347
- fields, variableValues)}.
348
+ fields, variableValues, fragmentVariableValues )}.
348
349
- Set {responseValue} as the value for {responseKey} in {resultMap}.
349
350
- Return {resultMap}.
350
351
@@ -492,27 +493,27 @@ The depth-first-search order of the field groups produced by {CollectFields()}
492
493
is maintained through execution, ensuring that fields appear in the executed
493
494
response in a stable and predictable order.
494
495
495
- CollectFields(objectType, selectionSet, variableValues, visitedFragments):
496
+ CollectFields(objectType, selectionSet, variableValues, visitedFragments, localVariableValues ):
496
497
497
498
- If {visitedFragments} is not provided, initialize it to the empty set.
498
499
- Initialize {groupedFields} to an empty ordered map of lists.
499
500
- For each {selection} in {selectionSet}:
500
501
- If {selection} provides the directive ` @skip ` , let {skipDirective} be that
501
502
directive.
502
503
- If {skipDirective}'s {if} argument is {true} or is a variable in
503
- {variableValues} with the value {true}, continue with the next {selection}
504
+ {localVariableValues} or { variableValues} with the value {true}, continue with the next {selection}
504
505
in {selectionSet}.
505
506
- If {selection} provides the directive ` @include ` , let {includeDirective} be
506
507
that directive.
507
508
- If {includeDirective}'s {if} argument is not {true} and is not a variable
508
- in {variableValues} with the value {true}, continue with the next
509
+ in {localVariableValues} or { variableValues} with the value {true}, continue with the next
509
510
{selection} in {selectionSet}.
510
511
- If {selection} is a {Field}:
511
512
- Let {responseKey} be the response key of {selection} (the alias if
512
513
defined, otherwise the field name).
513
514
- Let {groupForResponseKey} be the list in {groupedFields} for
514
515
{responseKey}; if no such list exists, create it as an empty list.
515
- - Append {selection} to the {groupForResponseKey}.
516
+ - Append {selection} and {localVariableValues} to the {groupForResponseKey}.
516
517
- If {selection} is a {FragmentSpread}:
517
518
- Let {fragmentSpreadName} be the name of {selection}.
518
519
- Let {fragment} be the Fragment in the current Document whose name is
@@ -525,10 +526,8 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
525
526
- Let {fragmentType} be the type condition on {fragment}.
526
527
- If {DoesFragmentTypeApply(objectType, fragmentType)} is {false}, continue
527
528
with the next {selection} in {selectionSet}.
528
- - Let {fragmentWithArgumentSubstitutions} be the result of calling
529
- {SubstituteFragmentArguments(fragment, arguments)}.
530
- - Let {fragmentSelectionSet} be the top-level selection set of
531
- {fragmentWithArgumentSubstitutions}.
529
+ - Let {localVariableValues} be the result of calling
530
+ {getArgumentValuesFromSpread(fragmentSpread, schema, fragmentDefinition.variableDefinitions, variableValues, localVariableValues)}.
532
531
- Let {fragmentGroupedFieldSet} be the result of calling
533
532
{CollectFields(objectType, fragmentSelectionSet, variableValues,
534
533
visitedFragments)}.
@@ -567,26 +566,25 @@ DoesFragmentTypeApply(objectType, fragmentType):
567
566
- If {objectType} is a possible type of {fragmentType}, return {true}
568
567
otherwise return {false}.
569
568
570
- SubstituteFragmentArguments(fragment, arguments ):
569
+ getArgumentValuesFromSpread(fragmentSpread, schema, fragmentDefinitionVariableDefinitions, variableValues, fragmentArgumentValues ):
571
570
572
- - Let {variablesToSubstitute } be initialized to an empty map .
573
- - For each {variableDefinition} in {fragment }:
571
+ - Let {coercedValues } be an empty unordered Map .
572
+ - For each {variableDefinition} in {fragmentDefinitionVariableDefinitions }:
574
573
- Let {variableName} be the name of {variableDefinition}.
575
- - If {variableName} is a key in {arguments}:
576
- - Let {argumentValue} be the value of {variableName} in {arguments}.
577
- - Add {argumentValue} to {variablesToSubstitute} at key {variableName}.
578
- - Otherwise if {variableDefinition} has a default value {defaultValue}:
579
- - Add {defaultValue} to {variablesToSubstitute} at key {variableName}.
580
- - Otherwise:
581
- - Set the key {variableName} in {variableToSubstitute} to a value indicating
582
- the variable is unset.
583
- - Let {substitutedFragment} be a copy of {fragment} where:
584
- - For each {variable} in the selection set of {fragment}:
585
- - Let {variableUsageName} be the name of {variable}.
586
- - If {variableUsageName} is in {variablesToSubstitute}:
587
- - Replace {variable} with the value of {variableUsageName} in
588
- {variablesToSubstitute}.
589
- - Return {substitutedFragment}.
574
+ - Let {variableType} be the type of {variableDefinition}.
575
+ - Let {defaultValue} be the default value for {variableDefinition}.
576
+ - Let {argumentNode} be the node provided in the fragment-spread for {variableName}
577
+ - If {argumentNode} isn't present or is null
578
+ - If {defaultValue} exists
579
+ - Add an entry to {coercedValues} named {argumentName} with the value
580
+ {defaultValue}.
581
+ - If {variableType} is not-nullable raise a field-error
582
+ - Let {hasValue} be {true} if {fragmentArgumentValues} or {variableValues} provides a value for the name
583
+ {variableName}.
584
+ - If {variableType} is not-nullable and {hasValue} is {false} raise a field-error
585
+ - Add an entry to {coercedValues} named {argumentName} with the value
586
+ found in {variableValues} or {fragmentArgumentValues}.
587
+ - Return {coercedValues}.
590
588
591
589
Note: The steps in {CollectFields()} evaluating the ` @skip ` and ` @include `
592
590
directives may be applied in either order since they apply commutatively.
@@ -605,12 +603,12 @@ coerces any provided argument values, then resolves a value for the field, and
605
603
finally completes that value either by recursively executing another selection
606
604
set or coercing a scalar value.
607
605
608
- ExecuteField(objectType, objectValue, fieldType, fields, variableValues):
606
+ ExecuteField(objectType, objectValue, fieldType, fields, variableValues, fragmentVariableValues ):
609
607
610
608
- Let {field} be the first entry in {fields}.
611
609
- Let {fieldName} be the field name of {field}.
612
610
- Let {argumentValues} be the result of {CoerceFieldArgumentValues(objectType,
613
- field, variableValues)}.
611
+ field, variableValues, fragmentVariableValues)}
614
612
- Let {resolvedValue} be {ResolveFieldValue(objectType, objectValue, fieldName,
615
613
argumentValues)}.
616
614
- Return the result of {CompleteValue(fieldType, fields, resolvedValue,
@@ -625,16 +623,16 @@ the type system to have a specific input type.
625
623
At each argument position in an operation may be a literal {Value}, or a
626
624
{Variable} to be provided at runtime.
627
625
628
- CoerceFieldArgumentValues(objectType, field, variableValues):
626
+ CoerceFieldArgumentValues(objectType, field, variableValues, fragmentVariableValues ):
629
627
630
628
- Let {argumentValues} be the argument values provided in {field}.
631
629
- Let {fieldName} be the name of {field}.
632
630
- Let {argumentDefinitions} be the arguments defined by {objectType} for the
633
631
field named {fieldName}.
634
632
- Return {CoerceArgumentValues(argumentDefinitions, argumentValues,
635
- variableValues)}
633
+ variableValues, fragmentVariableValues )}
636
634
637
- CoerceArgumentValues(argumentDefinitions, argumentValues, variableValues):
635
+ CoerceArgumentValues(argumentDefinitions, argumentValues, variableValues, fragmentVariableValues ):
638
636
639
637
- For each {argumentDefinition} in {argumentDefinitions}:
640
638
- Let {argumentName} be the name of {argumentDefinition}.
@@ -646,6 +644,10 @@ CoerceArgumentValues(argumentDefinitions, argumentValues, variableValues):
646
644
{argumentName}.
647
645
- If {argumentValue} is a {Variable}:
648
646
- Let {variableName} be the name of {argumentValue}.
647
+ - Let {hasValue} be {true} if {fragmentVariableValues} provides a value for the name
648
+ {variableName}.
649
+ - Let {value} be the value provided in {fragmentVariableValues} for the name
650
+ {variableName}.
649
651
- Let {hasValue} be {true} if {variableValues} provides a value for the name
650
652
{variableName}.
651
653
- Let {value} be the value provided in {variableValues} for the name
0 commit comments