github.com/speedoops/go-gqlrest-demo@v0.0.0-20220710122636-5c6460aeab4f/graph/model/models_gen.go (about) 1 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 3 package model 4 5 import ( 6 "fmt" 7 "io" 8 "strconv" 9 ) 10 11 type Category struct { 12 ID string `json:"id"` 13 Name string `json:"name"` 14 } 15 16 type NewTodoInput struct { 17 Text string `json:"text"` 18 UserID string `json:"userID"` 19 Done *bool `json:"done"` 20 } 21 22 type UpdateTodoInput struct { 23 ID string `json:"id"` 24 Text *string `json:"text"` 25 UserID *string `json:"userID"` 26 } 27 28 type User struct { 29 ID string `json:"id"` 30 Name string `json:"name"` 31 Role Role `json:"role"` 32 } 33 34 type Role string 35 36 const ( 37 RoleAdmin Role = "ADMIN" 38 RoleUser Role = "USER" 39 ) 40 41 var AllRole = []Role{ 42 RoleAdmin, 43 RoleUser, 44 } 45 46 func (e Role) IsValid() bool { 47 switch e { 48 case RoleAdmin, RoleUser: 49 return true 50 } 51 return false 52 } 53 54 func (e Role) String() string { 55 return string(e) 56 } 57 58 func (e *Role) UnmarshalGQL(v interface{}) error { 59 str, ok := v.(string) 60 if !ok { 61 return fmt.Errorf("enums must be strings") 62 } 63 64 *e = Role(str) 65 if !e.IsValid() { 66 return fmt.Errorf("%s is not a valid Role", str) 67 } 68 return nil 69 } 70 71 func (e Role) MarshalGQL(w io.Writer) { 72 fmt.Fprint(w, strconv.Quote(e.String())) 73 } 74 75 type TodoType string 76 77 const ( 78 TodoTypeTypeA TodoType = "TypeA" 79 TodoTypeTypeB TodoType = "TypeB" 80 ) 81 82 var AllTodoType = []TodoType{ 83 TodoTypeTypeA, 84 TodoTypeTypeB, 85 } 86 87 func (e TodoType) IsValid() bool { 88 switch e { 89 case TodoTypeTypeA, TodoTypeTypeB: 90 return true 91 } 92 return false 93 } 94 95 func (e TodoType) String() string { 96 return string(e) 97 } 98 99 func (e *TodoType) UnmarshalGQL(v interface{}) error { 100 str, ok := v.(string) 101 if !ok { 102 return fmt.Errorf("enums must be strings") 103 } 104 105 *e = TodoType(str) 106 if !e.IsValid() { 107 return fmt.Errorf("%s is not a valid TodoType", str) 108 } 109 return nil 110 } 111 112 func (e TodoType) MarshalGQL(w io.Writer) { 113 fmt.Fprint(w, strconv.Quote(e.String())) 114 }