visitOperationDefinitionNode method

  1. @override
List<GraphQLError>? visitOperationDefinitionNode(
  1. OperationDefinitionNode node
)

Implementation

@override
List<GraphQLError>? visitOperationDefinitionNode(
  OperationDefinitionNode node,
) {
  final name = node.name?.value;
  if (name == null && operationCount > 1) {
    return [
      GraphQLError(
        'This anonymous operation must be the only defined operation.',
        locations: GraphQLErrorLocation.firstFromNodes([
          node,
          node.selectionSet,
          node.selectionSet.selections.firstOrNull,
        ]),
        extensions: _loneAnonymousOperationSpec.extensions(),
      )
    ];
  }
}