You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
672 B
35 lines
672 B
package api
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// A QueryError is a GraphQL error.
|
|
type QueryError struct {
|
|
Message string `json:"message"`
|
|
Path []string `json:"path"`
|
|
}
|
|
|
|
func (err QueryError) Error() string {
|
|
return fmt.Sprintf("GraphQL: %s: %s", strings.Join(err.Path, "."), err.Message)
|
|
}
|
|
|
|
func (err QueryError) String() string {
|
|
return err.Error()
|
|
}
|
|
|
|
// QueryErrorList is a list of query errors
|
|
type QueryErrorList []QueryError
|
|
|
|
func (errs QueryErrorList) Error() string {
|
|
if len(errs) == 1 {
|
|
return errs[0].Error()
|
|
}
|
|
|
|
return fmt.Sprintf("%s (+%d others)", errs[0].Error(), len(errs)-1)
|
|
}
|
|
|
|
func (errs QueryErrorList) String() string {
|
|
return errs.Error()
|
|
}
|