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