github.com/maeglindeveloper/gqlgen@v0.13.1-0.20210413081235-57808b12a0a0/example/todo/models_gen.go (about) 1 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 3 package todo 4 5 import ( 6 "fmt" 7 "io" 8 "strconv" 9 ) 10 11 // Passed to createTodo to create a new todo 12 type TodoInput struct { 13 // The body text 14 Text string `json:"text"` 15 // Is it done already? 16 Done *bool `json:"done"` 17 } 18 19 type Role string 20 21 const ( 22 RoleAdmin Role = "ADMIN" 23 RoleOwner Role = "OWNER" 24 ) 25 26 var AllRole = []Role{ 27 RoleAdmin, 28 RoleOwner, 29 } 30 31 func (e Role) IsValid() bool { 32 switch e { 33 case RoleAdmin, RoleOwner: 34 return true 35 } 36 return false 37 } 38 39 func (e Role) String() string { 40 return string(e) 41 } 42 43 func (e *Role) UnmarshalGQL(v interface{}) error { 44 str, ok := v.(string) 45 if !ok { 46 return fmt.Errorf("enums must be strings") 47 } 48 49 *e = Role(str) 50 if !e.IsValid() { 51 return fmt.Errorf("%s is not a valid Role", str) 52 } 53 return nil 54 } 55 56 func (e Role) MarshalGQL(w io.Writer) { 57 fmt.Fprint(w, strconv.Quote(e.String())) 58 }