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) {
    return null;
  }
  final prev = operations[name];
  if (prev != null) {
    return [
      GraphQLError(
        'There can be only one operation named "$name".',
        locations: [
          GraphQLErrorLocation.fromSourceLocation(prev.name!.span!.start),
          GraphQLErrorLocation.fromSourceLocation(node.name!.span!.start),
        ],
        extensions: _uniqueOperationNamesSpec.extensions(),
      )
    ];
  } else {
    operations[name] = node;
  }
  // return false;
}