github.com/kerryoscer/gqlgen@v0.17.29/codegen/testserver/singlefile/models-gen.go (about) 1 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 3 package singlefile 4 5 import ( 6 "fmt" 7 "io" 8 "strconv" 9 "time" 10 ) 11 12 type Animal interface { 13 IsAnimal() 14 GetSpecies() string 15 GetSize() *Size 16 } 17 18 type ContentChild interface { 19 IsContentChild() 20 } 21 22 type TestUnion interface { 23 IsTestUnion() 24 } 25 26 type A struct { 27 ID string `json:"id"` 28 } 29 30 func (A) IsTestUnion() {} 31 32 type AIt struct { 33 ID string `json:"id"` 34 } 35 36 type AbIt struct { 37 ID string `json:"id"` 38 } 39 40 type B struct { 41 ID string `json:"id"` 42 } 43 44 func (B) IsTestUnion() {} 45 46 type Cat struct { 47 Species string `json:"species"` 48 Size *Size `json:"size"` 49 CatBreed string `json:"catBreed"` 50 } 51 52 func (Cat) IsAnimal() {} 53 func (this Cat) GetSpecies() string { return this.Species } 54 func (this Cat) GetSize() *Size { return this.Size } 55 56 type CheckIssue896 struct { 57 ID *int `json:"id,omitempty"` 58 } 59 60 type ContentPost struct { 61 Foo *string `json:"foo,omitempty"` 62 } 63 64 func (ContentPost) IsContentChild() {} 65 66 type ContentUser struct { 67 Foo *string `json:"foo,omitempty"` 68 } 69 70 func (ContentUser) IsContentChild() {} 71 72 type Coordinates struct { 73 X float64 `json:"x"` 74 Y float64 `json:"y"` 75 } 76 77 type DefaultInput struct { 78 FalsyBoolean *bool `json:"falsyBoolean,omitempty"` 79 TruthyBoolean *bool `json:"truthyBoolean,omitempty"` 80 } 81 82 type DefaultParametersMirror struct { 83 FalsyBoolean *bool `json:"falsyBoolean,omitempty"` 84 TruthyBoolean *bool `json:"truthyBoolean,omitempty"` 85 } 86 87 type Dog struct { 88 Species string `json:"species"` 89 Size *Size `json:"size"` 90 DogBreed string `json:"dogBreed"` 91 } 92 93 func (Dog) IsAnimal() {} 94 func (this Dog) GetSpecies() string { return this.Species } 95 func (this Dog) GetSize() *Size { return this.Size } 96 97 type EmbeddedDefaultScalar struct { 98 Value *string `json:"value,omitempty"` 99 } 100 101 type FieldsOrderPayload struct { 102 FirstFieldValue *string `json:"firstFieldValue,omitempty"` 103 } 104 105 type InnerDirectives struct { 106 Message string `json:"message"` 107 } 108 109 type InnerInput struct { 110 ID int `json:"id"` 111 } 112 113 type InnerObject struct { 114 ID int `json:"id"` 115 } 116 117 type InputDirectives struct { 118 Text string `json:"text"` 119 NullableText *string `json:"nullableText,omitempty"` 120 Inner *InnerDirectives `json:"inner"` 121 InnerNullable *InnerDirectives `json:"innerNullable,omitempty"` 122 ThirdParty *ThirdParty `json:"thirdParty,omitempty"` 123 } 124 125 type InputWithEnumValue struct { 126 Enum EnumTest `json:"enum"` 127 } 128 129 type LoopA struct { 130 B *LoopB `json:"b"` 131 } 132 133 type LoopB struct { 134 A *LoopA `json:"a"` 135 } 136 137 // Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_ 138 // added to the TypeMap 139 type Map struct { 140 ID string `json:"id"` 141 } 142 143 type NestedInput struct { 144 Field Email `json:"field"` 145 } 146 147 type NestedMapInput struct { 148 Map map[string]interface{} `json:"map,omitempty"` 149 } 150 151 type ObjectDirectives struct { 152 Text string `json:"text"` 153 NullableText *string `json:"nullableText,omitempty"` 154 Order []string `json:"order"` 155 } 156 157 type OuterInput struct { 158 Inner *InnerInput `json:"inner"` 159 } 160 161 type OuterObject struct { 162 Inner *InnerObject `json:"inner"` 163 } 164 165 type Pet struct { 166 ID int `json:"id"` 167 Friends []*Pet `json:"friends,omitempty"` 168 } 169 170 type Size struct { 171 Height int `json:"height"` 172 Weight int `json:"weight"` 173 } 174 175 type Slices struct { 176 Test1 []*string `json:"test1,omitempty"` 177 Test2 []string `json:"test2,omitempty"` 178 Test3 []*string `json:"test3"` 179 Test4 []string `json:"test4"` 180 } 181 182 type SpecialInput struct { 183 Nesting *NestedInput `json:"nesting"` 184 } 185 186 type User struct { 187 ID int `json:"id"` 188 Friends []*User `json:"friends"` 189 Created time.Time `json:"created"` 190 Updated *time.Time `json:"updated,omitempty"` 191 Pets []*Pet `json:"pets,omitempty"` 192 } 193 194 type ValidInput struct { 195 Break string `json:"break"` 196 Default string `json:"default"` 197 Func string `json:"func"` 198 Interface string `json:"interface"` 199 Select string `json:"select"` 200 Case string `json:"case"` 201 Defer string `json:"defer"` 202 Go string `json:"go"` 203 Map string `json:"map"` 204 Struct string `json:"struct"` 205 Chan string `json:"chan"` 206 Else string `json:"else"` 207 Goto string `json:"goto"` 208 Package string `json:"package"` 209 Switch string `json:"switch"` 210 Const string `json:"const"` 211 Fallthrough string `json:"fallthrough"` 212 If string `json:"if"` 213 Range string `json:"range"` 214 Type string `json:"type"` 215 Continue string `json:"continue"` 216 For string `json:"for"` 217 Import string `json:"import"` 218 Return string `json:"return"` 219 Var string `json:"var"` 220 Underscore string `json:"_"` 221 } 222 223 // These things are all valid, but without care generate invalid go code 224 type ValidType struct { 225 DifferentCase string `json:"differentCase"` 226 DifferentCaseOld string `json:"different_case"` 227 ValidInputKeywords bool `json:"validInputKeywords"` 228 ValidArgs bool `json:"validArgs"` 229 } 230 231 type XXIt struct { 232 ID string `json:"id"` 233 } 234 235 type XxIt struct { 236 ID string `json:"id"` 237 } 238 239 type AsdfIt struct { 240 ID string `json:"id"` 241 } 242 243 type IIt struct { 244 ID string `json:"id"` 245 } 246 247 type EnumTest string 248 249 const ( 250 EnumTestOk EnumTest = "OK" 251 EnumTestNg EnumTest = "NG" 252 ) 253 254 var AllEnumTest = []EnumTest{ 255 EnumTestOk, 256 EnumTestNg, 257 } 258 259 func (e EnumTest) IsValid() bool { 260 switch e { 261 case EnumTestOk, EnumTestNg: 262 return true 263 } 264 return false 265 } 266 267 func (e EnumTest) String() string { 268 return string(e) 269 } 270 271 func (e *EnumTest) UnmarshalGQL(v interface{}) error { 272 str, ok := v.(string) 273 if !ok { 274 return fmt.Errorf("enums must be strings") 275 } 276 277 *e = EnumTest(str) 278 if !e.IsValid() { 279 return fmt.Errorf("%s is not a valid EnumTest", str) 280 } 281 return nil 282 } 283 284 func (e EnumTest) MarshalGQL(w io.Writer) { 285 fmt.Fprint(w, strconv.Quote(e.String())) 286 } 287 288 type Status string 289 290 const ( 291 StatusOk Status = "OK" 292 StatusError Status = "ERROR" 293 ) 294 295 var AllStatus = []Status{ 296 StatusOk, 297 StatusError, 298 } 299 300 func (e Status) IsValid() bool { 301 switch e { 302 case StatusOk, StatusError: 303 return true 304 } 305 return false 306 } 307 308 func (e Status) String() string { 309 return string(e) 310 } 311 312 func (e *Status) UnmarshalGQL(v interface{}) error { 313 str, ok := v.(string) 314 if !ok { 315 return fmt.Errorf("enums must be strings") 316 } 317 318 *e = Status(str) 319 if !e.IsValid() { 320 return fmt.Errorf("%s is not a valid Status", str) 321 } 322 return nil 323 } 324 325 func (e Status) MarshalGQL(w io.Writer) { 326 fmt.Fprint(w, strconv.Quote(e.String())) 327 }