diff --git a/graphql_parser/lib/src/language/ast/fragment_definition.dart b/graphql_parser/lib/src/language/ast/fragment_definition.dart index 23787e07..00204bf2 100644 --- a/graphql_parser/lib/src/language/ast/fragment_definition.dart +++ b/graphql_parser/lib/src/language/ast/fragment_definition.dart @@ -5,22 +5,43 @@ import 'package:source_span/source_span.dart'; import 'selection_set.dart'; import 'type_condition.dart'; +/// A GraphQL query fragment definition. class FragmentDefinitionContext extends ExecutableDefinitionContext { - final Token FRAGMENT, NAME, ON; + /// The source tokens. + final Token fragmentToken, nameToken, onToken; + + /// The type to which this fragment applies. final TypeConditionContext typeCondition; + + /// Any directives on the fragment. final List directives = []; + + /// The selections to apply when the [typeCondition] is met. final SelectionSetContext selectionSet; - String get name => NAME.text; + /// The [String] value of the [nameToken]. + String get name => nameToken.text; - FragmentDefinitionContext( - this.FRAGMENT, this.NAME, this.ON, this.typeCondition, this.selectionSet); + FragmentDefinitionContext(this.fragmentToken, this.nameToken, this.onToken, + this.typeCondition, this.selectionSet); + + /// Use [fragmentToken] instead. + @deprecated + Token get FRAGMENT => fragmentToken; + + /// Use [nameToken] instead. + @deprecated + Token get NAME => nameToken; + + /// Use [onToken] instead. + @deprecated + Token get ON => onToken; @override FileSpan get span { - var out = FRAGMENT.span - .expand(NAME.span) - .expand(ON.span) + var out = fragmentToken.span + .expand(nameToken.span) + .expand(onToken.span) .expand(typeCondition.span); out = directives.fold(out, (o, d) => o.expand(d.span)); return out.expand(selectionSet.span);