Remove use of deprecated value members

This commit is contained in:
Tobe O 2019-08-14 10:59:18 -04:00
parent 02a816f5dd
commit 917477cb89
2 changed files with 30 additions and 27 deletions

View file

@ -55,7 +55,7 @@ class GraphQL {
GraphQLType convertType(TypeContext ctx) {
if (ctx.listType != null) {
return GraphQLListType(convertType(ctx.listType.type));
return GraphQLListType(convertType(ctx.listType.innerType));
} else if (ctx.typeName != null) {
switch (ctx.typeName.name) {
case 'Int':
@ -161,7 +161,8 @@ class GraphQL {
if (value == null) {
if (defaultValue != null) {
coercedValues[variableName] = defaultValue.value.value;
coercedValues[variableName] =
defaultValue.value.computeValue(variableValues);
} else if (!variableType.isNullable) {
throw GraphQLException.fromSourceSpan(
'Missing required variable "$variableName".',
@ -400,11 +401,11 @@ class GraphQL {
var argumentType = argumentDefinition.type;
var defaultValue = argumentDefinition.defaultValue;
var value = argumentValues.firstWhere((a) => a.name == argumentName,
orElse: () => null);
var argumentValue = argumentValues
.firstWhere((a) => a.name == argumentName, orElse: () => null);
if (value?.valueOrVariable?.variable != null) {
var variableName = value.valueOrVariable.variable.name;
if (argumentValue.value is VariableContext) {
var variableName = (argumentValue.value as VariableContext).name;
var variableValue = variableValues[variableName];
if (variableValues.containsKey(variableName)) {
@ -414,11 +415,11 @@ class GraphQL {
} else if (argumentType is GraphQLNonNullableType) {
throw GraphQLException.fromSourceSpan(
'Missing value for argument "$argumentName" of field "$fieldName".',
value.valueOrVariable.span);
argumentValue.value.span);
} else {
continue;
}
} else if (value == null) {
} else if (argumentValue == null) {
if (defaultValue != null || argumentDefinition.defaultsToNull) {
coercedValues[argumentName] = defaultValue;
} else if (argumentType is GraphQLNonNullableType) {
@ -430,7 +431,7 @@ class GraphQL {
} else {
try {
var validation = argumentType.validate(
fieldName, value.valueOrVariable.value.value);
fieldName, argumentValue.value.computeValue(variableValues));
if (!validation.successful) {
var errors = <GraphQLExceptionError>[
@ -438,7 +439,7 @@ class GraphQL {
'Type coercion error for value of argument "$argumentName" of field "$fieldName".',
locations: [
GraphExceptionErrorLocation.fromSourceLocation(
value.valueOrVariable.span.start)
argumentValue.value.span.start)
],
)
];
@ -449,7 +450,7 @@ class GraphQL {
error,
locations: [
GraphExceptionErrorLocation.fromSourceLocation(
value.valueOrVariable.span.start)
argumentValue.value.span.start)
],
),
);
@ -466,14 +467,14 @@ class GraphQL {
'Type coercion error for value of argument "$argumentName" of field "$fieldName".',
locations: [
GraphExceptionErrorLocation.fromSourceLocation(
value.valueOrVariable.span.start)
argumentValue.value.span.start)
],
),
GraphQLExceptionError(
e.message.toString(),
locations: [
GraphExceptionErrorLocation.fromSourceLocation(
value.valueOrVariable.span.start)
argumentValue.value.span.start)
],
),
]);
@ -699,26 +700,28 @@ class GraphQL {
SelectionContext selection, Map<String, dynamic> variableValues) {
if (selection.field == null) return null;
var directive = selection.field.directives.firstWhere((d) {
var vv = d.valueOrVariable;
if (vv.value != null) return vv.value.value == name;
return vv.variable.name == name;
var vv = d.value;
if (vv is VariableContext) {
return vv.name == name;
} else {
return vv.computeValue(variableValues) == name;
}
}, orElse: () => null);
if (directive == null) return null;
if (directive.argument?.name != argumentName) return null;
var vv = directive.argument.valueOrVariable;
if (vv.value != null) return vv.value.value;
var vname = vv.variable.name;
var vv = directive.argument.value;
if (vv is VariableContext) {
var vname = vv.name;
if (!variableValues.containsKey(vname)) {
throw GraphQLException.fromSourceSpan(
'Unknown variable: "$vname"', vv.span);
}
return variableValues[vname];
}
return vv.computeValue(variableValues);
}
bool doesFragmentTypeApply(
GraphQLObjectType objectType, TypeConditionContext fragmentType) {

View file

@ -382,7 +382,7 @@ GraphQLObjectType _reflectDirectiveType() {
field(
'name',
graphQLString.nonNullable(),
resolve: (obj, _) => (obj as DirectiveContext).NAME.span.text,
resolve: (obj, _) => (obj as DirectiveContext).nameToken.span.text,
),
field(
'description',