...
1 package graphb
2
3 import (
4 "fmt"
5 )
6
7 type nameType string
8
9 const (
10 operationName nameType = "operation name"
11 aliasName nameType = "alias name"
12 fieldName nameType = "field name"
13 argumentName nameType = "argument name"
14 )
15
16
17
18 type InvalidNameErr struct {
19 Type nameType
20 Name string
21 }
22
23 func (e InvalidNameErr) Error() string {
24 return fmt.Sprintf("'%s' is an invalid %s in GraphQL. A valid name matches /[_A-Za-z][_0-9A-Za-z]*/, see: http://facebook.github.io/graphql/October2016/#sec-Names", e.Name, e.Type)
25 }
26
27
28 type InvalidOperationTypeErr struct {
29 Type operationType
30 }
31
32 func (e InvalidOperationTypeErr) Error() string {
33 return fmt.Sprintf("'%s' is an invalid operation type in GraphQL. A valid type is one of 'query', 'mutation', 'subscription'", e.Type)
34 }
35
36
37 type NilFieldErr struct{}
38
39 func (e NilFieldErr) Error() string {
40 return "nil Field is not allowed. Please initialize a correct Field with NewField(...) function or Field{...} literal"
41 }
42
43
44 type CyclicFieldErr struct {
45 Field Field
46 }
47
48 func (e CyclicFieldErr) Error() string {
49 return fmt.Sprintf("Field %+v contains cyclic loop", e.Field)
50 }
51
52
53 type ArgumentTypeNotSupportedErr struct {
54 Value interface{}
55 }
56
57 func (e ArgumentTypeNotSupportedErr) Error() string {
58 return fmt.Sprintf("Argument %+v of Type %T is not supported", e.Value, e.Value)
59 }
60
View as plain text