coerce variable values the same as other values

This commit is contained in:
Tobe O 2019-08-14 11:58:19 -04:00
parent 2ca155375b
commit 4e7972ca5c
2 changed files with 7 additions and 16 deletions

View file

@ -1,3 +1,9 @@
# 1.1.0
* Updates for `package:graphql_parser@1.2.0`.
* Now that variables are `InputValueContext` descendants, handle them the
same way as other values in `coerceArgumentValues`. TLDR - Removed
now-obsolete, variable-specific logic in `coerceArgumentValues`.
# 1.0.1 # 1.0.1
* Fix a bug where `globalVariables` were not being properly passed * Fix a bug where `globalVariables` were not being properly passed
to field resolvers. to field resolvers.

View file

@ -404,22 +404,7 @@ class GraphQL {
var argumentValue = argumentValues var argumentValue = argumentValues
.firstWhere((a) => a.name == argumentName, orElse: () => null); .firstWhere((a) => a.name == argumentName, orElse: () => null);
if (argumentValue?.value is VariableContext) { if (argumentValue == null) {
var variableName = (argumentValue.value as VariableContext).name;
var variableValue = variableValues[variableName];
if (variableValues.containsKey(variableName)) {
coercedValues[argumentName] = variableValue;
} else if (defaultValue != null || argumentDefinition.defaultsToNull) {
coercedValues[argumentName] = defaultValue;
} else if (argumentType is GraphQLNonNullableType) {
throw GraphQLException.fromSourceSpan(
'Missing value for argument "$argumentName" of field "$fieldName".',
argumentValue.value.span);
} else {
continue;
}
} else if (argumentValue == null) {
if (defaultValue != null || argumentDefinition.defaultsToNull) { if (defaultValue != null || argumentDefinition.defaultsToNull) {
coercedValues[argumentName] = defaultValue; coercedValues[argumentName] = defaultValue;
} else if (argumentType is GraphQLNonNullableType) { } else if (argumentType is GraphQLNonNullableType) {