diff --git a/graphql_parser/lib/src/language/ast/operation_definition.dart b/graphql_parser/lib/src/language/ast/operation_definition.dart index e6abaf53..8334fb8b 100644 --- a/graphql_parser/lib/src/language/ast/operation_definition.dart +++ b/graphql_parser/lib/src/language/ast/operation_definition.dart @@ -26,7 +26,7 @@ class OperationDefinitionContext extends DefinitionContext { @override FileSpan get span { if (TYPE == null) return selectionSet.span; - var out = TYPE.span.expand(NAME.span); + var out = NAME == null ? TYPE.span : TYPE.span.expand(NAME.span); out = directives.fold(out, (o, d) => o.expand(d.span)); return out.expand(selectionSet.span); }