...
1
2
3 package models
4
5 import (
6 "fmt"
7 "io"
8 "strconv"
9 )
10
11 type DateFilter struct {
12 Value string `json:"value"`
13 Timezone *string `json:"timezone,omitempty"`
14 Op *DateFilterOp `json:"op,omitempty"`
15 }
16
17 type ListCoercion struct {
18 EnumVal []*ErrorType `json:"enumVal,omitempty"`
19 StrVal []*string `json:"strVal,omitempty"`
20 IntVal []*int `json:"intVal,omitempty"`
21 ScalarVal []map[string]interface{} `json:"scalarVal,omitempty"`
22 }
23
24 type Query struct {
25 }
26
27 type DateFilterOp string
28
29 const (
30 DateFilterOpEq DateFilterOp = "EQ"
31 DateFilterOpNeq DateFilterOp = "NEQ"
32 DateFilterOpGt DateFilterOp = "GT"
33 DateFilterOpGte DateFilterOp = "GTE"
34 DateFilterOpLt DateFilterOp = "LT"
35 DateFilterOpLte DateFilterOp = "LTE"
36 )
37
38 var AllDateFilterOp = []DateFilterOp{
39 DateFilterOpEq,
40 DateFilterOpNeq,
41 DateFilterOpGt,
42 DateFilterOpGte,
43 DateFilterOpLt,
44 DateFilterOpLte,
45 }
46
47 func (e DateFilterOp) IsValid() bool {
48 switch e {
49 case DateFilterOpEq, DateFilterOpNeq, DateFilterOpGt, DateFilterOpGte, DateFilterOpLt, DateFilterOpLte:
50 return true
51 }
52 return false
53 }
54
55 func (e DateFilterOp) String() string {
56 return string(e)
57 }
58
59 func (e *DateFilterOp) UnmarshalGQL(v interface{}) error {
60 str, ok := v.(string)
61 if !ok {
62 return fmt.Errorf("enums must be strings")
63 }
64
65 *e = DateFilterOp(str)
66 if !e.IsValid() {
67 return fmt.Errorf("%s is not a valid DATE_FILTER_OP", str)
68 }
69 return nil
70 }
71
72 func (e DateFilterOp) MarshalGQL(w io.Writer) {
73 fmt.Fprint(w, strconv.Quote(e.String()))
74 }
75
76 type ErrorType string
77
78 const (
79 ErrorTypeCustom ErrorType = "CUSTOM"
80 ErrorTypeNormal ErrorType = "NORMAL"
81 )
82
83 var AllErrorType = []ErrorType{
84 ErrorTypeCustom,
85 ErrorTypeNormal,
86 }
87
88 func (e ErrorType) IsValid() bool {
89 switch e {
90 case ErrorTypeCustom, ErrorTypeNormal:
91 return true
92 }
93 return false
94 }
95
96 func (e ErrorType) String() string {
97 return string(e)
98 }
99
100 func (e *ErrorType) UnmarshalGQL(v interface{}) error {
101 str, ok := v.(string)
102 if !ok {
103 return fmt.Errorf("enums must be strings")
104 }
105
106 *e = ErrorType(str)
107 if !e.IsValid() {
108 return fmt.Errorf("%s is not a valid ErrorType", str)
109 }
110 return nil
111 }
112
113 func (e ErrorType) MarshalGQL(w io.Writer) {
114 fmt.Fprint(w, strconv.Quote(e.String()))
115 }
116
View as plain text