github.com/codykaup/genqlient@v0.6.2/generate/testdata/snapshots/TestGenerate-InterfaceListOfListsOfListsField.graphql-InterfaceListOfListsOfListsField.graphql.go (about) 1 // Code generated by github.com/codykaup/genqlient, DO NOT EDIT. 2 3 package test 4 5 import ( 6 "encoding/json" 7 "fmt" 8 9 "github.com/codykaup/genqlient/graphql" 10 "github.com/codykaup/genqlient/internal/testutil" 11 ) 12 13 // InterfaceListOfListOfListsFieldListOfListsOfListsOfContent includes the requested fields of the GraphQL interface Content. 14 // 15 // InterfaceListOfListOfListsFieldListOfListsOfListsOfContent is implemented by the following types: 16 // InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle 17 // InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic 18 // InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo 19 // The GraphQL type's documentation follows. 20 // 21 // Content is implemented by various types like Article, Video, and Topic. 22 type InterfaceListOfListOfListsFieldListOfListsOfListsOfContent interface { 23 implementsGraphQLInterfaceInterfaceListOfListOfListsFieldListOfListsOfListsOfContent() 24 // GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values). 25 GetTypename() string 26 // GetId returns the interface-field "id" from its implementation. 27 // The GraphQL interface field's documentation follows. 28 // 29 // ID is the identifier of the content. 30 GetId() testutil.ID 31 // GetName returns the interface-field "name" from its implementation. 32 GetName() string 33 } 34 35 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle) implementsGraphQLInterfaceInterfaceListOfListOfListsFieldListOfListsOfListsOfContent() { 36 } 37 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic) implementsGraphQLInterfaceInterfaceListOfListOfListsFieldListOfListsOfListsOfContent() { 38 } 39 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo) implementsGraphQLInterfaceInterfaceListOfListOfListsFieldListOfListsOfListsOfContent() { 40 } 41 42 func __unmarshalInterfaceListOfListOfListsFieldListOfListsOfListsOfContent(b []byte, v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContent) error { 43 if string(b) == "null" { 44 return nil 45 } 46 47 var tn struct { 48 TypeName string `json:"__typename"` 49 } 50 err := json.Unmarshal(b, &tn) 51 if err != nil { 52 return err 53 } 54 55 switch tn.TypeName { 56 case "Article": 57 *v = new(InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle) 58 return json.Unmarshal(b, *v) 59 case "Topic": 60 *v = new(InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic) 61 return json.Unmarshal(b, *v) 62 case "Video": 63 *v = new(InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo) 64 return json.Unmarshal(b, *v) 65 case "": 66 return fmt.Errorf( 67 "response was missing Content.__typename") 68 default: 69 return fmt.Errorf( 70 `unexpected concrete type for InterfaceListOfListOfListsFieldListOfListsOfListsOfContent: "%v"`, tn.TypeName) 71 } 72 } 73 74 func __marshalInterfaceListOfListOfListsFieldListOfListsOfListsOfContent(v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContent) ([]byte, error) { 75 76 var typename string 77 switch v := (*v).(type) { 78 case *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle: 79 typename = "Article" 80 81 result := struct { 82 TypeName string `json:"__typename"` 83 *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle 84 }{typename, v} 85 return json.Marshal(result) 86 case *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic: 87 typename = "Topic" 88 89 result := struct { 90 TypeName string `json:"__typename"` 91 *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic 92 }{typename, v} 93 return json.Marshal(result) 94 case *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo: 95 typename = "Video" 96 97 result := struct { 98 TypeName string `json:"__typename"` 99 *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo 100 }{typename, v} 101 return json.Marshal(result) 102 case nil: 103 return []byte("null"), nil 104 default: 105 return nil, fmt.Errorf( 106 `unexpected concrete type for InterfaceListOfListOfListsFieldListOfListsOfListsOfContent: "%T"`, v) 107 } 108 } 109 110 // InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle includes the requested fields of the GraphQL type Article. 111 type InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle struct { 112 Typename string `json:"__typename"` 113 // ID is the identifier of the content. 114 Id testutil.ID `json:"id"` 115 Name string `json:"name"` 116 } 117 118 // GetTypename returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle.Typename, and is useful for accessing the field via an interface. 119 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle) GetTypename() string { 120 return v.Typename 121 } 122 123 // GetId returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle.Id, and is useful for accessing the field via an interface. 124 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle) GetId() testutil.ID { 125 return v.Id 126 } 127 128 // GetName returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle.Name, and is useful for accessing the field via an interface. 129 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentArticle) GetName() string { 130 return v.Name 131 } 132 133 // InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic includes the requested fields of the GraphQL type Topic. 134 type InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic struct { 135 Typename string `json:"__typename"` 136 // ID is the identifier of the content. 137 Id testutil.ID `json:"id"` 138 Name string `json:"name"` 139 } 140 141 // GetTypename returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic.Typename, and is useful for accessing the field via an interface. 142 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic) GetTypename() string { 143 return v.Typename 144 } 145 146 // GetId returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic.Id, and is useful for accessing the field via an interface. 147 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic) GetId() testutil.ID { 148 return v.Id 149 } 150 151 // GetName returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic.Name, and is useful for accessing the field via an interface. 152 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentTopic) GetName() string { 153 return v.Name 154 } 155 156 // InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo includes the requested fields of the GraphQL type Video. 157 type InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo struct { 158 Typename string `json:"__typename"` 159 // ID is the identifier of the content. 160 Id testutil.ID `json:"id"` 161 Name string `json:"name"` 162 } 163 164 // GetTypename returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo.Typename, and is useful for accessing the field via an interface. 165 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo) GetTypename() string { 166 return v.Typename 167 } 168 169 // GetId returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo.Id, and is useful for accessing the field via an interface. 170 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo) GetId() testutil.ID { 171 return v.Id 172 } 173 174 // GetName returns InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo.Name, and is useful for accessing the field via an interface. 175 func (v *InterfaceListOfListOfListsFieldListOfListsOfListsOfContentVideo) GetName() string { 176 return v.Name 177 } 178 179 // InterfaceListOfListOfListsFieldResponse is returned by InterfaceListOfListOfListsField on success. 180 type InterfaceListOfListOfListsFieldResponse struct { 181 ListOfListsOfListsOfContent [][][]InterfaceListOfListOfListsFieldListOfListsOfListsOfContent `json:"-"` 182 WithPointer [][][]*InterfaceListOfListOfListsFieldWithPointerContent `json:"-"` 183 } 184 185 // GetListOfListsOfListsOfContent returns InterfaceListOfListOfListsFieldResponse.ListOfListsOfListsOfContent, and is useful for accessing the field via an interface. 186 func (v *InterfaceListOfListOfListsFieldResponse) GetListOfListsOfListsOfContent() [][][]InterfaceListOfListOfListsFieldListOfListsOfListsOfContent { 187 return v.ListOfListsOfListsOfContent 188 } 189 190 // GetWithPointer returns InterfaceListOfListOfListsFieldResponse.WithPointer, and is useful for accessing the field via an interface. 191 func (v *InterfaceListOfListOfListsFieldResponse) GetWithPointer() [][][]*InterfaceListOfListOfListsFieldWithPointerContent { 192 return v.WithPointer 193 } 194 195 func (v *InterfaceListOfListOfListsFieldResponse) UnmarshalJSON(b []byte) error { 196 197 if string(b) == "null" { 198 return nil 199 } 200 201 var firstPass struct { 202 *InterfaceListOfListOfListsFieldResponse 203 ListOfListsOfListsOfContent [][][]json.RawMessage `json:"listOfListsOfListsOfContent"` 204 WithPointer [][][]json.RawMessage `json:"withPointer"` 205 graphql.NoUnmarshalJSON 206 } 207 firstPass.InterfaceListOfListOfListsFieldResponse = v 208 209 err := json.Unmarshal(b, &firstPass) 210 if err != nil { 211 return err 212 } 213 214 { 215 dst := &v.ListOfListsOfListsOfContent 216 src := firstPass.ListOfListsOfListsOfContent 217 *dst = make( 218 [][][]InterfaceListOfListOfListsFieldListOfListsOfListsOfContent, 219 len(src)) 220 for i, src := range src { 221 dst := &(*dst)[i] 222 *dst = make( 223 [][]InterfaceListOfListOfListsFieldListOfListsOfListsOfContent, 224 len(src)) 225 for i, src := range src { 226 dst := &(*dst)[i] 227 *dst = make( 228 []InterfaceListOfListOfListsFieldListOfListsOfListsOfContent, 229 len(src)) 230 for i, src := range src { 231 dst := &(*dst)[i] 232 if len(src) != 0 && string(src) != "null" { 233 err = __unmarshalInterfaceListOfListOfListsFieldListOfListsOfListsOfContent( 234 src, dst) 235 if err != nil { 236 return fmt.Errorf( 237 "unable to unmarshal InterfaceListOfListOfListsFieldResponse.ListOfListsOfListsOfContent: %w", err) 238 } 239 } 240 } 241 } 242 } 243 } 244 245 { 246 dst := &v.WithPointer 247 src := firstPass.WithPointer 248 *dst = make( 249 [][][]*InterfaceListOfListOfListsFieldWithPointerContent, 250 len(src)) 251 for i, src := range src { 252 dst := &(*dst)[i] 253 *dst = make( 254 [][]*InterfaceListOfListOfListsFieldWithPointerContent, 255 len(src)) 256 for i, src := range src { 257 dst := &(*dst)[i] 258 *dst = make( 259 []*InterfaceListOfListOfListsFieldWithPointerContent, 260 len(src)) 261 for i, src := range src { 262 dst := &(*dst)[i] 263 if len(src) != 0 && string(src) != "null" { 264 *dst = new(InterfaceListOfListOfListsFieldWithPointerContent) 265 err = __unmarshalInterfaceListOfListOfListsFieldWithPointerContent( 266 src, *dst) 267 if err != nil { 268 return fmt.Errorf( 269 "unable to unmarshal InterfaceListOfListOfListsFieldResponse.WithPointer: %w", err) 270 } 271 } 272 } 273 } 274 } 275 } 276 return nil 277 } 278 279 type __premarshalInterfaceListOfListOfListsFieldResponse struct { 280 ListOfListsOfListsOfContent [][][]json.RawMessage `json:"listOfListsOfListsOfContent"` 281 282 WithPointer [][][]json.RawMessage `json:"withPointer"` 283 } 284 285 func (v *InterfaceListOfListOfListsFieldResponse) MarshalJSON() ([]byte, error) { 286 premarshaled, err := v.__premarshalJSON() 287 if err != nil { 288 return nil, err 289 } 290 return json.Marshal(premarshaled) 291 } 292 293 func (v *InterfaceListOfListOfListsFieldResponse) __premarshalJSON() (*__premarshalInterfaceListOfListOfListsFieldResponse, error) { 294 var retval __premarshalInterfaceListOfListOfListsFieldResponse 295 296 { 297 298 dst := &retval.ListOfListsOfListsOfContent 299 src := v.ListOfListsOfListsOfContent 300 *dst = make( 301 [][][]json.RawMessage, 302 len(src)) 303 for i, src := range src { 304 dst := &(*dst)[i] 305 *dst = make( 306 [][]json.RawMessage, 307 len(src)) 308 for i, src := range src { 309 dst := &(*dst)[i] 310 *dst = make( 311 []json.RawMessage, 312 len(src)) 313 for i, src := range src { 314 dst := &(*dst)[i] 315 var err error 316 *dst, err = __marshalInterfaceListOfListOfListsFieldListOfListsOfListsOfContent( 317 &src) 318 if err != nil { 319 return nil, fmt.Errorf( 320 "unable to marshal InterfaceListOfListOfListsFieldResponse.ListOfListsOfListsOfContent: %w", err) 321 } 322 } 323 } 324 } 325 } 326 { 327 328 dst := &retval.WithPointer 329 src := v.WithPointer 330 *dst = make( 331 [][][]json.RawMessage, 332 len(src)) 333 for i, src := range src { 334 dst := &(*dst)[i] 335 *dst = make( 336 [][]json.RawMessage, 337 len(src)) 338 for i, src := range src { 339 dst := &(*dst)[i] 340 *dst = make( 341 []json.RawMessage, 342 len(src)) 343 for i, src := range src { 344 dst := &(*dst)[i] 345 if src != nil { 346 var err error 347 *dst, err = __marshalInterfaceListOfListOfListsFieldWithPointerContent( 348 src) 349 if err != nil { 350 return nil, fmt.Errorf( 351 "unable to marshal InterfaceListOfListOfListsFieldResponse.WithPointer: %w", err) 352 } 353 } 354 } 355 } 356 } 357 } 358 return &retval, nil 359 } 360 361 // InterfaceListOfListOfListsFieldWithPointerArticle includes the requested fields of the GraphQL type Article. 362 type InterfaceListOfListOfListsFieldWithPointerArticle struct { 363 Typename string `json:"__typename"` 364 // ID is the identifier of the content. 365 Id *testutil.ID `json:"id"` 366 Name *string `json:"name"` 367 } 368 369 // GetTypename returns InterfaceListOfListOfListsFieldWithPointerArticle.Typename, and is useful for accessing the field via an interface. 370 func (v *InterfaceListOfListOfListsFieldWithPointerArticle) GetTypename() string { return v.Typename } 371 372 // GetId returns InterfaceListOfListOfListsFieldWithPointerArticle.Id, and is useful for accessing the field via an interface. 373 func (v *InterfaceListOfListOfListsFieldWithPointerArticle) GetId() *testutil.ID { return v.Id } 374 375 // GetName returns InterfaceListOfListOfListsFieldWithPointerArticle.Name, and is useful for accessing the field via an interface. 376 func (v *InterfaceListOfListOfListsFieldWithPointerArticle) GetName() *string { return v.Name } 377 378 // InterfaceListOfListOfListsFieldWithPointerContent includes the requested fields of the GraphQL interface Content. 379 // 380 // InterfaceListOfListOfListsFieldWithPointerContent is implemented by the following types: 381 // InterfaceListOfListOfListsFieldWithPointerArticle 382 // InterfaceListOfListOfListsFieldWithPointerTopic 383 // InterfaceListOfListOfListsFieldWithPointerVideo 384 // The GraphQL type's documentation follows. 385 // 386 // Content is implemented by various types like Article, Video, and Topic. 387 type InterfaceListOfListOfListsFieldWithPointerContent interface { 388 implementsGraphQLInterfaceInterfaceListOfListOfListsFieldWithPointerContent() 389 // GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values). 390 GetTypename() string 391 // GetId returns the interface-field "id" from its implementation. 392 // The GraphQL interface field's documentation follows. 393 // 394 // ID is the identifier of the content. 395 GetId() *testutil.ID 396 // GetName returns the interface-field "name" from its implementation. 397 GetName() *string 398 } 399 400 func (v *InterfaceListOfListOfListsFieldWithPointerArticle) implementsGraphQLInterfaceInterfaceListOfListOfListsFieldWithPointerContent() { 401 } 402 func (v *InterfaceListOfListOfListsFieldWithPointerTopic) implementsGraphQLInterfaceInterfaceListOfListOfListsFieldWithPointerContent() { 403 } 404 func (v *InterfaceListOfListOfListsFieldWithPointerVideo) implementsGraphQLInterfaceInterfaceListOfListOfListsFieldWithPointerContent() { 405 } 406 407 func __unmarshalInterfaceListOfListOfListsFieldWithPointerContent(b []byte, v *InterfaceListOfListOfListsFieldWithPointerContent) error { 408 if string(b) == "null" { 409 return nil 410 } 411 412 var tn struct { 413 TypeName string `json:"__typename"` 414 } 415 err := json.Unmarshal(b, &tn) 416 if err != nil { 417 return err 418 } 419 420 switch tn.TypeName { 421 case "Article": 422 *v = new(InterfaceListOfListOfListsFieldWithPointerArticle) 423 return json.Unmarshal(b, *v) 424 case "Topic": 425 *v = new(InterfaceListOfListOfListsFieldWithPointerTopic) 426 return json.Unmarshal(b, *v) 427 case "Video": 428 *v = new(InterfaceListOfListOfListsFieldWithPointerVideo) 429 return json.Unmarshal(b, *v) 430 case "": 431 return fmt.Errorf( 432 "response was missing Content.__typename") 433 default: 434 return fmt.Errorf( 435 `unexpected concrete type for InterfaceListOfListOfListsFieldWithPointerContent: "%v"`, tn.TypeName) 436 } 437 } 438 439 func __marshalInterfaceListOfListOfListsFieldWithPointerContent(v *InterfaceListOfListOfListsFieldWithPointerContent) ([]byte, error) { 440 441 var typename string 442 switch v := (*v).(type) { 443 case *InterfaceListOfListOfListsFieldWithPointerArticle: 444 typename = "Article" 445 446 result := struct { 447 TypeName string `json:"__typename"` 448 *InterfaceListOfListOfListsFieldWithPointerArticle 449 }{typename, v} 450 return json.Marshal(result) 451 case *InterfaceListOfListOfListsFieldWithPointerTopic: 452 typename = "Topic" 453 454 result := struct { 455 TypeName string `json:"__typename"` 456 *InterfaceListOfListOfListsFieldWithPointerTopic 457 }{typename, v} 458 return json.Marshal(result) 459 case *InterfaceListOfListOfListsFieldWithPointerVideo: 460 typename = "Video" 461 462 result := struct { 463 TypeName string `json:"__typename"` 464 *InterfaceListOfListOfListsFieldWithPointerVideo 465 }{typename, v} 466 return json.Marshal(result) 467 case nil: 468 return []byte("null"), nil 469 default: 470 return nil, fmt.Errorf( 471 `unexpected concrete type for InterfaceListOfListOfListsFieldWithPointerContent: "%T"`, v) 472 } 473 } 474 475 // InterfaceListOfListOfListsFieldWithPointerTopic includes the requested fields of the GraphQL type Topic. 476 type InterfaceListOfListOfListsFieldWithPointerTopic struct { 477 Typename string `json:"__typename"` 478 // ID is the identifier of the content. 479 Id *testutil.ID `json:"id"` 480 Name *string `json:"name"` 481 } 482 483 // GetTypename returns InterfaceListOfListOfListsFieldWithPointerTopic.Typename, and is useful for accessing the field via an interface. 484 func (v *InterfaceListOfListOfListsFieldWithPointerTopic) GetTypename() string { return v.Typename } 485 486 // GetId returns InterfaceListOfListOfListsFieldWithPointerTopic.Id, and is useful for accessing the field via an interface. 487 func (v *InterfaceListOfListOfListsFieldWithPointerTopic) GetId() *testutil.ID { return v.Id } 488 489 // GetName returns InterfaceListOfListOfListsFieldWithPointerTopic.Name, and is useful for accessing the field via an interface. 490 func (v *InterfaceListOfListOfListsFieldWithPointerTopic) GetName() *string { return v.Name } 491 492 // InterfaceListOfListOfListsFieldWithPointerVideo includes the requested fields of the GraphQL type Video. 493 type InterfaceListOfListOfListsFieldWithPointerVideo struct { 494 Typename string `json:"__typename"` 495 // ID is the identifier of the content. 496 Id *testutil.ID `json:"id"` 497 Name *string `json:"name"` 498 } 499 500 // GetTypename returns InterfaceListOfListOfListsFieldWithPointerVideo.Typename, and is useful for accessing the field via an interface. 501 func (v *InterfaceListOfListOfListsFieldWithPointerVideo) GetTypename() string { return v.Typename } 502 503 // GetId returns InterfaceListOfListOfListsFieldWithPointerVideo.Id, and is useful for accessing the field via an interface. 504 func (v *InterfaceListOfListOfListsFieldWithPointerVideo) GetId() *testutil.ID { return v.Id } 505 506 // GetName returns InterfaceListOfListOfListsFieldWithPointerVideo.Name, and is useful for accessing the field via an interface. 507 func (v *InterfaceListOfListOfListsFieldWithPointerVideo) GetName() *string { return v.Name } 508 509 // The query or mutation executed by InterfaceListOfListOfListsField. 510 const InterfaceListOfListOfListsField_Operation = ` 511 query InterfaceListOfListOfListsField { 512 listOfListsOfListsOfContent { 513 __typename 514 id 515 name 516 } 517 withPointer: listOfListsOfListsOfContent { 518 __typename 519 id 520 name 521 } 522 } 523 ` 524 525 func InterfaceListOfListOfListsField( 526 client_ graphql.Client, 527 ) (*InterfaceListOfListOfListsFieldResponse, error) { 528 req_ := &graphql.Request{ 529 OpName: "InterfaceListOfListOfListsField", 530 Query: InterfaceListOfListOfListsField_Operation, 531 } 532 var err_ error 533 534 var data_ InterfaceListOfListOfListsFieldResponse 535 resp_ := &graphql.Response{Data: &data_} 536 537 err_ = client_.MakeRequest( 538 nil, 539 req_, 540 resp_, 541 ) 542 543 return &data_, err_ 544 } 545