protected override ISyntaxVisitorAction Enter( DocumentNode node, IDocumentValidatorContext context) { bool hasAnonymousOp = false; int opCount = 0; OperationDefinitionNode?anonymousOp = null; context.Names.Clear(); for (int i = 0; i < node.Definitions.Count; i++) { IDefinitionNode definition = node.Definitions[i]; if (definition.Kind == SyntaxKind.OperationDefinition) { opCount++; var operation = (OperationDefinitionNode)definition; if (operation.Name is null) { hasAnonymousOp = true; anonymousOp = operation; } else if (!context.Names.Add(operation.Name.Value)) { context.Errors.Add(context.OperationNameNotUnique( operation, operation.Name.Value)); } } } if (hasAnonymousOp && opCount > 1) { context.Errors.Add(context.OperationAnonymousMoreThanOne(anonymousOp !, opCount)); } return(Continue); }