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