github.com/Desuuuu/genqlient@v0.5.3/generate/testdata/snapshots/TestGenerate-SimpleNamedFragment.graphql-SimpleNamedFragment.graphql.go (about)

     1  // Code generated by github.com/Desuuuu/genqlient, DO NOT EDIT.
     2  
     3  package test
     4  
     5  import (
     6  	"encoding/json"
     7  	"fmt"
     8  
     9  	"github.com/Desuuuu/genqlient/graphql"
    10  	"github.com/Desuuuu/genqlient/internal/testutil"
    11  )
    12  
    13  // SimpleNamedFragmentRandomItemArticle includes the requested fields of the GraphQL type Article.
    14  type SimpleNamedFragmentRandomItemArticle struct {
    15  	Typename string `json:"__typename"`
    16  	// ID is the identifier of the content.
    17  	Id   testutil.ID `json:"id"`
    18  	Name string      `json:"name"`
    19  }
    20  
    21  // GetTypename returns SimpleNamedFragmentRandomItemArticle.Typename, and is useful for accessing the field via an interface.
    22  func (v *SimpleNamedFragmentRandomItemArticle) GetTypename() string { return v.Typename }
    23  
    24  // GetId returns SimpleNamedFragmentRandomItemArticle.Id, and is useful for accessing the field via an interface.
    25  func (v *SimpleNamedFragmentRandomItemArticle) GetId() testutil.ID { return v.Id }
    26  
    27  // GetName returns SimpleNamedFragmentRandomItemArticle.Name, and is useful for accessing the field via an interface.
    28  func (v *SimpleNamedFragmentRandomItemArticle) GetName() string { return v.Name }
    29  
    30  // SimpleNamedFragmentRandomItemContent includes the requested fields of the GraphQL interface Content.
    31  //
    32  // SimpleNamedFragmentRandomItemContent is implemented by the following types:
    33  // SimpleNamedFragmentRandomItemArticle
    34  // SimpleNamedFragmentRandomItemVideo
    35  // SimpleNamedFragmentRandomItemTopic
    36  // The GraphQL type's documentation follows.
    37  //
    38  // Content is implemented by various types like Article, Video, and Topic.
    39  type SimpleNamedFragmentRandomItemContent interface {
    40  	implementsGraphQLInterfaceSimpleNamedFragmentRandomItemContent()
    41  	// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
    42  	GetTypename() string
    43  	// GetId returns the interface-field "id" from its implementation.
    44  	// The GraphQL interface field's documentation follows.
    45  	//
    46  	// ID is the identifier of the content.
    47  	GetId() testutil.ID
    48  	// GetName returns the interface-field "name" from its implementation.
    49  	GetName() string
    50  	GetContentArticle() (*SimpleNamedFragmentRandomItemArticle, bool)
    51  	GetContentVideo() (*SimpleNamedFragmentRandomItemVideo, bool)
    52  	GetContentTopic() (*SimpleNamedFragmentRandomItemTopic, bool)
    53  }
    54  
    55  func (v *SimpleNamedFragmentRandomItemArticle) implementsGraphQLInterfaceSimpleNamedFragmentRandomItemContent() {
    56  }
    57  func (v *SimpleNamedFragmentRandomItemArticle) GetContentArticle() (*SimpleNamedFragmentRandomItemArticle, bool) {
    58  	return v, true
    59  }
    60  func (v *SimpleNamedFragmentRandomItemArticle) GetContentVideo() (*SimpleNamedFragmentRandomItemVideo, bool) {
    61  	return nil, false
    62  }
    63  func (v *SimpleNamedFragmentRandomItemArticle) GetContentTopic() (*SimpleNamedFragmentRandomItemTopic, bool) {
    64  	return nil, false
    65  }
    66  func (v *SimpleNamedFragmentRandomItemVideo) implementsGraphQLInterfaceSimpleNamedFragmentRandomItemContent() {
    67  }
    68  func (v *SimpleNamedFragmentRandomItemVideo) GetContentArticle() (*SimpleNamedFragmentRandomItemArticle, bool) {
    69  	return nil, false
    70  }
    71  func (v *SimpleNamedFragmentRandomItemVideo) GetContentVideo() (*SimpleNamedFragmentRandomItemVideo, bool) {
    72  	return v, true
    73  }
    74  func (v *SimpleNamedFragmentRandomItemVideo) GetContentTopic() (*SimpleNamedFragmentRandomItemTopic, bool) {
    75  	return nil, false
    76  }
    77  func (v *SimpleNamedFragmentRandomItemTopic) implementsGraphQLInterfaceSimpleNamedFragmentRandomItemContent() {
    78  }
    79  func (v *SimpleNamedFragmentRandomItemTopic) GetContentArticle() (*SimpleNamedFragmentRandomItemArticle, bool) {
    80  	return nil, false
    81  }
    82  func (v *SimpleNamedFragmentRandomItemTopic) GetContentVideo() (*SimpleNamedFragmentRandomItemVideo, bool) {
    83  	return nil, false
    84  }
    85  func (v *SimpleNamedFragmentRandomItemTopic) GetContentTopic() (*SimpleNamedFragmentRandomItemTopic, bool) {
    86  	return v, true
    87  }
    88  
    89  func __unmarshalSimpleNamedFragmentRandomItemContent(b []byte, v *SimpleNamedFragmentRandomItemContent) error {
    90  	if string(b) == "null" {
    91  		return nil
    92  	}
    93  
    94  	var tn struct {
    95  		TypeName string `json:"__typename"`
    96  	}
    97  	err := json.Unmarshal(b, &tn)
    98  	if err != nil {
    99  		return err
   100  	}
   101  
   102  	switch tn.TypeName {
   103  	case "Article":
   104  		*v = new(SimpleNamedFragmentRandomItemArticle)
   105  		return json.Unmarshal(b, *v)
   106  	case "Video":
   107  		*v = new(SimpleNamedFragmentRandomItemVideo)
   108  		return json.Unmarshal(b, *v)
   109  	case "Topic":
   110  		*v = new(SimpleNamedFragmentRandomItemTopic)
   111  		return json.Unmarshal(b, *v)
   112  	case "":
   113  		return fmt.Errorf(
   114  			"response was missing Content.__typename")
   115  	default:
   116  		return fmt.Errorf(
   117  			`unexpected concrete type for SimpleNamedFragmentRandomItemContent: "%v"`, tn.TypeName)
   118  	}
   119  }
   120  
   121  func __marshalSimpleNamedFragmentRandomItemContent(v *SimpleNamedFragmentRandomItemContent) ([]byte, error) {
   122  
   123  	var typename string
   124  	switch v := (*v).(type) {
   125  	case *SimpleNamedFragmentRandomItemArticle:
   126  		typename = "Article"
   127  
   128  		result := struct {
   129  			TypeName string `json:"__typename"`
   130  			*SimpleNamedFragmentRandomItemArticle
   131  		}{typename, v}
   132  		return json.Marshal(result)
   133  	case *SimpleNamedFragmentRandomItemVideo:
   134  		typename = "Video"
   135  
   136  		premarshaled, err := v.__premarshalJSON()
   137  		if err != nil {
   138  			return nil, err
   139  		}
   140  		result := struct {
   141  			TypeName string `json:"__typename"`
   142  			*__premarshalSimpleNamedFragmentRandomItemVideo
   143  		}{typename, premarshaled}
   144  		return json.Marshal(result)
   145  	case *SimpleNamedFragmentRandomItemTopic:
   146  		typename = "Topic"
   147  
   148  		result := struct {
   149  			TypeName string `json:"__typename"`
   150  			*SimpleNamedFragmentRandomItemTopic
   151  		}{typename, v}
   152  		return json.Marshal(result)
   153  	case nil:
   154  		return []byte("null"), nil
   155  	default:
   156  		return nil, fmt.Errorf(
   157  			`unexpected concrete type for SimpleNamedFragmentRandomItemContent: "%T"`, v)
   158  	}
   159  }
   160  
   161  // SimpleNamedFragmentRandomItemTopic includes the requested fields of the GraphQL type Topic.
   162  type SimpleNamedFragmentRandomItemTopic struct {
   163  	Typename string `json:"__typename"`
   164  	// ID is the identifier of the content.
   165  	Id   testutil.ID `json:"id"`
   166  	Name string      `json:"name"`
   167  }
   168  
   169  // GetTypename returns SimpleNamedFragmentRandomItemTopic.Typename, and is useful for accessing the field via an interface.
   170  func (v *SimpleNamedFragmentRandomItemTopic) GetTypename() string { return v.Typename }
   171  
   172  // GetId returns SimpleNamedFragmentRandomItemTopic.Id, and is useful for accessing the field via an interface.
   173  func (v *SimpleNamedFragmentRandomItemTopic) GetId() testutil.ID { return v.Id }
   174  
   175  // GetName returns SimpleNamedFragmentRandomItemTopic.Name, and is useful for accessing the field via an interface.
   176  func (v *SimpleNamedFragmentRandomItemTopic) GetName() string { return v.Name }
   177  
   178  // SimpleNamedFragmentRandomItemVideo includes the requested fields of the GraphQL type Video.
   179  type SimpleNamedFragmentRandomItemVideo struct {
   180  	Typename string `json:"__typename"`
   181  	// ID is the identifier of the content.
   182  	Id          testutil.ID `json:"id"`
   183  	Name        string      `json:"name"`
   184  	VideoFields `json:"-"`
   185  }
   186  
   187  // GetTypename returns SimpleNamedFragmentRandomItemVideo.Typename, and is useful for accessing the field via an interface.
   188  func (v *SimpleNamedFragmentRandomItemVideo) GetTypename() string { return v.Typename }
   189  
   190  // GetId returns SimpleNamedFragmentRandomItemVideo.Id, and is useful for accessing the field via an interface.
   191  func (v *SimpleNamedFragmentRandomItemVideo) GetId() testutil.ID { return v.Id }
   192  
   193  // GetName returns SimpleNamedFragmentRandomItemVideo.Name, and is useful for accessing the field via an interface.
   194  func (v *SimpleNamedFragmentRandomItemVideo) GetName() string { return v.Name }
   195  
   196  // GetUrl returns SimpleNamedFragmentRandomItemVideo.Url, and is useful for accessing the field via an interface.
   197  func (v *SimpleNamedFragmentRandomItemVideo) GetUrl() string { return v.VideoFields.Url }
   198  
   199  // GetDuration returns SimpleNamedFragmentRandomItemVideo.Duration, and is useful for accessing the field via an interface.
   200  func (v *SimpleNamedFragmentRandomItemVideo) GetDuration() int { return v.VideoFields.Duration }
   201  
   202  // GetThumbnail returns SimpleNamedFragmentRandomItemVideo.Thumbnail, and is useful for accessing the field via an interface.
   203  func (v *SimpleNamedFragmentRandomItemVideo) GetThumbnail() VideoFieldsThumbnail {
   204  	return v.VideoFields.Thumbnail
   205  }
   206  
   207  func (v *SimpleNamedFragmentRandomItemVideo) UnmarshalJSON(b []byte) error {
   208  
   209  	if string(b) == "null" {
   210  		return nil
   211  	}
   212  
   213  	var firstPass struct {
   214  		*SimpleNamedFragmentRandomItemVideo
   215  		graphql.NoUnmarshalJSON
   216  	}
   217  	firstPass.SimpleNamedFragmentRandomItemVideo = v
   218  
   219  	err := json.Unmarshal(b, &firstPass)
   220  	if err != nil {
   221  		return err
   222  	}
   223  
   224  	err = json.Unmarshal(
   225  		b, &v.VideoFields)
   226  	if err != nil {
   227  		return err
   228  	}
   229  	return nil
   230  }
   231  
   232  type __premarshalSimpleNamedFragmentRandomItemVideo struct {
   233  	Typename string `json:"__typename"`
   234  
   235  	Id testutil.ID `json:"id"`
   236  
   237  	Name string `json:"name"`
   238  
   239  	Url string `json:"url"`
   240  
   241  	Duration int `json:"duration"`
   242  
   243  	Thumbnail VideoFieldsThumbnail `json:"thumbnail"`
   244  }
   245  
   246  func (v *SimpleNamedFragmentRandomItemVideo) MarshalJSON() ([]byte, error) {
   247  	premarshaled, err := v.__premarshalJSON()
   248  	if err != nil {
   249  		return nil, err
   250  	}
   251  	return json.Marshal(premarshaled)
   252  }
   253  
   254  func (v *SimpleNamedFragmentRandomItemVideo) __premarshalJSON() (*__premarshalSimpleNamedFragmentRandomItemVideo, error) {
   255  	var retval __premarshalSimpleNamedFragmentRandomItemVideo
   256  
   257  	retval.Typename = v.Typename
   258  	retval.Id = v.Id
   259  	retval.Name = v.Name
   260  	retval.Url = v.VideoFields.Url
   261  	retval.Duration = v.VideoFields.Duration
   262  	retval.Thumbnail = v.VideoFields.Thumbnail
   263  	return &retval, nil
   264  }
   265  
   266  // SimpleNamedFragmentRandomLeafArticle includes the requested fields of the GraphQL type Article.
   267  type SimpleNamedFragmentRandomLeafArticle struct {
   268  	Typename string `json:"__typename"`
   269  }
   270  
   271  // GetTypename returns SimpleNamedFragmentRandomLeafArticle.Typename, and is useful for accessing the field via an interface.
   272  func (v *SimpleNamedFragmentRandomLeafArticle) GetTypename() string { return v.Typename }
   273  
   274  // SimpleNamedFragmentRandomLeafLeafContent includes the requested fields of the GraphQL interface LeafContent.
   275  //
   276  // SimpleNamedFragmentRandomLeafLeafContent is implemented by the following types:
   277  // SimpleNamedFragmentRandomLeafArticle
   278  // SimpleNamedFragmentRandomLeafVideo
   279  // The GraphQL type's documentation follows.
   280  //
   281  // LeafContent represents content items that can't have child-nodes.
   282  type SimpleNamedFragmentRandomLeafLeafContent interface {
   283  	implementsGraphQLInterfaceSimpleNamedFragmentRandomLeafLeafContent()
   284  	// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
   285  	GetTypename() string
   286  	GetLeafContentArticle() (*SimpleNamedFragmentRandomLeafArticle, bool)
   287  	GetLeafContentVideo() (*SimpleNamedFragmentRandomLeafVideo, bool)
   288  }
   289  
   290  func (v *SimpleNamedFragmentRandomLeafArticle) implementsGraphQLInterfaceSimpleNamedFragmentRandomLeafLeafContent() {
   291  }
   292  func (v *SimpleNamedFragmentRandomLeafArticle) GetLeafContentArticle() (*SimpleNamedFragmentRandomLeafArticle, bool) {
   293  	return v, true
   294  }
   295  func (v *SimpleNamedFragmentRandomLeafArticle) GetLeafContentVideo() (*SimpleNamedFragmentRandomLeafVideo, bool) {
   296  	return nil, false
   297  }
   298  func (v *SimpleNamedFragmentRandomLeafVideo) implementsGraphQLInterfaceSimpleNamedFragmentRandomLeafLeafContent() {
   299  }
   300  func (v *SimpleNamedFragmentRandomLeafVideo) GetLeafContentArticle() (*SimpleNamedFragmentRandomLeafArticle, bool) {
   301  	return nil, false
   302  }
   303  func (v *SimpleNamedFragmentRandomLeafVideo) GetLeafContentVideo() (*SimpleNamedFragmentRandomLeafVideo, bool) {
   304  	return v, true
   305  }
   306  
   307  func __unmarshalSimpleNamedFragmentRandomLeafLeafContent(b []byte, v *SimpleNamedFragmentRandomLeafLeafContent) error {
   308  	if string(b) == "null" {
   309  		return nil
   310  	}
   311  
   312  	var tn struct {
   313  		TypeName string `json:"__typename"`
   314  	}
   315  	err := json.Unmarshal(b, &tn)
   316  	if err != nil {
   317  		return err
   318  	}
   319  
   320  	switch tn.TypeName {
   321  	case "Article":
   322  		*v = new(SimpleNamedFragmentRandomLeafArticle)
   323  		return json.Unmarshal(b, *v)
   324  	case "Video":
   325  		*v = new(SimpleNamedFragmentRandomLeafVideo)
   326  		return json.Unmarshal(b, *v)
   327  	case "":
   328  		return fmt.Errorf(
   329  			"response was missing LeafContent.__typename")
   330  	default:
   331  		return fmt.Errorf(
   332  			`unexpected concrete type for SimpleNamedFragmentRandomLeafLeafContent: "%v"`, tn.TypeName)
   333  	}
   334  }
   335  
   336  func __marshalSimpleNamedFragmentRandomLeafLeafContent(v *SimpleNamedFragmentRandomLeafLeafContent) ([]byte, error) {
   337  
   338  	var typename string
   339  	switch v := (*v).(type) {
   340  	case *SimpleNamedFragmentRandomLeafArticle:
   341  		typename = "Article"
   342  
   343  		result := struct {
   344  			TypeName string `json:"__typename"`
   345  			*SimpleNamedFragmentRandomLeafArticle
   346  		}{typename, v}
   347  		return json.Marshal(result)
   348  	case *SimpleNamedFragmentRandomLeafVideo:
   349  		typename = "Video"
   350  
   351  		premarshaled, err := v.__premarshalJSON()
   352  		if err != nil {
   353  			return nil, err
   354  		}
   355  		result := struct {
   356  			TypeName string `json:"__typename"`
   357  			*__premarshalSimpleNamedFragmentRandomLeafVideo
   358  		}{typename, premarshaled}
   359  		return json.Marshal(result)
   360  	case nil:
   361  		return []byte("null"), nil
   362  	default:
   363  		return nil, fmt.Errorf(
   364  			`unexpected concrete type for SimpleNamedFragmentRandomLeafLeafContent: "%T"`, v)
   365  	}
   366  }
   367  
   368  // SimpleNamedFragmentRandomLeafVideo includes the requested fields of the GraphQL type Video.
   369  type SimpleNamedFragmentRandomLeafVideo struct {
   370  	Typename    string `json:"__typename"`
   371  	VideoFields `json:"-"`
   372  }
   373  
   374  // GetTypename returns SimpleNamedFragmentRandomLeafVideo.Typename, and is useful for accessing the field via an interface.
   375  func (v *SimpleNamedFragmentRandomLeafVideo) GetTypename() string { return v.Typename }
   376  
   377  // GetId returns SimpleNamedFragmentRandomLeafVideo.Id, and is useful for accessing the field via an interface.
   378  func (v *SimpleNamedFragmentRandomLeafVideo) GetId() testutil.ID { return v.VideoFields.Id }
   379  
   380  // GetName returns SimpleNamedFragmentRandomLeafVideo.Name, and is useful for accessing the field via an interface.
   381  func (v *SimpleNamedFragmentRandomLeafVideo) GetName() string { return v.VideoFields.Name }
   382  
   383  // GetUrl returns SimpleNamedFragmentRandomLeafVideo.Url, and is useful for accessing the field via an interface.
   384  func (v *SimpleNamedFragmentRandomLeafVideo) GetUrl() string { return v.VideoFields.Url }
   385  
   386  // GetDuration returns SimpleNamedFragmentRandomLeafVideo.Duration, and is useful for accessing the field via an interface.
   387  func (v *SimpleNamedFragmentRandomLeafVideo) GetDuration() int { return v.VideoFields.Duration }
   388  
   389  // GetThumbnail returns SimpleNamedFragmentRandomLeafVideo.Thumbnail, and is useful for accessing the field via an interface.
   390  func (v *SimpleNamedFragmentRandomLeafVideo) GetThumbnail() VideoFieldsThumbnail {
   391  	return v.VideoFields.Thumbnail
   392  }
   393  
   394  func (v *SimpleNamedFragmentRandomLeafVideo) UnmarshalJSON(b []byte) error {
   395  
   396  	if string(b) == "null" {
   397  		return nil
   398  	}
   399  
   400  	var firstPass struct {
   401  		*SimpleNamedFragmentRandomLeafVideo
   402  		graphql.NoUnmarshalJSON
   403  	}
   404  	firstPass.SimpleNamedFragmentRandomLeafVideo = v
   405  
   406  	err := json.Unmarshal(b, &firstPass)
   407  	if err != nil {
   408  		return err
   409  	}
   410  
   411  	err = json.Unmarshal(
   412  		b, &v.VideoFields)
   413  	if err != nil {
   414  		return err
   415  	}
   416  	return nil
   417  }
   418  
   419  type __premarshalSimpleNamedFragmentRandomLeafVideo struct {
   420  	Typename string `json:"__typename"`
   421  
   422  	Id testutil.ID `json:"id"`
   423  
   424  	Name string `json:"name"`
   425  
   426  	Url string `json:"url"`
   427  
   428  	Duration int `json:"duration"`
   429  
   430  	Thumbnail VideoFieldsThumbnail `json:"thumbnail"`
   431  }
   432  
   433  func (v *SimpleNamedFragmentRandomLeafVideo) MarshalJSON() ([]byte, error) {
   434  	premarshaled, err := v.__premarshalJSON()
   435  	if err != nil {
   436  		return nil, err
   437  	}
   438  	return json.Marshal(premarshaled)
   439  }
   440  
   441  func (v *SimpleNamedFragmentRandomLeafVideo) __premarshalJSON() (*__premarshalSimpleNamedFragmentRandomLeafVideo, error) {
   442  	var retval __premarshalSimpleNamedFragmentRandomLeafVideo
   443  
   444  	retval.Typename = v.Typename
   445  	retval.Id = v.VideoFields.Id
   446  	retval.Name = v.VideoFields.Name
   447  	retval.Url = v.VideoFields.Url
   448  	retval.Duration = v.VideoFields.Duration
   449  	retval.Thumbnail = v.VideoFields.Thumbnail
   450  	return &retval, nil
   451  }
   452  
   453  // SimpleNamedFragmentResponse is returned by SimpleNamedFragment on success.
   454  type SimpleNamedFragmentResponse struct {
   455  	RandomItem SimpleNamedFragmentRandomItemContent     `json:"-"`
   456  	RandomLeaf SimpleNamedFragmentRandomLeafLeafContent `json:"-"`
   457  }
   458  
   459  // GetRandomItem returns SimpleNamedFragmentResponse.RandomItem, and is useful for accessing the field via an interface.
   460  func (v *SimpleNamedFragmentResponse) GetRandomItem() SimpleNamedFragmentRandomItemContent {
   461  	return v.RandomItem
   462  }
   463  
   464  // GetRandomLeaf returns SimpleNamedFragmentResponse.RandomLeaf, and is useful for accessing the field via an interface.
   465  func (v *SimpleNamedFragmentResponse) GetRandomLeaf() SimpleNamedFragmentRandomLeafLeafContent {
   466  	return v.RandomLeaf
   467  }
   468  
   469  func (v *SimpleNamedFragmentResponse) UnmarshalJSON(b []byte) error {
   470  
   471  	if string(b) == "null" {
   472  		return nil
   473  	}
   474  
   475  	var firstPass struct {
   476  		*SimpleNamedFragmentResponse
   477  		RandomItem json.RawMessage `json:"randomItem"`
   478  		RandomLeaf json.RawMessage `json:"randomLeaf"`
   479  		graphql.NoUnmarshalJSON
   480  	}
   481  	firstPass.SimpleNamedFragmentResponse = v
   482  
   483  	err := json.Unmarshal(b, &firstPass)
   484  	if err != nil {
   485  		return err
   486  	}
   487  
   488  	{
   489  		dst := &v.RandomItem
   490  		src := firstPass.RandomItem
   491  		if len(src) != 0 && string(src) != "null" {
   492  			err = __unmarshalSimpleNamedFragmentRandomItemContent(
   493  				src, dst)
   494  			if err != nil {
   495  				return fmt.Errorf(
   496  					"Unable to unmarshal SimpleNamedFragmentResponse.RandomItem: %w", err)
   497  			}
   498  		}
   499  	}
   500  
   501  	{
   502  		dst := &v.RandomLeaf
   503  		src := firstPass.RandomLeaf
   504  		if len(src) != 0 && string(src) != "null" {
   505  			err = __unmarshalSimpleNamedFragmentRandomLeafLeafContent(
   506  				src, dst)
   507  			if err != nil {
   508  				return fmt.Errorf(
   509  					"Unable to unmarshal SimpleNamedFragmentResponse.RandomLeaf: %w", err)
   510  			}
   511  		}
   512  	}
   513  	return nil
   514  }
   515  
   516  type __premarshalSimpleNamedFragmentResponse struct {
   517  	RandomItem json.RawMessage `json:"randomItem"`
   518  
   519  	RandomLeaf json.RawMessage `json:"randomLeaf"`
   520  }
   521  
   522  func (v *SimpleNamedFragmentResponse) MarshalJSON() ([]byte, error) {
   523  	premarshaled, err := v.__premarshalJSON()
   524  	if err != nil {
   525  		return nil, err
   526  	}
   527  	return json.Marshal(premarshaled)
   528  }
   529  
   530  func (v *SimpleNamedFragmentResponse) __premarshalJSON() (*__premarshalSimpleNamedFragmentResponse, error) {
   531  	var retval __premarshalSimpleNamedFragmentResponse
   532  
   533  	{
   534  
   535  		dst := &retval.RandomItem
   536  		src := v.RandomItem
   537  		var err error
   538  		*dst, err = __marshalSimpleNamedFragmentRandomItemContent(
   539  			&src)
   540  		if err != nil {
   541  			return nil, fmt.Errorf(
   542  				"Unable to marshal SimpleNamedFragmentResponse.RandomItem: %w", err)
   543  		}
   544  	}
   545  	{
   546  
   547  		dst := &retval.RandomLeaf
   548  		src := v.RandomLeaf
   549  		var err error
   550  		*dst, err = __marshalSimpleNamedFragmentRandomLeafLeafContent(
   551  			&src)
   552  		if err != nil {
   553  			return nil, fmt.Errorf(
   554  				"Unable to marshal SimpleNamedFragmentResponse.RandomLeaf: %w", err)
   555  		}
   556  	}
   557  	return &retval, nil
   558  }
   559  
   560  // VideoFields includes the GraphQL fields of Video requested by the fragment VideoFields.
   561  type VideoFields struct {
   562  	// ID is documented in the Content interface.
   563  	Id        testutil.ID          `json:"id"`
   564  	Name      string               `json:"name"`
   565  	Url       string               `json:"url"`
   566  	Duration  int                  `json:"duration"`
   567  	Thumbnail VideoFieldsThumbnail `json:"thumbnail"`
   568  }
   569  
   570  // GetId returns VideoFields.Id, and is useful for accessing the field via an interface.
   571  func (v *VideoFields) GetId() testutil.ID { return v.Id }
   572  
   573  // GetName returns VideoFields.Name, and is useful for accessing the field via an interface.
   574  func (v *VideoFields) GetName() string { return v.Name }
   575  
   576  // GetUrl returns VideoFields.Url, and is useful for accessing the field via an interface.
   577  func (v *VideoFields) GetUrl() string { return v.Url }
   578  
   579  // GetDuration returns VideoFields.Duration, and is useful for accessing the field via an interface.
   580  func (v *VideoFields) GetDuration() int { return v.Duration }
   581  
   582  // GetThumbnail returns VideoFields.Thumbnail, and is useful for accessing the field via an interface.
   583  func (v *VideoFields) GetThumbnail() VideoFieldsThumbnail { return v.Thumbnail }
   584  
   585  // VideoFieldsThumbnail includes the requested fields of the GraphQL type Thumbnail.
   586  type VideoFieldsThumbnail struct {
   587  	Id testutil.ID `json:"id"`
   588  }
   589  
   590  // GetId returns VideoFieldsThumbnail.Id, and is useful for accessing the field via an interface.
   591  func (v *VideoFieldsThumbnail) GetId() testutil.ID { return v.Id }
   592  
   593  func SimpleNamedFragment(
   594  	client graphql.Client,
   595  ) (*SimpleNamedFragmentResponse, error) {
   596  	req := &graphql.Request{
   597  		OpName: "SimpleNamedFragment",
   598  		Query: `
   599  query SimpleNamedFragment {
   600  	randomItem {
   601  		__typename
   602  		id
   603  		name
   604  		... VideoFields
   605  	}
   606  	randomLeaf {
   607  		__typename
   608  		... VideoFields
   609  	}
   610  }
   611  fragment VideoFields on Video {
   612  	id
   613  	name
   614  	url
   615  	duration
   616  	thumbnail {
   617  		id
   618  	}
   619  }
   620  `,
   621  	}
   622  	var err error
   623  
   624  	var data SimpleNamedFragmentResponse
   625  	resp := &graphql.Response{Data: &data}
   626  
   627  	err = client.MakeRequest(
   628  		nil,
   629  		req,
   630  		resp,
   631  	)
   632  
   633  	return &data, err
   634  }
   635