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