diff --git a/graphql_parser/lib/src/language/ast/argument.dart b/graphql_parser/lib/src/language/ast/argument.dart index 3a85a067..6639874a 100644 --- a/graphql_parser/lib/src/language/ast/argument.dart +++ b/graphql_parser/lib/src/language/ast/argument.dart @@ -1,17 +1,20 @@ import 'package:source_span/source_span.dart'; import '../token.dart'; import 'node.dart'; -import 'value_or_variable.dart'; +import 'input_value.dart'; class ArgumentContext extends Node { final Token NAME, COLON; - final ValueOrVariableContext valueOrVariable; + final InputValueContext value; - ArgumentContext(this.NAME, this.COLON, this.valueOrVariable); + ArgumentContext(this.NAME, this.COLON, this.value); + + /// Use [value] instead. + @deprecated + InputValueContext get valueOrVariable => value; String get name => NAME.text; @override - FileSpan get span => - NAME.span.expand(COLON.span).expand(valueOrVariable.span); + FileSpan get span => NAME.span.expand(COLON.span).expand(value.span); } diff --git a/graphql_parser/lib/src/language/ast/constant.dart b/graphql_parser/lib/src/language/ast/constant.dart index 3338a83d..fff707cf 100644 --- a/graphql_parser/lib/src/language/ast/constant.dart +++ b/graphql_parser/lib/src/language/ast/constant.dart @@ -2,6 +2,7 @@ import 'node.dart'; abstract class ConstantContext extends Node { T get value; + T computeValue(Map variables) => value; } /// Use [ConstantContext] instead. This class remains solely for backwards compatibility. diff --git a/graphql_parser/lib/src/language/ast/input_value.dart b/graphql_parser/lib/src/language/ast/input_value.dart index 238fbec0..103c07f4 100644 --- a/graphql_parser/lib/src/language/ast/input_value.dart +++ b/graphql_parser/lib/src/language/ast/input_value.dart @@ -13,4 +13,7 @@ class InputValueContext extends Node { @override FileSpan get span => constant?.span ?? variable.span; + + Object computeValue(Map variables) => + constant?.computeValue(variables) ?? variable?.computeValue(variables); } diff --git a/graphql_parser/lib/src/language/ast/variable.dart b/graphql_parser/lib/src/language/ast/variable.dart index 71e7ab56..b1c356b4 100644 --- a/graphql_parser/lib/src/language/ast/variable.dart +++ b/graphql_parser/lib/src/language/ast/variable.dart @@ -11,5 +11,7 @@ class VariableContext extends Node { @override FileSpan get span => DOLLAR.span.expand(NAME.span); + + Object computeValue(Map variables) => variables[name]; // new FileSpan(DOLLAR?.span?.start, NAME?.span?.end, toSource()); }