github.com/codykaup/genqlient@v0.6.2/generate/testdata/snapshots/TestGenerate-CovariantInterfaceImplementation.graphql-CovariantInterfaceImplementation.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 // ContentFields includes the GraphQL fields of Content requested by the fragment ContentFields. 14 // The GraphQL type's documentation follows. 15 // 16 // Content is implemented by various types like Article, Video, and Topic. 17 // 18 // ContentFields is implemented by the following types: 19 // ContentFieldsArticle 20 // ContentFieldsTopic 21 // ContentFieldsVideo 22 type ContentFields interface { 23 implementsGraphQLInterfaceContentFields() 24 // GetNext returns the interface-field "next" from its implementation. 25 GetNext() ContentFieldsNextContent 26 // GetRelated returns the interface-field "related" from its implementation. 27 GetRelated() []ContentFieldsRelatedContent 28 } 29 30 func (v *ContentFieldsArticle) implementsGraphQLInterfaceContentFields() {} 31 func (v *ContentFieldsTopic) implementsGraphQLInterfaceContentFields() {} 32 func (v *ContentFieldsVideo) implementsGraphQLInterfaceContentFields() {} 33 34 func __unmarshalContentFields(b []byte, v *ContentFields) error { 35 if string(b) == "null" { 36 return nil 37 } 38 39 var tn struct { 40 TypeName string `json:"__typename"` 41 } 42 err := json.Unmarshal(b, &tn) 43 if err != nil { 44 return err 45 } 46 47 switch tn.TypeName { 48 case "Article": 49 *v = new(ContentFieldsArticle) 50 return json.Unmarshal(b, *v) 51 case "Topic": 52 *v = new(ContentFieldsTopic) 53 return json.Unmarshal(b, *v) 54 case "Video": 55 *v = new(ContentFieldsVideo) 56 return json.Unmarshal(b, *v) 57 case "": 58 return fmt.Errorf( 59 "response was missing Content.__typename") 60 default: 61 return fmt.Errorf( 62 `unexpected concrete type for ContentFields: "%v"`, tn.TypeName) 63 } 64 } 65 66 func __marshalContentFields(v *ContentFields) ([]byte, error) { 67 68 var typename string 69 switch v := (*v).(type) { 70 case *ContentFieldsArticle: 71 typename = "Article" 72 73 premarshaled, err := v.__premarshalJSON() 74 if err != nil { 75 return nil, err 76 } 77 result := struct { 78 TypeName string `json:"__typename"` 79 *__premarshalContentFieldsArticle 80 }{typename, premarshaled} 81 return json.Marshal(result) 82 case *ContentFieldsTopic: 83 typename = "Topic" 84 85 premarshaled, err := v.__premarshalJSON() 86 if err != nil { 87 return nil, err 88 } 89 result := struct { 90 TypeName string `json:"__typename"` 91 *__premarshalContentFieldsTopic 92 }{typename, premarshaled} 93 return json.Marshal(result) 94 case *ContentFieldsVideo: 95 typename = "Video" 96 97 premarshaled, err := v.__premarshalJSON() 98 if err != nil { 99 return nil, err 100 } 101 result := struct { 102 TypeName string `json:"__typename"` 103 *__premarshalContentFieldsVideo 104 }{typename, premarshaled} 105 return json.Marshal(result) 106 case nil: 107 return []byte("null"), nil 108 default: 109 return nil, fmt.Errorf( 110 `unexpected concrete type for ContentFields: "%T"`, v) 111 } 112 } 113 114 // ContentFields includes the GraphQL fields of Article requested by the fragment ContentFields. 115 // The GraphQL type's documentation follows. 116 // 117 // Content is implemented by various types like Article, Video, and Topic. 118 type ContentFieldsArticle struct { 119 Next ContentFieldsNextContent `json:"-"` 120 Related []ContentFieldsRelatedContent `json:"-"` 121 } 122 123 // GetNext returns ContentFieldsArticle.Next, and is useful for accessing the field via an interface. 124 func (v *ContentFieldsArticle) GetNext() ContentFieldsNextContent { return v.Next } 125 126 // GetRelated returns ContentFieldsArticle.Related, and is useful for accessing the field via an interface. 127 func (v *ContentFieldsArticle) GetRelated() []ContentFieldsRelatedContent { return v.Related } 128 129 func (v *ContentFieldsArticle) UnmarshalJSON(b []byte) error { 130 131 if string(b) == "null" { 132 return nil 133 } 134 135 var firstPass struct { 136 *ContentFieldsArticle 137 Next json.RawMessage `json:"next"` 138 Related []json.RawMessage `json:"related"` 139 graphql.NoUnmarshalJSON 140 } 141 firstPass.ContentFieldsArticle = v 142 143 err := json.Unmarshal(b, &firstPass) 144 if err != nil { 145 return err 146 } 147 148 { 149 dst := &v.Next 150 src := firstPass.Next 151 if len(src) != 0 && string(src) != "null" { 152 err = __unmarshalContentFieldsNextContent( 153 src, dst) 154 if err != nil { 155 return fmt.Errorf( 156 "unable to unmarshal ContentFieldsArticle.Next: %w", err) 157 } 158 } 159 } 160 161 { 162 dst := &v.Related 163 src := firstPass.Related 164 *dst = make( 165 []ContentFieldsRelatedContent, 166 len(src)) 167 for i, src := range src { 168 dst := &(*dst)[i] 169 if len(src) != 0 && string(src) != "null" { 170 err = __unmarshalContentFieldsRelatedContent( 171 src, dst) 172 if err != nil { 173 return fmt.Errorf( 174 "unable to unmarshal ContentFieldsArticle.Related: %w", err) 175 } 176 } 177 } 178 } 179 return nil 180 } 181 182 type __premarshalContentFieldsArticle struct { 183 Next json.RawMessage `json:"next"` 184 185 Related []json.RawMessage `json:"related"` 186 } 187 188 func (v *ContentFieldsArticle) MarshalJSON() ([]byte, error) { 189 premarshaled, err := v.__premarshalJSON() 190 if err != nil { 191 return nil, err 192 } 193 return json.Marshal(premarshaled) 194 } 195 196 func (v *ContentFieldsArticle) __premarshalJSON() (*__premarshalContentFieldsArticle, error) { 197 var retval __premarshalContentFieldsArticle 198 199 { 200 201 dst := &retval.Next 202 src := v.Next 203 var err error 204 *dst, err = __marshalContentFieldsNextContent( 205 &src) 206 if err != nil { 207 return nil, fmt.Errorf( 208 "unable to marshal ContentFieldsArticle.Next: %w", err) 209 } 210 } 211 { 212 213 dst := &retval.Related 214 src := v.Related 215 *dst = make( 216 []json.RawMessage, 217 len(src)) 218 for i, src := range src { 219 dst := &(*dst)[i] 220 var err error 221 *dst, err = __marshalContentFieldsRelatedContent( 222 &src) 223 if err != nil { 224 return nil, fmt.Errorf( 225 "unable to marshal ContentFieldsArticle.Related: %w", err) 226 } 227 } 228 } 229 return &retval, nil 230 } 231 232 // ContentFieldsNextArticle includes the requested fields of the GraphQL type Article. 233 type ContentFieldsNextArticle struct { 234 Typename string `json:"__typename"` 235 // ID is the identifier of the content. 236 Id testutil.ID `json:"id"` 237 } 238 239 // GetTypename returns ContentFieldsNextArticle.Typename, and is useful for accessing the field via an interface. 240 func (v *ContentFieldsNextArticle) GetTypename() string { return v.Typename } 241 242 // GetId returns ContentFieldsNextArticle.Id, and is useful for accessing the field via an interface. 243 func (v *ContentFieldsNextArticle) GetId() testutil.ID { return v.Id } 244 245 // ContentFieldsNextContent includes the requested fields of the GraphQL interface Content. 246 // 247 // ContentFieldsNextContent is implemented by the following types: 248 // ContentFieldsNextArticle 249 // ContentFieldsNextTopic 250 // ContentFieldsNextVideo 251 // The GraphQL type's documentation follows. 252 // 253 // Content is implemented by various types like Article, Video, and Topic. 254 type ContentFieldsNextContent interface { 255 implementsGraphQLInterfaceContentFieldsNextContent() 256 // GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values). 257 GetTypename() string 258 // GetId returns the interface-field "id" from its implementation. 259 // The GraphQL interface field's documentation follows. 260 // 261 // ID is the identifier of the content. 262 GetId() testutil.ID 263 } 264 265 func (v *ContentFieldsNextArticle) implementsGraphQLInterfaceContentFieldsNextContent() {} 266 func (v *ContentFieldsNextTopic) implementsGraphQLInterfaceContentFieldsNextContent() {} 267 func (v *ContentFieldsNextVideo) implementsGraphQLInterfaceContentFieldsNextContent() {} 268 269 func __unmarshalContentFieldsNextContent(b []byte, v *ContentFieldsNextContent) error { 270 if string(b) == "null" { 271 return nil 272 } 273 274 var tn struct { 275 TypeName string `json:"__typename"` 276 } 277 err := json.Unmarshal(b, &tn) 278 if err != nil { 279 return err 280 } 281 282 switch tn.TypeName { 283 case "Article": 284 *v = new(ContentFieldsNextArticle) 285 return json.Unmarshal(b, *v) 286 case "Topic": 287 *v = new(ContentFieldsNextTopic) 288 return json.Unmarshal(b, *v) 289 case "Video": 290 *v = new(ContentFieldsNextVideo) 291 return json.Unmarshal(b, *v) 292 case "": 293 return fmt.Errorf( 294 "response was missing Content.__typename") 295 default: 296 return fmt.Errorf( 297 `unexpected concrete type for ContentFieldsNextContent: "%v"`, tn.TypeName) 298 } 299 } 300 301 func __marshalContentFieldsNextContent(v *ContentFieldsNextContent) ([]byte, error) { 302 303 var typename string 304 switch v := (*v).(type) { 305 case *ContentFieldsNextArticle: 306 typename = "Article" 307 308 result := struct { 309 TypeName string `json:"__typename"` 310 *ContentFieldsNextArticle 311 }{typename, v} 312 return json.Marshal(result) 313 case *ContentFieldsNextTopic: 314 typename = "Topic" 315 316 result := struct { 317 TypeName string `json:"__typename"` 318 *ContentFieldsNextTopic 319 }{typename, v} 320 return json.Marshal(result) 321 case *ContentFieldsNextVideo: 322 typename = "Video" 323 324 result := struct { 325 TypeName string `json:"__typename"` 326 *ContentFieldsNextVideo 327 }{typename, v} 328 return json.Marshal(result) 329 case nil: 330 return []byte("null"), nil 331 default: 332 return nil, fmt.Errorf( 333 `unexpected concrete type for ContentFieldsNextContent: "%T"`, v) 334 } 335 } 336 337 // ContentFieldsNextTopic includes the requested fields of the GraphQL type Topic. 338 type ContentFieldsNextTopic struct { 339 Typename string `json:"__typename"` 340 // ID is the identifier of the content. 341 Id testutil.ID `json:"id"` 342 } 343 344 // GetTypename returns ContentFieldsNextTopic.Typename, and is useful for accessing the field via an interface. 345 func (v *ContentFieldsNextTopic) GetTypename() string { return v.Typename } 346 347 // GetId returns ContentFieldsNextTopic.Id, and is useful for accessing the field via an interface. 348 func (v *ContentFieldsNextTopic) GetId() testutil.ID { return v.Id } 349 350 // ContentFieldsNextVideo includes the requested fields of the GraphQL type Video. 351 type ContentFieldsNextVideo struct { 352 Typename string `json:"__typename"` 353 // ID is the identifier of the content. 354 Id testutil.ID `json:"id"` 355 } 356 357 // GetTypename returns ContentFieldsNextVideo.Typename, and is useful for accessing the field via an interface. 358 func (v *ContentFieldsNextVideo) GetTypename() string { return v.Typename } 359 360 // GetId returns ContentFieldsNextVideo.Id, and is useful for accessing the field via an interface. 361 func (v *ContentFieldsNextVideo) GetId() testutil.ID { return v.Id } 362 363 // ContentFieldsRelatedArticle includes the requested fields of the GraphQL type Article. 364 type ContentFieldsRelatedArticle struct { 365 Typename string `json:"__typename"` 366 // ID is the identifier of the content. 367 Id testutil.ID `json:"id"` 368 } 369 370 // GetTypename returns ContentFieldsRelatedArticle.Typename, and is useful for accessing the field via an interface. 371 func (v *ContentFieldsRelatedArticle) GetTypename() string { return v.Typename } 372 373 // GetId returns ContentFieldsRelatedArticle.Id, and is useful for accessing the field via an interface. 374 func (v *ContentFieldsRelatedArticle) GetId() testutil.ID { return v.Id } 375 376 // ContentFieldsRelatedContent includes the requested fields of the GraphQL interface Content. 377 // 378 // ContentFieldsRelatedContent is implemented by the following types: 379 // ContentFieldsRelatedArticle 380 // ContentFieldsRelatedTopic 381 // ContentFieldsRelatedVideo 382 // The GraphQL type's documentation follows. 383 // 384 // Content is implemented by various types like Article, Video, and Topic. 385 type ContentFieldsRelatedContent interface { 386 implementsGraphQLInterfaceContentFieldsRelatedContent() 387 // GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values). 388 GetTypename() string 389 // GetId returns the interface-field "id" from its implementation. 390 // The GraphQL interface field's documentation follows. 391 // 392 // ID is the identifier of the content. 393 GetId() testutil.ID 394 } 395 396 func (v *ContentFieldsRelatedArticle) implementsGraphQLInterfaceContentFieldsRelatedContent() {} 397 func (v *ContentFieldsRelatedTopic) implementsGraphQLInterfaceContentFieldsRelatedContent() {} 398 func (v *ContentFieldsRelatedVideo) implementsGraphQLInterfaceContentFieldsRelatedContent() {} 399 400 func __unmarshalContentFieldsRelatedContent(b []byte, v *ContentFieldsRelatedContent) error { 401 if string(b) == "null" { 402 return nil 403 } 404 405 var tn struct { 406 TypeName string `json:"__typename"` 407 } 408 err := json.Unmarshal(b, &tn) 409 if err != nil { 410 return err 411 } 412 413 switch tn.TypeName { 414 case "Article": 415 *v = new(ContentFieldsRelatedArticle) 416 return json.Unmarshal(b, *v) 417 case "Topic": 418 *v = new(ContentFieldsRelatedTopic) 419 return json.Unmarshal(b, *v) 420 case "Video": 421 *v = new(ContentFieldsRelatedVideo) 422 return json.Unmarshal(b, *v) 423 case "": 424 return fmt.Errorf( 425 "response was missing Content.__typename") 426 default: 427 return fmt.Errorf( 428 `unexpected concrete type for ContentFieldsRelatedContent: "%v"`, tn.TypeName) 429 } 430 } 431 432 func __marshalContentFieldsRelatedContent(v *ContentFieldsRelatedContent) ([]byte, error) { 433 434 var typename string 435 switch v := (*v).(type) { 436 case *ContentFieldsRelatedArticle: 437 typename = "Article" 438 439 result := struct { 440 TypeName string `json:"__typename"` 441 *ContentFieldsRelatedArticle 442 }{typename, v} 443 return json.Marshal(result) 444 case *ContentFieldsRelatedTopic: 445 typename = "Topic" 446 447 result := struct { 448 TypeName string `json:"__typename"` 449 *ContentFieldsRelatedTopic 450 }{typename, v} 451 return json.Marshal(result) 452 case *ContentFieldsRelatedVideo: 453 typename = "Video" 454 455 result := struct { 456 TypeName string `json:"__typename"` 457 *ContentFieldsRelatedVideo 458 }{typename, v} 459 return json.Marshal(result) 460 case nil: 461 return []byte("null"), nil 462 default: 463 return nil, fmt.Errorf( 464 `unexpected concrete type for ContentFieldsRelatedContent: "%T"`, v) 465 } 466 } 467 468 // ContentFieldsRelatedTopic includes the requested fields of the GraphQL type Topic. 469 type ContentFieldsRelatedTopic struct { 470 Typename string `json:"__typename"` 471 // ID is the identifier of the content. 472 Id testutil.ID `json:"id"` 473 } 474 475 // GetTypename returns ContentFieldsRelatedTopic.Typename, and is useful for accessing the field via an interface. 476 func (v *ContentFieldsRelatedTopic) GetTypename() string { return v.Typename } 477 478 // GetId returns ContentFieldsRelatedTopic.Id, and is useful for accessing the field via an interface. 479 func (v *ContentFieldsRelatedTopic) GetId() testutil.ID { return v.Id } 480 481 // ContentFieldsRelatedVideo includes the requested fields of the GraphQL type Video. 482 type ContentFieldsRelatedVideo struct { 483 Typename string `json:"__typename"` 484 // ID is the identifier of the content. 485 Id testutil.ID `json:"id"` 486 } 487 488 // GetTypename returns ContentFieldsRelatedVideo.Typename, and is useful for accessing the field via an interface. 489 func (v *ContentFieldsRelatedVideo) GetTypename() string { return v.Typename } 490 491 // GetId returns ContentFieldsRelatedVideo.Id, and is useful for accessing the field via an interface. 492 func (v *ContentFieldsRelatedVideo) GetId() testutil.ID { return v.Id } 493 494 // ContentFields includes the GraphQL fields of Topic requested by the fragment ContentFields. 495 // The GraphQL type's documentation follows. 496 // 497 // Content is implemented by various types like Article, Video, and Topic. 498 type ContentFieldsTopic struct { 499 Next ContentFieldsNextContent `json:"-"` 500 Related []ContentFieldsRelatedContent `json:"-"` 501 } 502 503 // GetNext returns ContentFieldsTopic.Next, and is useful for accessing the field via an interface. 504 func (v *ContentFieldsTopic) GetNext() ContentFieldsNextContent { return v.Next } 505 506 // GetRelated returns ContentFieldsTopic.Related, and is useful for accessing the field via an interface. 507 func (v *ContentFieldsTopic) GetRelated() []ContentFieldsRelatedContent { return v.Related } 508 509 func (v *ContentFieldsTopic) UnmarshalJSON(b []byte) error { 510 511 if string(b) == "null" { 512 return nil 513 } 514 515 var firstPass struct { 516 *ContentFieldsTopic 517 Next json.RawMessage `json:"next"` 518 Related []json.RawMessage `json:"related"` 519 graphql.NoUnmarshalJSON 520 } 521 firstPass.ContentFieldsTopic = v 522 523 err := json.Unmarshal(b, &firstPass) 524 if err != nil { 525 return err 526 } 527 528 { 529 dst := &v.Next 530 src := firstPass.Next 531 if len(src) != 0 && string(src) != "null" { 532 err = __unmarshalContentFieldsNextContent( 533 src, dst) 534 if err != nil { 535 return fmt.Errorf( 536 "unable to unmarshal ContentFieldsTopic.Next: %w", err) 537 } 538 } 539 } 540 541 { 542 dst := &v.Related 543 src := firstPass.Related 544 *dst = make( 545 []ContentFieldsRelatedContent, 546 len(src)) 547 for i, src := range src { 548 dst := &(*dst)[i] 549 if len(src) != 0 && string(src) != "null" { 550 err = __unmarshalContentFieldsRelatedContent( 551 src, dst) 552 if err != nil { 553 return fmt.Errorf( 554 "unable to unmarshal ContentFieldsTopic.Related: %w", err) 555 } 556 } 557 } 558 } 559 return nil 560 } 561 562 type __premarshalContentFieldsTopic struct { 563 Next json.RawMessage `json:"next"` 564 565 Related []json.RawMessage `json:"related"` 566 } 567 568 func (v *ContentFieldsTopic) MarshalJSON() ([]byte, error) { 569 premarshaled, err := v.__premarshalJSON() 570 if err != nil { 571 return nil, err 572 } 573 return json.Marshal(premarshaled) 574 } 575 576 func (v *ContentFieldsTopic) __premarshalJSON() (*__premarshalContentFieldsTopic, error) { 577 var retval __premarshalContentFieldsTopic 578 579 { 580 581 dst := &retval.Next 582 src := v.Next 583 var err error 584 *dst, err = __marshalContentFieldsNextContent( 585 &src) 586 if err != nil { 587 return nil, fmt.Errorf( 588 "unable to marshal ContentFieldsTopic.Next: %w", err) 589 } 590 } 591 { 592 593 dst := &retval.Related 594 src := v.Related 595 *dst = make( 596 []json.RawMessage, 597 len(src)) 598 for i, src := range src { 599 dst := &(*dst)[i] 600 var err error 601 *dst, err = __marshalContentFieldsRelatedContent( 602 &src) 603 if err != nil { 604 return nil, fmt.Errorf( 605 "unable to marshal ContentFieldsTopic.Related: %w", err) 606 } 607 } 608 } 609 return &retval, nil 610 } 611 612 // ContentFields includes the GraphQL fields of Video requested by the fragment ContentFields. 613 // The GraphQL type's documentation follows. 614 // 615 // Content is implemented by various types like Article, Video, and Topic. 616 type ContentFieldsVideo struct { 617 Next ContentFieldsNextContent `json:"-"` 618 Related []ContentFieldsRelatedContent `json:"-"` 619 } 620 621 // GetNext returns ContentFieldsVideo.Next, and is useful for accessing the field via an interface. 622 func (v *ContentFieldsVideo) GetNext() ContentFieldsNextContent { return v.Next } 623 624 // GetRelated returns ContentFieldsVideo.Related, and is useful for accessing the field via an interface. 625 func (v *ContentFieldsVideo) GetRelated() []ContentFieldsRelatedContent { return v.Related } 626 627 func (v *ContentFieldsVideo) UnmarshalJSON(b []byte) error { 628 629 if string(b) == "null" { 630 return nil 631 } 632 633 var firstPass struct { 634 *ContentFieldsVideo 635 Next json.RawMessage `json:"next"` 636 Related []json.RawMessage `json:"related"` 637 graphql.NoUnmarshalJSON 638 } 639 firstPass.ContentFieldsVideo = v 640 641 err := json.Unmarshal(b, &firstPass) 642 if err != nil { 643 return err 644 } 645 646 { 647 dst := &v.Next 648 src := firstPass.Next 649 if len(src) != 0 && string(src) != "null" { 650 err = __unmarshalContentFieldsNextContent( 651 src, dst) 652 if err != nil { 653 return fmt.Errorf( 654 "unable to unmarshal ContentFieldsVideo.Next: %w", err) 655 } 656 } 657 } 658 659 { 660 dst := &v.Related 661 src := firstPass.Related 662 *dst = make( 663 []ContentFieldsRelatedContent, 664 len(src)) 665 for i, src := range src { 666 dst := &(*dst)[i] 667 if len(src) != 0 && string(src) != "null" { 668 err = __unmarshalContentFieldsRelatedContent( 669 src, dst) 670 if err != nil { 671 return fmt.Errorf( 672 "unable to unmarshal ContentFieldsVideo.Related: %w", err) 673 } 674 } 675 } 676 } 677 return nil 678 } 679 680 type __premarshalContentFieldsVideo struct { 681 Next json.RawMessage `json:"next"` 682 683 Related []json.RawMessage `json:"related"` 684 } 685 686 func (v *ContentFieldsVideo) MarshalJSON() ([]byte, error) { 687 premarshaled, err := v.__premarshalJSON() 688 if err != nil { 689 return nil, err 690 } 691 return json.Marshal(premarshaled) 692 } 693 694 func (v *ContentFieldsVideo) __premarshalJSON() (*__premarshalContentFieldsVideo, error) { 695 var retval __premarshalContentFieldsVideo 696 697 { 698 699 dst := &retval.Next 700 src := v.Next 701 var err error 702 *dst, err = __marshalContentFieldsNextContent( 703 &src) 704 if err != nil { 705 return nil, fmt.Errorf( 706 "unable to marshal ContentFieldsVideo.Next: %w", err) 707 } 708 } 709 { 710 711 dst := &retval.Related 712 src := v.Related 713 *dst = make( 714 []json.RawMessage, 715 len(src)) 716 for i, src := range src { 717 dst := &(*dst)[i] 718 var err error 719 *dst, err = __marshalContentFieldsRelatedContent( 720 &src) 721 if err != nil { 722 return nil, fmt.Errorf( 723 "unable to marshal ContentFieldsVideo.Related: %w", err) 724 } 725 } 726 } 727 return &retval, nil 728 } 729 730 // CovariantInterfaceImplementationRandomItemArticle includes the requested fields of the GraphQL type Article. 731 type CovariantInterfaceImplementationRandomItemArticle struct { 732 Typename string `json:"__typename"` 733 // ID is the identifier of the content. 734 Id testutil.ID `json:"id"` 735 Next CovariantInterfaceImplementationRandomItemContentNextContent `json:"-"` 736 Related []CovariantInterfaceImplementationRandomItemContentRelatedContent `json:"-"` 737 } 738 739 // GetTypename returns CovariantInterfaceImplementationRandomItemArticle.Typename, and is useful for accessing the field via an interface. 740 func (v *CovariantInterfaceImplementationRandomItemArticle) GetTypename() string { return v.Typename } 741 742 // GetId returns CovariantInterfaceImplementationRandomItemArticle.Id, and is useful for accessing the field via an interface. 743 func (v *CovariantInterfaceImplementationRandomItemArticle) GetId() testutil.ID { return v.Id } 744 745 // GetNext returns CovariantInterfaceImplementationRandomItemArticle.Next, and is useful for accessing the field via an interface. 746 func (v *CovariantInterfaceImplementationRandomItemArticle) GetNext() CovariantInterfaceImplementationRandomItemContentNextContent { 747 return v.Next 748 } 749 750 // GetRelated returns CovariantInterfaceImplementationRandomItemArticle.Related, and is useful for accessing the field via an interface. 751 func (v *CovariantInterfaceImplementationRandomItemArticle) GetRelated() []CovariantInterfaceImplementationRandomItemContentRelatedContent { 752 return v.Related 753 } 754 755 func (v *CovariantInterfaceImplementationRandomItemArticle) UnmarshalJSON(b []byte) error { 756 757 if string(b) == "null" { 758 return nil 759 } 760 761 var firstPass struct { 762 *CovariantInterfaceImplementationRandomItemArticle 763 Next json.RawMessage `json:"next"` 764 Related []json.RawMessage `json:"related"` 765 graphql.NoUnmarshalJSON 766 } 767 firstPass.CovariantInterfaceImplementationRandomItemArticle = v 768 769 err := json.Unmarshal(b, &firstPass) 770 if err != nil { 771 return err 772 } 773 774 { 775 dst := &v.Next 776 src := firstPass.Next 777 if len(src) != 0 && string(src) != "null" { 778 err = __unmarshalCovariantInterfaceImplementationRandomItemContentNextContent( 779 src, dst) 780 if err != nil { 781 return fmt.Errorf( 782 "unable to unmarshal CovariantInterfaceImplementationRandomItemArticle.Next: %w", err) 783 } 784 } 785 } 786 787 { 788 dst := &v.Related 789 src := firstPass.Related 790 *dst = make( 791 []CovariantInterfaceImplementationRandomItemContentRelatedContent, 792 len(src)) 793 for i, src := range src { 794 dst := &(*dst)[i] 795 if len(src) != 0 && string(src) != "null" { 796 err = __unmarshalCovariantInterfaceImplementationRandomItemContentRelatedContent( 797 src, dst) 798 if err != nil { 799 return fmt.Errorf( 800 "unable to unmarshal CovariantInterfaceImplementationRandomItemArticle.Related: %w", err) 801 } 802 } 803 } 804 } 805 return nil 806 } 807 808 type __premarshalCovariantInterfaceImplementationRandomItemArticle struct { 809 Typename string `json:"__typename"` 810 811 Id testutil.ID `json:"id"` 812 813 Next json.RawMessage `json:"next"` 814 815 Related []json.RawMessage `json:"related"` 816 } 817 818 func (v *CovariantInterfaceImplementationRandomItemArticle) MarshalJSON() ([]byte, error) { 819 premarshaled, err := v.__premarshalJSON() 820 if err != nil { 821 return nil, err 822 } 823 return json.Marshal(premarshaled) 824 } 825 826 func (v *CovariantInterfaceImplementationRandomItemArticle) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemArticle, error) { 827 var retval __premarshalCovariantInterfaceImplementationRandomItemArticle 828 829 retval.Typename = v.Typename 830 retval.Id = v.Id 831 { 832 833 dst := &retval.Next 834 src := v.Next 835 var err error 836 *dst, err = __marshalCovariantInterfaceImplementationRandomItemContentNextContent( 837 &src) 838 if err != nil { 839 return nil, fmt.Errorf( 840 "unable to marshal CovariantInterfaceImplementationRandomItemArticle.Next: %w", err) 841 } 842 } 843 { 844 845 dst := &retval.Related 846 src := v.Related 847 *dst = make( 848 []json.RawMessage, 849 len(src)) 850 for i, src := range src { 851 dst := &(*dst)[i] 852 var err error 853 *dst, err = __marshalCovariantInterfaceImplementationRandomItemContentRelatedContent( 854 &src) 855 if err != nil { 856 return nil, fmt.Errorf( 857 "unable to marshal CovariantInterfaceImplementationRandomItemArticle.Related: %w", err) 858 } 859 } 860 } 861 return &retval, nil 862 } 863 864 // CovariantInterfaceImplementationRandomItemContent includes the requested fields of the GraphQL interface Content. 865 // 866 // CovariantInterfaceImplementationRandomItemContent is implemented by the following types: 867 // CovariantInterfaceImplementationRandomItemArticle 868 // CovariantInterfaceImplementationRandomItemTopic 869 // CovariantInterfaceImplementationRandomItemVideo 870 // The GraphQL type's documentation follows. 871 // 872 // Content is implemented by various types like Article, Video, and Topic. 873 type CovariantInterfaceImplementationRandomItemContent interface { 874 implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContent() 875 // GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values). 876 GetTypename() string 877 // GetId returns the interface-field "id" from its implementation. 878 // The GraphQL interface field's documentation follows. 879 // 880 // ID is the identifier of the content. 881 GetId() testutil.ID 882 // GetNext returns the interface-field "next" from its implementation. 883 GetNext() CovariantInterfaceImplementationRandomItemContentNextContent 884 // GetRelated returns the interface-field "related" from its implementation. 885 GetRelated() []CovariantInterfaceImplementationRandomItemContentRelatedContent 886 } 887 888 func (v *CovariantInterfaceImplementationRandomItemArticle) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContent() { 889 } 890 func (v *CovariantInterfaceImplementationRandomItemTopic) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContent() { 891 } 892 func (v *CovariantInterfaceImplementationRandomItemVideo) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContent() { 893 } 894 895 func __unmarshalCovariantInterfaceImplementationRandomItemContent(b []byte, v *CovariantInterfaceImplementationRandomItemContent) error { 896 if string(b) == "null" { 897 return nil 898 } 899 900 var tn struct { 901 TypeName string `json:"__typename"` 902 } 903 err := json.Unmarshal(b, &tn) 904 if err != nil { 905 return err 906 } 907 908 switch tn.TypeName { 909 case "Article": 910 *v = new(CovariantInterfaceImplementationRandomItemArticle) 911 return json.Unmarshal(b, *v) 912 case "Topic": 913 *v = new(CovariantInterfaceImplementationRandomItemTopic) 914 return json.Unmarshal(b, *v) 915 case "Video": 916 *v = new(CovariantInterfaceImplementationRandomItemVideo) 917 return json.Unmarshal(b, *v) 918 case "": 919 return fmt.Errorf( 920 "response was missing Content.__typename") 921 default: 922 return fmt.Errorf( 923 `unexpected concrete type for CovariantInterfaceImplementationRandomItemContent: "%v"`, tn.TypeName) 924 } 925 } 926 927 func __marshalCovariantInterfaceImplementationRandomItemContent(v *CovariantInterfaceImplementationRandomItemContent) ([]byte, error) { 928 929 var typename string 930 switch v := (*v).(type) { 931 case *CovariantInterfaceImplementationRandomItemArticle: 932 typename = "Article" 933 934 premarshaled, err := v.__premarshalJSON() 935 if err != nil { 936 return nil, err 937 } 938 result := struct { 939 TypeName string `json:"__typename"` 940 *__premarshalCovariantInterfaceImplementationRandomItemArticle 941 }{typename, premarshaled} 942 return json.Marshal(result) 943 case *CovariantInterfaceImplementationRandomItemTopic: 944 typename = "Topic" 945 946 premarshaled, err := v.__premarshalJSON() 947 if err != nil { 948 return nil, err 949 } 950 result := struct { 951 TypeName string `json:"__typename"` 952 *__premarshalCovariantInterfaceImplementationRandomItemTopic 953 }{typename, premarshaled} 954 return json.Marshal(result) 955 case *CovariantInterfaceImplementationRandomItemVideo: 956 typename = "Video" 957 958 premarshaled, err := v.__premarshalJSON() 959 if err != nil { 960 return nil, err 961 } 962 result := struct { 963 TypeName string `json:"__typename"` 964 *__premarshalCovariantInterfaceImplementationRandomItemVideo 965 }{typename, premarshaled} 966 return json.Marshal(result) 967 case nil: 968 return []byte("null"), nil 969 default: 970 return nil, fmt.Errorf( 971 `unexpected concrete type for CovariantInterfaceImplementationRandomItemContent: "%T"`, v) 972 } 973 } 974 975 // CovariantInterfaceImplementationRandomItemContentNextArticle includes the requested fields of the GraphQL type Article. 976 type CovariantInterfaceImplementationRandomItemContentNextArticle struct { 977 Typename string `json:"__typename"` 978 ContentFieldsArticle `json:"-"` 979 } 980 981 // GetTypename returns CovariantInterfaceImplementationRandomItemContentNextArticle.Typename, and is useful for accessing the field via an interface. 982 func (v *CovariantInterfaceImplementationRandomItemContentNextArticle) GetTypename() string { 983 return v.Typename 984 } 985 986 // GetNext returns CovariantInterfaceImplementationRandomItemContentNextArticle.Next, and is useful for accessing the field via an interface. 987 func (v *CovariantInterfaceImplementationRandomItemContentNextArticle) GetNext() ContentFieldsNextContent { 988 return v.ContentFieldsArticle.Next 989 } 990 991 // GetRelated returns CovariantInterfaceImplementationRandomItemContentNextArticle.Related, and is useful for accessing the field via an interface. 992 func (v *CovariantInterfaceImplementationRandomItemContentNextArticle) GetRelated() []ContentFieldsRelatedContent { 993 return v.ContentFieldsArticle.Related 994 } 995 996 func (v *CovariantInterfaceImplementationRandomItemContentNextArticle) UnmarshalJSON(b []byte) error { 997 998 if string(b) == "null" { 999 return nil 1000 } 1001 1002 var firstPass struct { 1003 *CovariantInterfaceImplementationRandomItemContentNextArticle 1004 graphql.NoUnmarshalJSON 1005 } 1006 firstPass.CovariantInterfaceImplementationRandomItemContentNextArticle = v 1007 1008 err := json.Unmarshal(b, &firstPass) 1009 if err != nil { 1010 return err 1011 } 1012 1013 err = json.Unmarshal( 1014 b, &v.ContentFieldsArticle) 1015 if err != nil { 1016 return err 1017 } 1018 return nil 1019 } 1020 1021 type __premarshalCovariantInterfaceImplementationRandomItemContentNextArticle struct { 1022 Typename string `json:"__typename"` 1023 1024 Next json.RawMessage `json:"next"` 1025 1026 Related []json.RawMessage `json:"related"` 1027 } 1028 1029 func (v *CovariantInterfaceImplementationRandomItemContentNextArticle) MarshalJSON() ([]byte, error) { 1030 premarshaled, err := v.__premarshalJSON() 1031 if err != nil { 1032 return nil, err 1033 } 1034 return json.Marshal(premarshaled) 1035 } 1036 1037 func (v *CovariantInterfaceImplementationRandomItemContentNextArticle) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemContentNextArticle, error) { 1038 var retval __premarshalCovariantInterfaceImplementationRandomItemContentNextArticle 1039 1040 retval.Typename = v.Typename 1041 { 1042 1043 dst := &retval.Next 1044 src := v.ContentFieldsArticle.Next 1045 var err error 1046 *dst, err = __marshalContentFieldsNextContent( 1047 &src) 1048 if err != nil { 1049 return nil, fmt.Errorf( 1050 "unable to marshal CovariantInterfaceImplementationRandomItemContentNextArticle.ContentFieldsArticle.Next: %w", err) 1051 } 1052 } 1053 { 1054 1055 dst := &retval.Related 1056 src := v.ContentFieldsArticle.Related 1057 *dst = make( 1058 []json.RawMessage, 1059 len(src)) 1060 for i, src := range src { 1061 dst := &(*dst)[i] 1062 var err error 1063 *dst, err = __marshalContentFieldsRelatedContent( 1064 &src) 1065 if err != nil { 1066 return nil, fmt.Errorf( 1067 "unable to marshal CovariantInterfaceImplementationRandomItemContentNextArticle.ContentFieldsArticle.Related: %w", err) 1068 } 1069 } 1070 } 1071 return &retval, nil 1072 } 1073 1074 // CovariantInterfaceImplementationRandomItemContentNextContent includes the requested fields of the GraphQL interface Content. 1075 // 1076 // CovariantInterfaceImplementationRandomItemContentNextContent is implemented by the following types: 1077 // CovariantInterfaceImplementationRandomItemContentNextArticle 1078 // CovariantInterfaceImplementationRandomItemContentNextTopic 1079 // CovariantInterfaceImplementationRandomItemContentNextVideo 1080 // The GraphQL type's documentation follows. 1081 // 1082 // Content is implemented by various types like Article, Video, and Topic. 1083 type CovariantInterfaceImplementationRandomItemContentNextContent interface { 1084 implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContentNextContent() 1085 // GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values). 1086 GetTypename() string 1087 ContentFields 1088 } 1089 1090 func (v *CovariantInterfaceImplementationRandomItemContentNextArticle) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContentNextContent() { 1091 } 1092 func (v *CovariantInterfaceImplementationRandomItemContentNextTopic) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContentNextContent() { 1093 } 1094 func (v *CovariantInterfaceImplementationRandomItemContentNextVideo) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContentNextContent() { 1095 } 1096 1097 func __unmarshalCovariantInterfaceImplementationRandomItemContentNextContent(b []byte, v *CovariantInterfaceImplementationRandomItemContentNextContent) error { 1098 if string(b) == "null" { 1099 return nil 1100 } 1101 1102 var tn struct { 1103 TypeName string `json:"__typename"` 1104 } 1105 err := json.Unmarshal(b, &tn) 1106 if err != nil { 1107 return err 1108 } 1109 1110 switch tn.TypeName { 1111 case "Article": 1112 *v = new(CovariantInterfaceImplementationRandomItemContentNextArticle) 1113 return json.Unmarshal(b, *v) 1114 case "Topic": 1115 *v = new(CovariantInterfaceImplementationRandomItemContentNextTopic) 1116 return json.Unmarshal(b, *v) 1117 case "Video": 1118 *v = new(CovariantInterfaceImplementationRandomItemContentNextVideo) 1119 return json.Unmarshal(b, *v) 1120 case "": 1121 return fmt.Errorf( 1122 "response was missing Content.__typename") 1123 default: 1124 return fmt.Errorf( 1125 `unexpected concrete type for CovariantInterfaceImplementationRandomItemContentNextContent: "%v"`, tn.TypeName) 1126 } 1127 } 1128 1129 func __marshalCovariantInterfaceImplementationRandomItemContentNextContent(v *CovariantInterfaceImplementationRandomItemContentNextContent) ([]byte, error) { 1130 1131 var typename string 1132 switch v := (*v).(type) { 1133 case *CovariantInterfaceImplementationRandomItemContentNextArticle: 1134 typename = "Article" 1135 1136 premarshaled, err := v.__premarshalJSON() 1137 if err != nil { 1138 return nil, err 1139 } 1140 result := struct { 1141 TypeName string `json:"__typename"` 1142 *__premarshalCovariantInterfaceImplementationRandomItemContentNextArticle 1143 }{typename, premarshaled} 1144 return json.Marshal(result) 1145 case *CovariantInterfaceImplementationRandomItemContentNextTopic: 1146 typename = "Topic" 1147 1148 premarshaled, err := v.__premarshalJSON() 1149 if err != nil { 1150 return nil, err 1151 } 1152 result := struct { 1153 TypeName string `json:"__typename"` 1154 *__premarshalCovariantInterfaceImplementationRandomItemContentNextTopic 1155 }{typename, premarshaled} 1156 return json.Marshal(result) 1157 case *CovariantInterfaceImplementationRandomItemContentNextVideo: 1158 typename = "Video" 1159 1160 premarshaled, err := v.__premarshalJSON() 1161 if err != nil { 1162 return nil, err 1163 } 1164 result := struct { 1165 TypeName string `json:"__typename"` 1166 *__premarshalCovariantInterfaceImplementationRandomItemContentNextVideo 1167 }{typename, premarshaled} 1168 return json.Marshal(result) 1169 case nil: 1170 return []byte("null"), nil 1171 default: 1172 return nil, fmt.Errorf( 1173 `unexpected concrete type for CovariantInterfaceImplementationRandomItemContentNextContent: "%T"`, v) 1174 } 1175 } 1176 1177 // CovariantInterfaceImplementationRandomItemContentNextTopic includes the requested fields of the GraphQL type Topic. 1178 type CovariantInterfaceImplementationRandomItemContentNextTopic struct { 1179 Typename string `json:"__typename"` 1180 ContentFieldsTopic `json:"-"` 1181 } 1182 1183 // GetTypename returns CovariantInterfaceImplementationRandomItemContentNextTopic.Typename, and is useful for accessing the field via an interface. 1184 func (v *CovariantInterfaceImplementationRandomItemContentNextTopic) GetTypename() string { 1185 return v.Typename 1186 } 1187 1188 // GetNext returns CovariantInterfaceImplementationRandomItemContentNextTopic.Next, and is useful for accessing the field via an interface. 1189 func (v *CovariantInterfaceImplementationRandomItemContentNextTopic) GetNext() ContentFieldsNextContent { 1190 return v.ContentFieldsTopic.Next 1191 } 1192 1193 // GetRelated returns CovariantInterfaceImplementationRandomItemContentNextTopic.Related, and is useful for accessing the field via an interface. 1194 func (v *CovariantInterfaceImplementationRandomItemContentNextTopic) GetRelated() []ContentFieldsRelatedContent { 1195 return v.ContentFieldsTopic.Related 1196 } 1197 1198 func (v *CovariantInterfaceImplementationRandomItemContentNextTopic) UnmarshalJSON(b []byte) error { 1199 1200 if string(b) == "null" { 1201 return nil 1202 } 1203 1204 var firstPass struct { 1205 *CovariantInterfaceImplementationRandomItemContentNextTopic 1206 graphql.NoUnmarshalJSON 1207 } 1208 firstPass.CovariantInterfaceImplementationRandomItemContentNextTopic = v 1209 1210 err := json.Unmarshal(b, &firstPass) 1211 if err != nil { 1212 return err 1213 } 1214 1215 err = json.Unmarshal( 1216 b, &v.ContentFieldsTopic) 1217 if err != nil { 1218 return err 1219 } 1220 return nil 1221 } 1222 1223 type __premarshalCovariantInterfaceImplementationRandomItemContentNextTopic struct { 1224 Typename string `json:"__typename"` 1225 1226 Next json.RawMessage `json:"next"` 1227 1228 Related []json.RawMessage `json:"related"` 1229 } 1230 1231 func (v *CovariantInterfaceImplementationRandomItemContentNextTopic) MarshalJSON() ([]byte, error) { 1232 premarshaled, err := v.__premarshalJSON() 1233 if err != nil { 1234 return nil, err 1235 } 1236 return json.Marshal(premarshaled) 1237 } 1238 1239 func (v *CovariantInterfaceImplementationRandomItemContentNextTopic) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemContentNextTopic, error) { 1240 var retval __premarshalCovariantInterfaceImplementationRandomItemContentNextTopic 1241 1242 retval.Typename = v.Typename 1243 { 1244 1245 dst := &retval.Next 1246 src := v.ContentFieldsTopic.Next 1247 var err error 1248 *dst, err = __marshalContentFieldsNextContent( 1249 &src) 1250 if err != nil { 1251 return nil, fmt.Errorf( 1252 "unable to marshal CovariantInterfaceImplementationRandomItemContentNextTopic.ContentFieldsTopic.Next: %w", err) 1253 } 1254 } 1255 { 1256 1257 dst := &retval.Related 1258 src := v.ContentFieldsTopic.Related 1259 *dst = make( 1260 []json.RawMessage, 1261 len(src)) 1262 for i, src := range src { 1263 dst := &(*dst)[i] 1264 var err error 1265 *dst, err = __marshalContentFieldsRelatedContent( 1266 &src) 1267 if err != nil { 1268 return nil, fmt.Errorf( 1269 "unable to marshal CovariantInterfaceImplementationRandomItemContentNextTopic.ContentFieldsTopic.Related: %w", err) 1270 } 1271 } 1272 } 1273 return &retval, nil 1274 } 1275 1276 // CovariantInterfaceImplementationRandomItemContentNextVideo includes the requested fields of the GraphQL type Video. 1277 type CovariantInterfaceImplementationRandomItemContentNextVideo struct { 1278 Typename string `json:"__typename"` 1279 ContentFieldsVideo `json:"-"` 1280 } 1281 1282 // GetTypename returns CovariantInterfaceImplementationRandomItemContentNextVideo.Typename, and is useful for accessing the field via an interface. 1283 func (v *CovariantInterfaceImplementationRandomItemContentNextVideo) GetTypename() string { 1284 return v.Typename 1285 } 1286 1287 // GetNext returns CovariantInterfaceImplementationRandomItemContentNextVideo.Next, and is useful for accessing the field via an interface. 1288 func (v *CovariantInterfaceImplementationRandomItemContentNextVideo) GetNext() ContentFieldsNextContent { 1289 return v.ContentFieldsVideo.Next 1290 } 1291 1292 // GetRelated returns CovariantInterfaceImplementationRandomItemContentNextVideo.Related, and is useful for accessing the field via an interface. 1293 func (v *CovariantInterfaceImplementationRandomItemContentNextVideo) GetRelated() []ContentFieldsRelatedContent { 1294 return v.ContentFieldsVideo.Related 1295 } 1296 1297 func (v *CovariantInterfaceImplementationRandomItemContentNextVideo) UnmarshalJSON(b []byte) error { 1298 1299 if string(b) == "null" { 1300 return nil 1301 } 1302 1303 var firstPass struct { 1304 *CovariantInterfaceImplementationRandomItemContentNextVideo 1305 graphql.NoUnmarshalJSON 1306 } 1307 firstPass.CovariantInterfaceImplementationRandomItemContentNextVideo = v 1308 1309 err := json.Unmarshal(b, &firstPass) 1310 if err != nil { 1311 return err 1312 } 1313 1314 err = json.Unmarshal( 1315 b, &v.ContentFieldsVideo) 1316 if err != nil { 1317 return err 1318 } 1319 return nil 1320 } 1321 1322 type __premarshalCovariantInterfaceImplementationRandomItemContentNextVideo struct { 1323 Typename string `json:"__typename"` 1324 1325 Next json.RawMessage `json:"next"` 1326 1327 Related []json.RawMessage `json:"related"` 1328 } 1329 1330 func (v *CovariantInterfaceImplementationRandomItemContentNextVideo) MarshalJSON() ([]byte, error) { 1331 premarshaled, err := v.__premarshalJSON() 1332 if err != nil { 1333 return nil, err 1334 } 1335 return json.Marshal(premarshaled) 1336 } 1337 1338 func (v *CovariantInterfaceImplementationRandomItemContentNextVideo) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemContentNextVideo, error) { 1339 var retval __premarshalCovariantInterfaceImplementationRandomItemContentNextVideo 1340 1341 retval.Typename = v.Typename 1342 { 1343 1344 dst := &retval.Next 1345 src := v.ContentFieldsVideo.Next 1346 var err error 1347 *dst, err = __marshalContentFieldsNextContent( 1348 &src) 1349 if err != nil { 1350 return nil, fmt.Errorf( 1351 "unable to marshal CovariantInterfaceImplementationRandomItemContentNextVideo.ContentFieldsVideo.Next: %w", err) 1352 } 1353 } 1354 { 1355 1356 dst := &retval.Related 1357 src := v.ContentFieldsVideo.Related 1358 *dst = make( 1359 []json.RawMessage, 1360 len(src)) 1361 for i, src := range src { 1362 dst := &(*dst)[i] 1363 var err error 1364 *dst, err = __marshalContentFieldsRelatedContent( 1365 &src) 1366 if err != nil { 1367 return nil, fmt.Errorf( 1368 "unable to marshal CovariantInterfaceImplementationRandomItemContentNextVideo.ContentFieldsVideo.Related: %w", err) 1369 } 1370 } 1371 } 1372 return &retval, nil 1373 } 1374 1375 // CovariantInterfaceImplementationRandomItemContentRelatedArticle includes the requested fields of the GraphQL type Article. 1376 type CovariantInterfaceImplementationRandomItemContentRelatedArticle struct { 1377 Typename string `json:"__typename"` 1378 ContentFieldsArticle `json:"-"` 1379 } 1380 1381 // GetTypename returns CovariantInterfaceImplementationRandomItemContentRelatedArticle.Typename, and is useful for accessing the field via an interface. 1382 func (v *CovariantInterfaceImplementationRandomItemContentRelatedArticle) GetTypename() string { 1383 return v.Typename 1384 } 1385 1386 // GetNext returns CovariantInterfaceImplementationRandomItemContentRelatedArticle.Next, and is useful for accessing the field via an interface. 1387 func (v *CovariantInterfaceImplementationRandomItemContentRelatedArticle) GetNext() ContentFieldsNextContent { 1388 return v.ContentFieldsArticle.Next 1389 } 1390 1391 // GetRelated returns CovariantInterfaceImplementationRandomItemContentRelatedArticle.Related, and is useful for accessing the field via an interface. 1392 func (v *CovariantInterfaceImplementationRandomItemContentRelatedArticle) GetRelated() []ContentFieldsRelatedContent { 1393 return v.ContentFieldsArticle.Related 1394 } 1395 1396 func (v *CovariantInterfaceImplementationRandomItemContentRelatedArticle) UnmarshalJSON(b []byte) error { 1397 1398 if string(b) == "null" { 1399 return nil 1400 } 1401 1402 var firstPass struct { 1403 *CovariantInterfaceImplementationRandomItemContentRelatedArticle 1404 graphql.NoUnmarshalJSON 1405 } 1406 firstPass.CovariantInterfaceImplementationRandomItemContentRelatedArticle = v 1407 1408 err := json.Unmarshal(b, &firstPass) 1409 if err != nil { 1410 return err 1411 } 1412 1413 err = json.Unmarshal( 1414 b, &v.ContentFieldsArticle) 1415 if err != nil { 1416 return err 1417 } 1418 return nil 1419 } 1420 1421 type __premarshalCovariantInterfaceImplementationRandomItemContentRelatedArticle struct { 1422 Typename string `json:"__typename"` 1423 1424 Next json.RawMessage `json:"next"` 1425 1426 Related []json.RawMessage `json:"related"` 1427 } 1428 1429 func (v *CovariantInterfaceImplementationRandomItemContentRelatedArticle) MarshalJSON() ([]byte, error) { 1430 premarshaled, err := v.__premarshalJSON() 1431 if err != nil { 1432 return nil, err 1433 } 1434 return json.Marshal(premarshaled) 1435 } 1436 1437 func (v *CovariantInterfaceImplementationRandomItemContentRelatedArticle) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemContentRelatedArticle, error) { 1438 var retval __premarshalCovariantInterfaceImplementationRandomItemContentRelatedArticle 1439 1440 retval.Typename = v.Typename 1441 { 1442 1443 dst := &retval.Next 1444 src := v.ContentFieldsArticle.Next 1445 var err error 1446 *dst, err = __marshalContentFieldsNextContent( 1447 &src) 1448 if err != nil { 1449 return nil, fmt.Errorf( 1450 "unable to marshal CovariantInterfaceImplementationRandomItemContentRelatedArticle.ContentFieldsArticle.Next: %w", err) 1451 } 1452 } 1453 { 1454 1455 dst := &retval.Related 1456 src := v.ContentFieldsArticle.Related 1457 *dst = make( 1458 []json.RawMessage, 1459 len(src)) 1460 for i, src := range src { 1461 dst := &(*dst)[i] 1462 var err error 1463 *dst, err = __marshalContentFieldsRelatedContent( 1464 &src) 1465 if err != nil { 1466 return nil, fmt.Errorf( 1467 "unable to marshal CovariantInterfaceImplementationRandomItemContentRelatedArticle.ContentFieldsArticle.Related: %w", err) 1468 } 1469 } 1470 } 1471 return &retval, nil 1472 } 1473 1474 // CovariantInterfaceImplementationRandomItemContentRelatedContent includes the requested fields of the GraphQL interface Content. 1475 // 1476 // CovariantInterfaceImplementationRandomItemContentRelatedContent is implemented by the following types: 1477 // CovariantInterfaceImplementationRandomItemContentRelatedArticle 1478 // CovariantInterfaceImplementationRandomItemContentRelatedTopic 1479 // CovariantInterfaceImplementationRandomItemContentRelatedVideo 1480 // The GraphQL type's documentation follows. 1481 // 1482 // Content is implemented by various types like Article, Video, and Topic. 1483 type CovariantInterfaceImplementationRandomItemContentRelatedContent interface { 1484 implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContentRelatedContent() 1485 // GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values). 1486 GetTypename() string 1487 ContentFields 1488 } 1489 1490 func (v *CovariantInterfaceImplementationRandomItemContentRelatedArticle) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContentRelatedContent() { 1491 } 1492 func (v *CovariantInterfaceImplementationRandomItemContentRelatedTopic) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContentRelatedContent() { 1493 } 1494 func (v *CovariantInterfaceImplementationRandomItemContentRelatedVideo) implementsGraphQLInterfaceCovariantInterfaceImplementationRandomItemContentRelatedContent() { 1495 } 1496 1497 func __unmarshalCovariantInterfaceImplementationRandomItemContentRelatedContent(b []byte, v *CovariantInterfaceImplementationRandomItemContentRelatedContent) error { 1498 if string(b) == "null" { 1499 return nil 1500 } 1501 1502 var tn struct { 1503 TypeName string `json:"__typename"` 1504 } 1505 err := json.Unmarshal(b, &tn) 1506 if err != nil { 1507 return err 1508 } 1509 1510 switch tn.TypeName { 1511 case "Article": 1512 *v = new(CovariantInterfaceImplementationRandomItemContentRelatedArticle) 1513 return json.Unmarshal(b, *v) 1514 case "Topic": 1515 *v = new(CovariantInterfaceImplementationRandomItemContentRelatedTopic) 1516 return json.Unmarshal(b, *v) 1517 case "Video": 1518 *v = new(CovariantInterfaceImplementationRandomItemContentRelatedVideo) 1519 return json.Unmarshal(b, *v) 1520 case "": 1521 return fmt.Errorf( 1522 "response was missing Content.__typename") 1523 default: 1524 return fmt.Errorf( 1525 `unexpected concrete type for CovariantInterfaceImplementationRandomItemContentRelatedContent: "%v"`, tn.TypeName) 1526 } 1527 } 1528 1529 func __marshalCovariantInterfaceImplementationRandomItemContentRelatedContent(v *CovariantInterfaceImplementationRandomItemContentRelatedContent) ([]byte, error) { 1530 1531 var typename string 1532 switch v := (*v).(type) { 1533 case *CovariantInterfaceImplementationRandomItemContentRelatedArticle: 1534 typename = "Article" 1535 1536 premarshaled, err := v.__premarshalJSON() 1537 if err != nil { 1538 return nil, err 1539 } 1540 result := struct { 1541 TypeName string `json:"__typename"` 1542 *__premarshalCovariantInterfaceImplementationRandomItemContentRelatedArticle 1543 }{typename, premarshaled} 1544 return json.Marshal(result) 1545 case *CovariantInterfaceImplementationRandomItemContentRelatedTopic: 1546 typename = "Topic" 1547 1548 premarshaled, err := v.__premarshalJSON() 1549 if err != nil { 1550 return nil, err 1551 } 1552 result := struct { 1553 TypeName string `json:"__typename"` 1554 *__premarshalCovariantInterfaceImplementationRandomItemContentRelatedTopic 1555 }{typename, premarshaled} 1556 return json.Marshal(result) 1557 case *CovariantInterfaceImplementationRandomItemContentRelatedVideo: 1558 typename = "Video" 1559 1560 premarshaled, err := v.__premarshalJSON() 1561 if err != nil { 1562 return nil, err 1563 } 1564 result := struct { 1565 TypeName string `json:"__typename"` 1566 *__premarshalCovariantInterfaceImplementationRandomItemContentRelatedVideo 1567 }{typename, premarshaled} 1568 return json.Marshal(result) 1569 case nil: 1570 return []byte("null"), nil 1571 default: 1572 return nil, fmt.Errorf( 1573 `unexpected concrete type for CovariantInterfaceImplementationRandomItemContentRelatedContent: "%T"`, v) 1574 } 1575 } 1576 1577 // CovariantInterfaceImplementationRandomItemContentRelatedTopic includes the requested fields of the GraphQL type Topic. 1578 type CovariantInterfaceImplementationRandomItemContentRelatedTopic struct { 1579 Typename string `json:"__typename"` 1580 ContentFieldsTopic `json:"-"` 1581 } 1582 1583 // GetTypename returns CovariantInterfaceImplementationRandomItemContentRelatedTopic.Typename, and is useful for accessing the field via an interface. 1584 func (v *CovariantInterfaceImplementationRandomItemContentRelatedTopic) GetTypename() string { 1585 return v.Typename 1586 } 1587 1588 // GetNext returns CovariantInterfaceImplementationRandomItemContentRelatedTopic.Next, and is useful for accessing the field via an interface. 1589 func (v *CovariantInterfaceImplementationRandomItemContentRelatedTopic) GetNext() ContentFieldsNextContent { 1590 return v.ContentFieldsTopic.Next 1591 } 1592 1593 // GetRelated returns CovariantInterfaceImplementationRandomItemContentRelatedTopic.Related, and is useful for accessing the field via an interface. 1594 func (v *CovariantInterfaceImplementationRandomItemContentRelatedTopic) GetRelated() []ContentFieldsRelatedContent { 1595 return v.ContentFieldsTopic.Related 1596 } 1597 1598 func (v *CovariantInterfaceImplementationRandomItemContentRelatedTopic) UnmarshalJSON(b []byte) error { 1599 1600 if string(b) == "null" { 1601 return nil 1602 } 1603 1604 var firstPass struct { 1605 *CovariantInterfaceImplementationRandomItemContentRelatedTopic 1606 graphql.NoUnmarshalJSON 1607 } 1608 firstPass.CovariantInterfaceImplementationRandomItemContentRelatedTopic = v 1609 1610 err := json.Unmarshal(b, &firstPass) 1611 if err != nil { 1612 return err 1613 } 1614 1615 err = json.Unmarshal( 1616 b, &v.ContentFieldsTopic) 1617 if err != nil { 1618 return err 1619 } 1620 return nil 1621 } 1622 1623 type __premarshalCovariantInterfaceImplementationRandomItemContentRelatedTopic struct { 1624 Typename string `json:"__typename"` 1625 1626 Next json.RawMessage `json:"next"` 1627 1628 Related []json.RawMessage `json:"related"` 1629 } 1630 1631 func (v *CovariantInterfaceImplementationRandomItemContentRelatedTopic) MarshalJSON() ([]byte, error) { 1632 premarshaled, err := v.__premarshalJSON() 1633 if err != nil { 1634 return nil, err 1635 } 1636 return json.Marshal(premarshaled) 1637 } 1638 1639 func (v *CovariantInterfaceImplementationRandomItemContentRelatedTopic) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemContentRelatedTopic, error) { 1640 var retval __premarshalCovariantInterfaceImplementationRandomItemContentRelatedTopic 1641 1642 retval.Typename = v.Typename 1643 { 1644 1645 dst := &retval.Next 1646 src := v.ContentFieldsTopic.Next 1647 var err error 1648 *dst, err = __marshalContentFieldsNextContent( 1649 &src) 1650 if err != nil { 1651 return nil, fmt.Errorf( 1652 "unable to marshal CovariantInterfaceImplementationRandomItemContentRelatedTopic.ContentFieldsTopic.Next: %w", err) 1653 } 1654 } 1655 { 1656 1657 dst := &retval.Related 1658 src := v.ContentFieldsTopic.Related 1659 *dst = make( 1660 []json.RawMessage, 1661 len(src)) 1662 for i, src := range src { 1663 dst := &(*dst)[i] 1664 var err error 1665 *dst, err = __marshalContentFieldsRelatedContent( 1666 &src) 1667 if err != nil { 1668 return nil, fmt.Errorf( 1669 "unable to marshal CovariantInterfaceImplementationRandomItemContentRelatedTopic.ContentFieldsTopic.Related: %w", err) 1670 } 1671 } 1672 } 1673 return &retval, nil 1674 } 1675 1676 // CovariantInterfaceImplementationRandomItemContentRelatedVideo includes the requested fields of the GraphQL type Video. 1677 type CovariantInterfaceImplementationRandomItemContentRelatedVideo struct { 1678 Typename string `json:"__typename"` 1679 ContentFieldsVideo `json:"-"` 1680 } 1681 1682 // GetTypename returns CovariantInterfaceImplementationRandomItemContentRelatedVideo.Typename, and is useful for accessing the field via an interface. 1683 func (v *CovariantInterfaceImplementationRandomItemContentRelatedVideo) GetTypename() string { 1684 return v.Typename 1685 } 1686 1687 // GetNext returns CovariantInterfaceImplementationRandomItemContentRelatedVideo.Next, and is useful for accessing the field via an interface. 1688 func (v *CovariantInterfaceImplementationRandomItemContentRelatedVideo) GetNext() ContentFieldsNextContent { 1689 return v.ContentFieldsVideo.Next 1690 } 1691 1692 // GetRelated returns CovariantInterfaceImplementationRandomItemContentRelatedVideo.Related, and is useful for accessing the field via an interface. 1693 func (v *CovariantInterfaceImplementationRandomItemContentRelatedVideo) GetRelated() []ContentFieldsRelatedContent { 1694 return v.ContentFieldsVideo.Related 1695 } 1696 1697 func (v *CovariantInterfaceImplementationRandomItemContentRelatedVideo) UnmarshalJSON(b []byte) error { 1698 1699 if string(b) == "null" { 1700 return nil 1701 } 1702 1703 var firstPass struct { 1704 *CovariantInterfaceImplementationRandomItemContentRelatedVideo 1705 graphql.NoUnmarshalJSON 1706 } 1707 firstPass.CovariantInterfaceImplementationRandomItemContentRelatedVideo = v 1708 1709 err := json.Unmarshal(b, &firstPass) 1710 if err != nil { 1711 return err 1712 } 1713 1714 err = json.Unmarshal( 1715 b, &v.ContentFieldsVideo) 1716 if err != nil { 1717 return err 1718 } 1719 return nil 1720 } 1721 1722 type __premarshalCovariantInterfaceImplementationRandomItemContentRelatedVideo struct { 1723 Typename string `json:"__typename"` 1724 1725 Next json.RawMessage `json:"next"` 1726 1727 Related []json.RawMessage `json:"related"` 1728 } 1729 1730 func (v *CovariantInterfaceImplementationRandomItemContentRelatedVideo) MarshalJSON() ([]byte, error) { 1731 premarshaled, err := v.__premarshalJSON() 1732 if err != nil { 1733 return nil, err 1734 } 1735 return json.Marshal(premarshaled) 1736 } 1737 1738 func (v *CovariantInterfaceImplementationRandomItemContentRelatedVideo) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemContentRelatedVideo, error) { 1739 var retval __premarshalCovariantInterfaceImplementationRandomItemContentRelatedVideo 1740 1741 retval.Typename = v.Typename 1742 { 1743 1744 dst := &retval.Next 1745 src := v.ContentFieldsVideo.Next 1746 var err error 1747 *dst, err = __marshalContentFieldsNextContent( 1748 &src) 1749 if err != nil { 1750 return nil, fmt.Errorf( 1751 "unable to marshal CovariantInterfaceImplementationRandomItemContentRelatedVideo.ContentFieldsVideo.Next: %w", err) 1752 } 1753 } 1754 { 1755 1756 dst := &retval.Related 1757 src := v.ContentFieldsVideo.Related 1758 *dst = make( 1759 []json.RawMessage, 1760 len(src)) 1761 for i, src := range src { 1762 dst := &(*dst)[i] 1763 var err error 1764 *dst, err = __marshalContentFieldsRelatedContent( 1765 &src) 1766 if err != nil { 1767 return nil, fmt.Errorf( 1768 "unable to marshal CovariantInterfaceImplementationRandomItemContentRelatedVideo.ContentFieldsVideo.Related: %w", err) 1769 } 1770 } 1771 } 1772 return &retval, nil 1773 } 1774 1775 // CovariantInterfaceImplementationRandomItemTopic includes the requested fields of the GraphQL type Topic. 1776 type CovariantInterfaceImplementationRandomItemTopic struct { 1777 Typename string `json:"__typename"` 1778 // ID is the identifier of the content. 1779 Id testutil.ID `json:"id"` 1780 Next CovariantInterfaceImplementationRandomItemContentNextContent `json:"-"` 1781 Related []CovariantInterfaceImplementationRandomItemContentRelatedContent `json:"-"` 1782 } 1783 1784 // GetTypename returns CovariantInterfaceImplementationRandomItemTopic.Typename, and is useful for accessing the field via an interface. 1785 func (v *CovariantInterfaceImplementationRandomItemTopic) GetTypename() string { return v.Typename } 1786 1787 // GetId returns CovariantInterfaceImplementationRandomItemTopic.Id, and is useful for accessing the field via an interface. 1788 func (v *CovariantInterfaceImplementationRandomItemTopic) GetId() testutil.ID { return v.Id } 1789 1790 // GetNext returns CovariantInterfaceImplementationRandomItemTopic.Next, and is useful for accessing the field via an interface. 1791 func (v *CovariantInterfaceImplementationRandomItemTopic) GetNext() CovariantInterfaceImplementationRandomItemContentNextContent { 1792 return v.Next 1793 } 1794 1795 // GetRelated returns CovariantInterfaceImplementationRandomItemTopic.Related, and is useful for accessing the field via an interface. 1796 func (v *CovariantInterfaceImplementationRandomItemTopic) GetRelated() []CovariantInterfaceImplementationRandomItemContentRelatedContent { 1797 return v.Related 1798 } 1799 1800 func (v *CovariantInterfaceImplementationRandomItemTopic) UnmarshalJSON(b []byte) error { 1801 1802 if string(b) == "null" { 1803 return nil 1804 } 1805 1806 var firstPass struct { 1807 *CovariantInterfaceImplementationRandomItemTopic 1808 Next json.RawMessage `json:"next"` 1809 Related []json.RawMessage `json:"related"` 1810 graphql.NoUnmarshalJSON 1811 } 1812 firstPass.CovariantInterfaceImplementationRandomItemTopic = v 1813 1814 err := json.Unmarshal(b, &firstPass) 1815 if err != nil { 1816 return err 1817 } 1818 1819 { 1820 dst := &v.Next 1821 src := firstPass.Next 1822 if len(src) != 0 && string(src) != "null" { 1823 err = __unmarshalCovariantInterfaceImplementationRandomItemContentNextContent( 1824 src, dst) 1825 if err != nil { 1826 return fmt.Errorf( 1827 "unable to unmarshal CovariantInterfaceImplementationRandomItemTopic.Next: %w", err) 1828 } 1829 } 1830 } 1831 1832 { 1833 dst := &v.Related 1834 src := firstPass.Related 1835 *dst = make( 1836 []CovariantInterfaceImplementationRandomItemContentRelatedContent, 1837 len(src)) 1838 for i, src := range src { 1839 dst := &(*dst)[i] 1840 if len(src) != 0 && string(src) != "null" { 1841 err = __unmarshalCovariantInterfaceImplementationRandomItemContentRelatedContent( 1842 src, dst) 1843 if err != nil { 1844 return fmt.Errorf( 1845 "unable to unmarshal CovariantInterfaceImplementationRandomItemTopic.Related: %w", err) 1846 } 1847 } 1848 } 1849 } 1850 return nil 1851 } 1852 1853 type __premarshalCovariantInterfaceImplementationRandomItemTopic struct { 1854 Typename string `json:"__typename"` 1855 1856 Id testutil.ID `json:"id"` 1857 1858 Next json.RawMessage `json:"next"` 1859 1860 Related []json.RawMessage `json:"related"` 1861 } 1862 1863 func (v *CovariantInterfaceImplementationRandomItemTopic) MarshalJSON() ([]byte, error) { 1864 premarshaled, err := v.__premarshalJSON() 1865 if err != nil { 1866 return nil, err 1867 } 1868 return json.Marshal(premarshaled) 1869 } 1870 1871 func (v *CovariantInterfaceImplementationRandomItemTopic) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemTopic, error) { 1872 var retval __premarshalCovariantInterfaceImplementationRandomItemTopic 1873 1874 retval.Typename = v.Typename 1875 retval.Id = v.Id 1876 { 1877 1878 dst := &retval.Next 1879 src := v.Next 1880 var err error 1881 *dst, err = __marshalCovariantInterfaceImplementationRandomItemContentNextContent( 1882 &src) 1883 if err != nil { 1884 return nil, fmt.Errorf( 1885 "unable to marshal CovariantInterfaceImplementationRandomItemTopic.Next: %w", err) 1886 } 1887 } 1888 { 1889 1890 dst := &retval.Related 1891 src := v.Related 1892 *dst = make( 1893 []json.RawMessage, 1894 len(src)) 1895 for i, src := range src { 1896 dst := &(*dst)[i] 1897 var err error 1898 *dst, err = __marshalCovariantInterfaceImplementationRandomItemContentRelatedContent( 1899 &src) 1900 if err != nil { 1901 return nil, fmt.Errorf( 1902 "unable to marshal CovariantInterfaceImplementationRandomItemTopic.Related: %w", err) 1903 } 1904 } 1905 } 1906 return &retval, nil 1907 } 1908 1909 // CovariantInterfaceImplementationRandomItemVideo includes the requested fields of the GraphQL type Video. 1910 type CovariantInterfaceImplementationRandomItemVideo struct { 1911 Typename string `json:"__typename"` 1912 // ID is the identifier of the content. 1913 Id testutil.ID `json:"id"` 1914 Next CovariantInterfaceImplementationRandomItemContentNextContent `json:"-"` 1915 Related []CovariantInterfaceImplementationRandomItemContentRelatedContent `json:"-"` 1916 } 1917 1918 // GetTypename returns CovariantInterfaceImplementationRandomItemVideo.Typename, and is useful for accessing the field via an interface. 1919 func (v *CovariantInterfaceImplementationRandomItemVideo) GetTypename() string { return v.Typename } 1920 1921 // GetId returns CovariantInterfaceImplementationRandomItemVideo.Id, and is useful for accessing the field via an interface. 1922 func (v *CovariantInterfaceImplementationRandomItemVideo) GetId() testutil.ID { return v.Id } 1923 1924 // GetNext returns CovariantInterfaceImplementationRandomItemVideo.Next, and is useful for accessing the field via an interface. 1925 func (v *CovariantInterfaceImplementationRandomItemVideo) GetNext() CovariantInterfaceImplementationRandomItemContentNextContent { 1926 return v.Next 1927 } 1928 1929 // GetRelated returns CovariantInterfaceImplementationRandomItemVideo.Related, and is useful for accessing the field via an interface. 1930 func (v *CovariantInterfaceImplementationRandomItemVideo) GetRelated() []CovariantInterfaceImplementationRandomItemContentRelatedContent { 1931 return v.Related 1932 } 1933 1934 func (v *CovariantInterfaceImplementationRandomItemVideo) UnmarshalJSON(b []byte) error { 1935 1936 if string(b) == "null" { 1937 return nil 1938 } 1939 1940 var firstPass struct { 1941 *CovariantInterfaceImplementationRandomItemVideo 1942 Next json.RawMessage `json:"next"` 1943 Related []json.RawMessage `json:"related"` 1944 graphql.NoUnmarshalJSON 1945 } 1946 firstPass.CovariantInterfaceImplementationRandomItemVideo = v 1947 1948 err := json.Unmarshal(b, &firstPass) 1949 if err != nil { 1950 return err 1951 } 1952 1953 { 1954 dst := &v.Next 1955 src := firstPass.Next 1956 if len(src) != 0 && string(src) != "null" { 1957 err = __unmarshalCovariantInterfaceImplementationRandomItemContentNextContent( 1958 src, dst) 1959 if err != nil { 1960 return fmt.Errorf( 1961 "unable to unmarshal CovariantInterfaceImplementationRandomItemVideo.Next: %w", err) 1962 } 1963 } 1964 } 1965 1966 { 1967 dst := &v.Related 1968 src := firstPass.Related 1969 *dst = make( 1970 []CovariantInterfaceImplementationRandomItemContentRelatedContent, 1971 len(src)) 1972 for i, src := range src { 1973 dst := &(*dst)[i] 1974 if len(src) != 0 && string(src) != "null" { 1975 err = __unmarshalCovariantInterfaceImplementationRandomItemContentRelatedContent( 1976 src, dst) 1977 if err != nil { 1978 return fmt.Errorf( 1979 "unable to unmarshal CovariantInterfaceImplementationRandomItemVideo.Related: %w", err) 1980 } 1981 } 1982 } 1983 } 1984 return nil 1985 } 1986 1987 type __premarshalCovariantInterfaceImplementationRandomItemVideo struct { 1988 Typename string `json:"__typename"` 1989 1990 Id testutil.ID `json:"id"` 1991 1992 Next json.RawMessage `json:"next"` 1993 1994 Related []json.RawMessage `json:"related"` 1995 } 1996 1997 func (v *CovariantInterfaceImplementationRandomItemVideo) MarshalJSON() ([]byte, error) { 1998 premarshaled, err := v.__premarshalJSON() 1999 if err != nil { 2000 return nil, err 2001 } 2002 return json.Marshal(premarshaled) 2003 } 2004 2005 func (v *CovariantInterfaceImplementationRandomItemVideo) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRandomItemVideo, error) { 2006 var retval __premarshalCovariantInterfaceImplementationRandomItemVideo 2007 2008 retval.Typename = v.Typename 2009 retval.Id = v.Id 2010 { 2011 2012 dst := &retval.Next 2013 src := v.Next 2014 var err error 2015 *dst, err = __marshalCovariantInterfaceImplementationRandomItemContentNextContent( 2016 &src) 2017 if err != nil { 2018 return nil, fmt.Errorf( 2019 "unable to marshal CovariantInterfaceImplementationRandomItemVideo.Next: %w", err) 2020 } 2021 } 2022 { 2023 2024 dst := &retval.Related 2025 src := v.Related 2026 *dst = make( 2027 []json.RawMessage, 2028 len(src)) 2029 for i, src := range src { 2030 dst := &(*dst)[i] 2031 var err error 2032 *dst, err = __marshalCovariantInterfaceImplementationRandomItemContentRelatedContent( 2033 &src) 2034 if err != nil { 2035 return nil, fmt.Errorf( 2036 "unable to marshal CovariantInterfaceImplementationRandomItemVideo.Related: %w", err) 2037 } 2038 } 2039 } 2040 return &retval, nil 2041 } 2042 2043 // CovariantInterfaceImplementationResponse is returned by CovariantInterfaceImplementation on success. 2044 type CovariantInterfaceImplementationResponse struct { 2045 RandomItem CovariantInterfaceImplementationRandomItemContent `json:"-"` 2046 Root CovariantInterfaceImplementationRootTopic `json:"root"` 2047 } 2048 2049 // GetRandomItem returns CovariantInterfaceImplementationResponse.RandomItem, and is useful for accessing the field via an interface. 2050 func (v *CovariantInterfaceImplementationResponse) GetRandomItem() CovariantInterfaceImplementationRandomItemContent { 2051 return v.RandomItem 2052 } 2053 2054 // GetRoot returns CovariantInterfaceImplementationResponse.Root, and is useful for accessing the field via an interface. 2055 func (v *CovariantInterfaceImplementationResponse) GetRoot() CovariantInterfaceImplementationRootTopic { 2056 return v.Root 2057 } 2058 2059 func (v *CovariantInterfaceImplementationResponse) UnmarshalJSON(b []byte) error { 2060 2061 if string(b) == "null" { 2062 return nil 2063 } 2064 2065 var firstPass struct { 2066 *CovariantInterfaceImplementationResponse 2067 RandomItem json.RawMessage `json:"randomItem"` 2068 graphql.NoUnmarshalJSON 2069 } 2070 firstPass.CovariantInterfaceImplementationResponse = v 2071 2072 err := json.Unmarshal(b, &firstPass) 2073 if err != nil { 2074 return err 2075 } 2076 2077 { 2078 dst := &v.RandomItem 2079 src := firstPass.RandomItem 2080 if len(src) != 0 && string(src) != "null" { 2081 err = __unmarshalCovariantInterfaceImplementationRandomItemContent( 2082 src, dst) 2083 if err != nil { 2084 return fmt.Errorf( 2085 "unable to unmarshal CovariantInterfaceImplementationResponse.RandomItem: %w", err) 2086 } 2087 } 2088 } 2089 return nil 2090 } 2091 2092 type __premarshalCovariantInterfaceImplementationResponse struct { 2093 RandomItem json.RawMessage `json:"randomItem"` 2094 2095 Root CovariantInterfaceImplementationRootTopic `json:"root"` 2096 } 2097 2098 func (v *CovariantInterfaceImplementationResponse) MarshalJSON() ([]byte, error) { 2099 premarshaled, err := v.__premarshalJSON() 2100 if err != nil { 2101 return nil, err 2102 } 2103 return json.Marshal(premarshaled) 2104 } 2105 2106 func (v *CovariantInterfaceImplementationResponse) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationResponse, error) { 2107 var retval __premarshalCovariantInterfaceImplementationResponse 2108 2109 { 2110 2111 dst := &retval.RandomItem 2112 src := v.RandomItem 2113 var err error 2114 *dst, err = __marshalCovariantInterfaceImplementationRandomItemContent( 2115 &src) 2116 if err != nil { 2117 return nil, fmt.Errorf( 2118 "unable to marshal CovariantInterfaceImplementationResponse.RandomItem: %w", err) 2119 } 2120 } 2121 retval.Root = v.Root 2122 return &retval, nil 2123 } 2124 2125 // CovariantInterfaceImplementationRootTopic includes the requested fields of the GraphQL type Topic. 2126 type CovariantInterfaceImplementationRootTopic struct { 2127 ContentFieldsTopic `json:"-"` 2128 TopicFields `json:"-"` 2129 Next CovariantInterfaceImplementationRootTopicNextTopic `json:"next"` 2130 Related []CovariantInterfaceImplementationRootTopicRelatedTopic `json:"related"` 2131 } 2132 2133 // GetNext returns CovariantInterfaceImplementationRootTopic.Next, and is useful for accessing the field via an interface. 2134 func (v *CovariantInterfaceImplementationRootTopic) GetNext() CovariantInterfaceImplementationRootTopicNextTopic { 2135 return v.Next 2136 } 2137 2138 // GetRelated returns CovariantInterfaceImplementationRootTopic.Related, and is useful for accessing the field via an interface. 2139 func (v *CovariantInterfaceImplementationRootTopic) GetRelated() []CovariantInterfaceImplementationRootTopicRelatedTopic { 2140 return v.Related 2141 } 2142 2143 func (v *CovariantInterfaceImplementationRootTopic) UnmarshalJSON(b []byte) error { 2144 2145 if string(b) == "null" { 2146 return nil 2147 } 2148 2149 var firstPass struct { 2150 *CovariantInterfaceImplementationRootTopic 2151 graphql.NoUnmarshalJSON 2152 } 2153 firstPass.CovariantInterfaceImplementationRootTopic = v 2154 2155 err := json.Unmarshal(b, &firstPass) 2156 if err != nil { 2157 return err 2158 } 2159 2160 err = json.Unmarshal( 2161 b, &v.ContentFieldsTopic) 2162 if err != nil { 2163 return err 2164 } 2165 err = json.Unmarshal( 2166 b, &v.TopicFields) 2167 if err != nil { 2168 return err 2169 } 2170 return nil 2171 } 2172 2173 type __premarshalCovariantInterfaceImplementationRootTopic struct { 2174 Next CovariantInterfaceImplementationRootTopicNextTopic `json:"next"` 2175 2176 Related []CovariantInterfaceImplementationRootTopicRelatedTopic `json:"related"` 2177 } 2178 2179 func (v *CovariantInterfaceImplementationRootTopic) MarshalJSON() ([]byte, error) { 2180 premarshaled, err := v.__premarshalJSON() 2181 if err != nil { 2182 return nil, err 2183 } 2184 return json.Marshal(premarshaled) 2185 } 2186 2187 func (v *CovariantInterfaceImplementationRootTopic) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRootTopic, error) { 2188 var retval __premarshalCovariantInterfaceImplementationRootTopic 2189 2190 retval.Next = v.Next 2191 retval.Related = v.Related 2192 return &retval, nil 2193 } 2194 2195 // CovariantInterfaceImplementationRootTopicNextTopic includes the requested fields of the GraphQL type Topic. 2196 type CovariantInterfaceImplementationRootTopicNextTopic struct { 2197 TopicFields `json:"-"` 2198 } 2199 2200 // GetNext returns CovariantInterfaceImplementationRootTopicNextTopic.Next, and is useful for accessing the field via an interface. 2201 func (v *CovariantInterfaceImplementationRootTopicNextTopic) GetNext() TopicFieldsNextTopic { 2202 return v.TopicFields.Next 2203 } 2204 2205 // GetRelated returns CovariantInterfaceImplementationRootTopicNextTopic.Related, and is useful for accessing the field via an interface. 2206 func (v *CovariantInterfaceImplementationRootTopicNextTopic) GetRelated() []TopicFieldsRelatedTopic { 2207 return v.TopicFields.Related 2208 } 2209 2210 func (v *CovariantInterfaceImplementationRootTopicNextTopic) UnmarshalJSON(b []byte) error { 2211 2212 if string(b) == "null" { 2213 return nil 2214 } 2215 2216 var firstPass struct { 2217 *CovariantInterfaceImplementationRootTopicNextTopic 2218 graphql.NoUnmarshalJSON 2219 } 2220 firstPass.CovariantInterfaceImplementationRootTopicNextTopic = v 2221 2222 err := json.Unmarshal(b, &firstPass) 2223 if err != nil { 2224 return err 2225 } 2226 2227 err = json.Unmarshal( 2228 b, &v.TopicFields) 2229 if err != nil { 2230 return err 2231 } 2232 return nil 2233 } 2234 2235 type __premarshalCovariantInterfaceImplementationRootTopicNextTopic struct { 2236 Next TopicFieldsNextTopic `json:"next"` 2237 2238 Related []TopicFieldsRelatedTopic `json:"related"` 2239 } 2240 2241 func (v *CovariantInterfaceImplementationRootTopicNextTopic) MarshalJSON() ([]byte, error) { 2242 premarshaled, err := v.__premarshalJSON() 2243 if err != nil { 2244 return nil, err 2245 } 2246 return json.Marshal(premarshaled) 2247 } 2248 2249 func (v *CovariantInterfaceImplementationRootTopicNextTopic) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRootTopicNextTopic, error) { 2250 var retval __premarshalCovariantInterfaceImplementationRootTopicNextTopic 2251 2252 retval.Next = v.TopicFields.Next 2253 retval.Related = v.TopicFields.Related 2254 return &retval, nil 2255 } 2256 2257 // CovariantInterfaceImplementationRootTopicRelatedTopic includes the requested fields of the GraphQL type Topic. 2258 type CovariantInterfaceImplementationRootTopicRelatedTopic struct { 2259 TopicFields `json:"-"` 2260 } 2261 2262 // GetNext returns CovariantInterfaceImplementationRootTopicRelatedTopic.Next, and is useful for accessing the field via an interface. 2263 func (v *CovariantInterfaceImplementationRootTopicRelatedTopic) GetNext() TopicFieldsNextTopic { 2264 return v.TopicFields.Next 2265 } 2266 2267 // GetRelated returns CovariantInterfaceImplementationRootTopicRelatedTopic.Related, and is useful for accessing the field via an interface. 2268 func (v *CovariantInterfaceImplementationRootTopicRelatedTopic) GetRelated() []TopicFieldsRelatedTopic { 2269 return v.TopicFields.Related 2270 } 2271 2272 func (v *CovariantInterfaceImplementationRootTopicRelatedTopic) UnmarshalJSON(b []byte) error { 2273 2274 if string(b) == "null" { 2275 return nil 2276 } 2277 2278 var firstPass struct { 2279 *CovariantInterfaceImplementationRootTopicRelatedTopic 2280 graphql.NoUnmarshalJSON 2281 } 2282 firstPass.CovariantInterfaceImplementationRootTopicRelatedTopic = v 2283 2284 err := json.Unmarshal(b, &firstPass) 2285 if err != nil { 2286 return err 2287 } 2288 2289 err = json.Unmarshal( 2290 b, &v.TopicFields) 2291 if err != nil { 2292 return err 2293 } 2294 return nil 2295 } 2296 2297 type __premarshalCovariantInterfaceImplementationRootTopicRelatedTopic struct { 2298 Next TopicFieldsNextTopic `json:"next"` 2299 2300 Related []TopicFieldsRelatedTopic `json:"related"` 2301 } 2302 2303 func (v *CovariantInterfaceImplementationRootTopicRelatedTopic) MarshalJSON() ([]byte, error) { 2304 premarshaled, err := v.__premarshalJSON() 2305 if err != nil { 2306 return nil, err 2307 } 2308 return json.Marshal(premarshaled) 2309 } 2310 2311 func (v *CovariantInterfaceImplementationRootTopicRelatedTopic) __premarshalJSON() (*__premarshalCovariantInterfaceImplementationRootTopicRelatedTopic, error) { 2312 var retval __premarshalCovariantInterfaceImplementationRootTopicRelatedTopic 2313 2314 retval.Next = v.TopicFields.Next 2315 retval.Related = v.TopicFields.Related 2316 return &retval, nil 2317 } 2318 2319 // TopicFields includes the GraphQL fields of Topic requested by the fragment TopicFields. 2320 type TopicFields struct { 2321 Next TopicFieldsNextTopic `json:"next"` 2322 Related []TopicFieldsRelatedTopic `json:"related"` 2323 } 2324 2325 // GetNext returns TopicFields.Next, and is useful for accessing the field via an interface. 2326 func (v *TopicFields) GetNext() TopicFieldsNextTopic { return v.Next } 2327 2328 // GetRelated returns TopicFields.Related, and is useful for accessing the field via an interface. 2329 func (v *TopicFields) GetRelated() []TopicFieldsRelatedTopic { return v.Related } 2330 2331 // TopicFieldsNextTopic includes the requested fields of the GraphQL type Topic. 2332 type TopicFieldsNextTopic struct { 2333 // ID is documented in the Content interface. 2334 Id testutil.ID `json:"id"` 2335 } 2336 2337 // GetId returns TopicFieldsNextTopic.Id, and is useful for accessing the field via an interface. 2338 func (v *TopicFieldsNextTopic) GetId() testutil.ID { return v.Id } 2339 2340 // TopicFieldsRelatedTopic includes the requested fields of the GraphQL type Topic. 2341 type TopicFieldsRelatedTopic struct { 2342 // ID is documented in the Content interface. 2343 Id testutil.ID `json:"id"` 2344 } 2345 2346 // GetId returns TopicFieldsRelatedTopic.Id, and is useful for accessing the field via an interface. 2347 func (v *TopicFieldsRelatedTopic) GetId() testutil.ID { return v.Id } 2348 2349 // The query or mutation executed by CovariantInterfaceImplementation. 2350 const CovariantInterfaceImplementation_Operation = ` 2351 query CovariantInterfaceImplementation { 2352 randomItem { 2353 __typename 2354 id 2355 next { 2356 __typename 2357 ... ContentFields 2358 } 2359 related { 2360 __typename 2361 ... ContentFields 2362 } 2363 } 2364 root { 2365 ... ContentFields 2366 ... TopicFields 2367 next { 2368 ... TopicFields 2369 } 2370 related { 2371 ... TopicFields 2372 } 2373 } 2374 } 2375 fragment ContentFields on Content { 2376 next { 2377 __typename 2378 id 2379 } 2380 related { 2381 __typename 2382 id 2383 } 2384 } 2385 fragment TopicFields on Topic { 2386 next { 2387 id 2388 } 2389 related { 2390 id 2391 } 2392 } 2393 ` 2394 2395 func CovariantInterfaceImplementation( 2396 client_ graphql.Client, 2397 ) (*CovariantInterfaceImplementationResponse, error) { 2398 req_ := &graphql.Request{ 2399 OpName: "CovariantInterfaceImplementation", 2400 Query: CovariantInterfaceImplementation_Operation, 2401 } 2402 var err_ error 2403 2404 var data_ CovariantInterfaceImplementationResponse 2405 resp_ := &graphql.Response{Data: &data_} 2406 2407 err_ = client_.MakeRequest( 2408 nil, 2409 req_, 2410 resp_, 2411 ) 2412 2413 return &data_, err_ 2414 } 2415