github.com/Desuuuu/genqlient@v0.5.3/internal/integration/server/gqlgen_models.go (about) 1 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 3 package server 4 5 import ( 6 "fmt" 7 "io" 8 "strconv" 9 ) 10 11 type Being interface { 12 IsBeing() 13 } 14 15 type Lucky interface { 16 IsLucky() 17 } 18 19 type Animal struct { 20 ID string `json:"id"` 21 Name string `json:"name"` 22 Species Species `json:"species"` 23 Owner Being `json:"owner"` 24 Hair *BeingsHair `json:"hair"` 25 } 26 27 func (Animal) IsBeing() {} 28 29 type BeingsHair struct { 30 HasHair bool `json:"hasHair"` 31 } 32 33 type Hair struct { 34 Color *string `json:"color"` 35 } 36 37 type NewUser struct { 38 Name string `json:"name"` 39 } 40 41 type User struct { 42 ID string `json:"id"` 43 Name string `json:"name"` 44 LuckyNumber *int `json:"luckyNumber"` 45 Hair *Hair `json:"hair"` 46 Birthdate *string `json:"birthdate"` 47 Friends []*User `json:"friends"` 48 } 49 50 func (User) IsBeing() {} 51 func (User) IsLucky() {} 52 53 type Species string 54 55 const ( 56 SpeciesDog Species = "DOG" 57 SpeciesCoelacanth Species = "COELACANTH" 58 ) 59 60 var AllSpecies = []Species{ 61 SpeciesDog, 62 SpeciesCoelacanth, 63 } 64 65 func (e Species) IsValid() bool { 66 switch e { 67 case SpeciesDog, SpeciesCoelacanth: 68 return true 69 } 70 return false 71 } 72 73 func (e Species) String() string { 74 return string(e) 75 } 76 77 func (e *Species) UnmarshalGQL(v interface{}) error { 78 str, ok := v.(string) 79 if !ok { 80 return fmt.Errorf("enums must be strings") 81 } 82 83 *e = Species(str) 84 if !e.IsValid() { 85 return fmt.Errorf("%s is not a valid Species", str) 86 } 87 return nil 88 } 89 90 func (e Species) MarshalGQL(w io.Writer) { 91 fmt.Fprint(w, strconv.Quote(e.String())) 92 }