@@ -83,24 +83,19 @@ def get_variable_values(
83
83
)
84
84
)
85
85
elif has_value :
86
- if value is None :
87
- # If the explicit value `None` was provided, an entry in the
88
- # coerced values must exist as the value `None`.
89
- coerced_values [var_name ] = None
86
+ # Otherwise, a non-null value was provided, coerce it to the expected
87
+ # type or report an error if coercion fails.
88
+ coerced = coerce_value (value , var_type , var_def_node )
89
+ coercion_errors = coerced .errors
90
+ if coercion_errors :
91
+ for error in coercion_errors :
92
+ error .message = (
93
+ f"Variable '${ var_name } ' got invalid"
94
+ f" value { inspect (value )} ; { error .message } "
95
+ )
96
+ errors .extend (coercion_errors )
90
97
else :
91
- # Otherwise, a non-null value was provided, coerce it to the
92
- # expected type or report an error if coercion fails.
93
- coerced = coerce_value (value , var_type , var_def_node )
94
- coercion_errors = coerced .errors
95
- if coercion_errors :
96
- for error in coercion_errors :
97
- error .message = (
98
- f"Variable '${ var_name } ' got invalid"
99
- f" value { inspect (value )} ; { error .message } "
100
- )
101
- errors .extend (coercion_errors )
102
- else :
103
- coerced_values [var_name ] = coerced .value
98
+ coerced_values [var_name ] = coerced .value
104
99
return (
105
100
CoercedVariableValues (errors , None )
106
101
if errors
@@ -164,31 +159,17 @@ def get_argument_values(
164
159
node ,
165
160
)
166
161
elif has_value :
167
- if isinstance (argument_node .value , NullValueNode ):
168
- # If the explicit value `None` was provided, an entry in the coerced
169
- # values must exist as the value `None`.
170
- coerced_values [arg_def .out_name or name ] = None
171
- elif isinstance (argument_node .value , VariableNode ):
172
- variable_name = argument_node .value .name .value
173
- # Note: This Does no further checking that this variable is correct.
174
- # This assumes that this query has been validated and the variable
175
- # usage here is of the correct type.
176
- coerced_values [arg_def .out_name or name ] = variable_values [
177
- variable_name
178
- ]
179
- else :
180
- value_node = argument_node .value
181
- coerced_value = value_from_ast (value_node , arg_type , variable_values )
182
- if coerced_value is INVALID :
183
- # Note: `values_of_correct_type` validation should catch this before
184
- # execution. This is a runtime check to ensure execution does not
185
- # continue with an invalid argument value.
186
- raise GraphQLError (
187
- f"Argument '{ name } '"
188
- f" has invalid value { print_ast (value_node )} ." ,
189
- argument_node .value ,
190
- )
191
- coerced_values [arg_def .out_name or name ] = coerced_value
162
+ value_node = argument_node .value
163
+ coerced_value = value_from_ast (value_node , arg_type , variable_values )
164
+ if coerced_value is INVALID :
165
+ # Note: `values_of_correct_type` validation should catch this before
166
+ # execution. This is a runtime check to ensure execution does not
167
+ # continue with an invalid argument value.
168
+ raise GraphQLError (
169
+ f"Argument '{ name } '" f" has invalid value { print_ast (value_node )} ." ,
170
+ argument_node .value ,
171
+ )
172
+ coerced_values [arg_def .out_name or name ] = coerced_value
192
173
return coerced_values
193
174
194
175
0 commit comments