package test // Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( "encoding/json" "fmt" "github.com/Khan/genqlient/graphql" "github.com/Khan/genqlient/internal/testutil" ) // InterfaceNoFragmentsQueryRandomItemArticle includes the requested fields of the GraphQL type Article. type InterfaceNoFragmentsQueryRandomItemArticle struct { Typename string `json:"__typename"` // ID is the identifier of the content. Id testutil.ID `json:"id"` Name string `json:"name"` } // InterfaceNoFragmentsQueryRandomItemContent includes the requested fields of the GraphQL type Content. // The GraphQL type's documentation follows. // // Content is implemented by various types like Article, Video, and Topic. type InterfaceNoFragmentsQueryRandomItemContent interface { implementsGraphQLInterfaceInterfaceNoFragmentsQueryRandomItemContent() } func (v *InterfaceNoFragmentsQueryRandomItemArticle) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRandomItemContent() { } func (v *InterfaceNoFragmentsQueryRandomItemVideo) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRandomItemContent() { } func (v *InterfaceNoFragmentsQueryRandomItemTopic) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRandomItemContent() { } func __unmarshalInterfaceNoFragmentsQueryRandomItemContent(v *InterfaceNoFragmentsQueryRandomItemContent, m json.RawMessage) error { if string(m) == "null" { return nil } var tn struct { TypeName string `json:"__typename"` } err := json.Unmarshal(m, &tn) if err != nil { return err } switch tn.TypeName { case "Article": *v = new(InterfaceNoFragmentsQueryRandomItemArticle) return json.Unmarshal(m, *v) case "Video": *v = new(InterfaceNoFragmentsQueryRandomItemVideo) return json.Unmarshal(m, *v) case "Topic": *v = new(InterfaceNoFragmentsQueryRandomItemTopic) return json.Unmarshal(m, *v) default: return fmt.Errorf( `Unexpected concrete type for InterfaceNoFragmentsQueryRandomItemContent: "%v"`, tn.TypeName) } } // InterfaceNoFragmentsQueryRandomItemTopic includes the requested fields of the GraphQL type Topic. type InterfaceNoFragmentsQueryRandomItemTopic struct { Typename string `json:"__typename"` // ID is the identifier of the content. Id testutil.ID `json:"id"` Name string `json:"name"` } // InterfaceNoFragmentsQueryRandomItemVideo includes the requested fields of the GraphQL type Video. type InterfaceNoFragmentsQueryRandomItemVideo struct { Typename string `json:"__typename"` // ID is the identifier of the content. Id testutil.ID `json:"id"` Name string `json:"name"` } // InterfaceNoFragmentsQueryResponse is returned by InterfaceNoFragmentsQuery on success. type InterfaceNoFragmentsQueryResponse struct { Root InterfaceNoFragmentsQueryRootTopic `json:"root"` RandomItem InterfaceNoFragmentsQueryRandomItemContent `json:"-"` } func (v *InterfaceNoFragmentsQueryResponse) UnmarshalJSON(b []byte) error { type InterfaceNoFragmentsQueryResponseWrapper InterfaceNoFragmentsQueryResponse var firstPass struct { *InterfaceNoFragmentsQueryResponseWrapper RandomItem json.RawMessage `json:"randomItem"` } firstPass.InterfaceNoFragmentsQueryResponseWrapper = (*InterfaceNoFragmentsQueryResponseWrapper)(v) err := json.Unmarshal(b, &firstPass) if err != nil { return err } err = __unmarshalInterfaceNoFragmentsQueryRandomItemContent( &v.RandomItem, firstPass.RandomItem) if err != nil { return err } return nil } // InterfaceNoFragmentsQueryRootTopic includes the requested fields of the GraphQL type Topic. type InterfaceNoFragmentsQueryRootTopic struct { // ID is documented in the Content interface. Id testutil.ID `json:"id"` Name string `json:"name"` } func InterfaceNoFragmentsQuery( client graphql.Client, ) (*InterfaceNoFragmentsQueryResponse, error) { var retval InterfaceNoFragmentsQueryResponse err := client.MakeRequest( nil, "InterfaceNoFragmentsQuery", ` query InterfaceNoFragmentsQuery { root { id name } randomItem { __typename id name } } `, &retval, nil, ) return &retval, err }