...

Source file src/github.com/vektah/gqlparser/v2/validator/rules/lone_anonymous_operation.go

Documentation: github.com/vektah/gqlparser/v2/validator/rules

     1  package validator
     2  
     3  import (
     4  	"github.com/vektah/gqlparser/v2/ast"
     5  
     6  	//nolint:revive // Validator rules each use dot imports for convenience.
     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