@@ -104,29 +104,17 @@ CoerceVariableValues(schema, operation, variableValues):
104
104
- Let {variableName} be the name of {variableDefinition}.
105
105
- Let {variableType} be the expected type of {variableDefinition}.
106
106
- Assert: {IsInputType(variableType)} must be {true}.
107
- - Let {defaultValue} be the default value for {variableDefinition}.
108
- - Let {hasValue } be {true} if {variableValues} provides a value for the name
109
- {variableName} .
110
- - Let {value} be the value provided in {variableValues} for the name
111
- {variableName }.
112
- - If {hasValue} is not {true} and {defaultValue} exists (including {null}) :
107
+ - If {variableValues} has an entry named {variableName}, let {value} be its value:
108
+ - Let {coercedValue } be the result of coercing { value} according to the
109
+ input coercion rules of {variableType}, or raise a _ request error _ .
110
+ - Add an entry to {coercedValues} named {variableName} with the value
111
+ {coercedValue }.
112
+ - Otherwise if {variableDefinition} has a default value, let it be {defaultValue} :
113
113
- Let {coercedDefaultValue} be the result of coercing {defaultValue}
114
- according to the input coercion rules of {variableType}.
114
+ according to the input coercion rules of {variableType}, or raise a _ request error _ .
115
115
- Add an entry to {coercedValues} named {variableName} with the value
116
116
{coercedDefaultValue}.
117
- - Otherwise if {variableType} is a Non-Nullable type, and either {hasValue} is
118
- not {true} or {value} is {null}, raise a _ request error_ .
119
- - Otherwise if {hasValue} is {true}:
120
- - If {value} is {null}:
121
- - Add an entry to {coercedValues} named {variableName} with the value
122
- {null}.
123
- - Otherwise:
124
- - If {value} cannot be coerced according to the input coercion rules of
125
- {variableType}, raise a _ request error_ .
126
- - Let {coercedValue} be the result of coercing {value} according to the
127
- input coercion rules of {variableType}.
128
- - Add an entry to {coercedValues} named {variableName} with the value
129
- {coercedValue}.
117
+ - Otherwise if {variableType} is a Non-Nullable type, raise a _ request error_ .
130
118
- Return {coercedValues}.
131
119
132
120
Note: This algorithm is very similar to {CoerceArgumentValues()}.
@@ -742,46 +730,30 @@ At each argument position in an operation may be a literal {Value}, or a
742
730
CoerceArgumentValues(objectType, field, variableValues):
743
731
744
732
- Let {coercedValues} be an empty unordered Map.
745
- - Let {argumentValues } be the argument values provided in {field}.
733
+ - Let {arguments } be the {Arguments} provided in {field}.
746
734
- Let {fieldName} be the name of {field}.
747
735
- Let {argumentDefinitions} be the arguments defined by {objectType} for the
748
736
field named {fieldName}.
749
737
- For each {argumentDefinition} in {argumentDefinitions}:
750
738
- Let {argumentName} be the name of {argumentDefinition}.
751
739
- Let {argumentType} be the expected type of {argumentDefinition}.
752
- - Let {defaultValue} be the default value for {argumentDefinition}.
753
- - Let {hasValue} be {true} if {argumentValues} provides a value for the name
754
- {argumentName}.
755
- - Let {argumentValue} be the value provided in {argumentValues} for the name
756
- {argumentName}.
757
- - If {argumentValue} is a {Variable}:
758
- - Let {variableName} be the name of {argumentValue}.
759
- - Let {hasValue} be {true} if {variableValues} provides a value for the name
760
- {variableName}.
761
- - Let {value} be the value provided in {variableValues} for the name
762
- {variableName}.
763
- - Otherwise, let {value} be {argumentValue}.
764
- - If {hasValue} is not {true} and {defaultValue} exists (including {null}):
765
- - Let {coercedDefaultValue} be the result of coercing {defaultValue}
766
- according to the input coercion rules of {argumentType}.
767
- - Add an entry to {coercedValues} named {argumentName} with the value
768
- {coercedDefaultValue}.
769
- - Otherwise if {argumentType} is a Non-Nullable type, and either {hasValue} is
770
- not {true} or {value} is {null}, raise an _ execution error_ .
771
- - Otherwise if {hasValue} is {true}:
772
- - If {value} is {null}:
773
- - Add an entry to {coercedValues} named {argumentName} with the value
774
- {null}.
775
- - Otherwise, if {argumentValue} is a {Variable}:
776
- - Add an entry to {coercedValues} named {argumentName} with the value
777
- {value}.
740
+ - Assert: {IsInputType(argumentType)} must be {true}.
741
+ - If {arguments} has an {Argument} with name {argumentName}, let {argumentValue} be its {Value}:
742
+ - If {argumentValue} is a {Variable}, let {variableName} be its name:
743
+ - If {variableValues} has an entry named {variableName}, let {variableValue} be its value:
744
+ - Add an entry to {coercedValues} named {argumentName} with the value {value}.
745
+ - Otherwise if {argumentType} is a Non-Nullable type, raise a _ execution error_ .
778
746
- Otherwise:
779
- - If {value} cannot be coerced according to the input coercion rules of
780
- {argumentType}, raise an _ execution error_ .
781
747
- Let {coercedValue} be the result of coercing {value} according to the
782
- input coercion rules of {argumentType}.
748
+ input coercion rules of {argumentType}, or raise a _ execution error _ .
783
749
- Add an entry to {coercedValues} named {argumentName} with the value
784
750
{coercedValue}.
751
+ - Otherwise if {argumentDefinition} has a default value, let it be {defaultValue}:
752
+ - Let {coercedDefaultValue} be the result of coercing {defaultValue}
753
+ according to the input coercion rules of {argumentType}, or raise a _ execution error_ .
754
+ - Add an entry to {coercedValues} named {argumentName} with the value
755
+ {coercedDefaultValue}.
756
+ - Otherwise if {argumentType} is a Non-Nullable type, raise a _ execution error_ .
785
757
- Return {coercedValues}.
786
758
787
759
Any _ request error_ raised as a result of input coercion during
0 commit comments