...
1 package validator
2
3 import (
4 "github.com/vektah/gqlparser/v2/ast"
5
6
7 . "github.com/vektah/gqlparser/v2/validator"
8 )
9
10 func init() {
11 AddRule("LoneAnonymousOperation", func(observers *Events, addError AddErrFunc) {
12 observers.OnOperation(func(walker *Walker, operation *ast.OperationDefinition) {
13 if operation.Name == "" && len(walker.Document.Operations) > 1 {
14 addError(
15 Message(`This anonymous operation must be the only defined operation.`),
16 At(operation.Position),
17 )
18 }
19 })
20 })
21 }
22
View as plain text