## Summary: We guarantee that we never return a nil response, so you can safely do ``` resp, err := myQuery(...) return resp.Field.SubField, err ``` And furthermore, if the error was a GraphQL error, `resp` may even be nonzero; other, non-failing fields may be set. (This depends on the server, of course.) But we weren't testing either of those. Now we do. ## Test plan: make check Author: benjaminjkraft Reviewers: jvoll, aberkan, dnerdy, MiguelCastillo, mahtabsabet Required Reviewers: Approved By: jvoll Checks: ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Lint, ✅ Test (1.17), ✅ Test (1.16), ✅ Test (1.15), ✅ Test (1.14), ✅ Lint Pull Request URL: https://github.com/Khan/genqlient/pull/83
1351 lines
37 KiB
Go
1351 lines
37 KiB
Go
package integration
|
|
|
|
// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/Khan/genqlient/graphql"
|
|
)
|
|
|
|
// AnimalFields includes the GraphQL fields of Animal requested by the fragment AnimalFields.
|
|
type AnimalFields struct {
|
|
Id string `json:"id"`
|
|
Hair AnimalFieldsHairBeingsHair `json:"hair"`
|
|
Owner AnimalFieldsOwnerBeing `json:"-"`
|
|
}
|
|
|
|
func (v *AnimalFields) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*AnimalFields
|
|
Owner json.RawMessage `json:"owner"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.AnimalFields = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
{
|
|
target := &v.Owner
|
|
raw := firstPass.Owner
|
|
err = __unmarshalAnimalFieldsOwnerBeing(
|
|
target, raw)
|
|
if err != nil {
|
|
return fmt.Errorf(
|
|
"Unable to unmarshal AnimalFields.Owner: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// AnimalFieldsHairBeingsHair includes the requested fields of the GraphQL type BeingsHair.
|
|
type AnimalFieldsHairBeingsHair struct {
|
|
HasHair bool `json:"hasHair"`
|
|
}
|
|
|
|
// AnimalFieldsOwnerAnimal includes the requested fields of the GraphQL type Animal.
|
|
type AnimalFieldsOwnerAnimal struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
}
|
|
|
|
// AnimalFieldsOwnerBeing includes the requested fields of the GraphQL interface Being.
|
|
//
|
|
// AnimalFieldsOwnerBeing is implemented by the following types:
|
|
// AnimalFieldsOwnerUser
|
|
// AnimalFieldsOwnerAnimal
|
|
type AnimalFieldsOwnerBeing interface {
|
|
implementsGraphQLInterfaceAnimalFieldsOwnerBeing()
|
|
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
|
|
GetTypename() string
|
|
// GetId returns the interface-field "id" from its implementation.
|
|
GetId() string
|
|
}
|
|
|
|
func (v *AnimalFieldsOwnerUser) implementsGraphQLInterfaceAnimalFieldsOwnerBeing() {}
|
|
|
|
// GetTypename is a part of, and documented with, the interface AnimalFieldsOwnerBeing.
|
|
func (v *AnimalFieldsOwnerUser) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface AnimalFieldsOwnerBeing.
|
|
func (v *AnimalFieldsOwnerUser) GetId() string { return v.Id }
|
|
|
|
func (v *AnimalFieldsOwnerAnimal) implementsGraphQLInterfaceAnimalFieldsOwnerBeing() {}
|
|
|
|
// GetTypename is a part of, and documented with, the interface AnimalFieldsOwnerBeing.
|
|
func (v *AnimalFieldsOwnerAnimal) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface AnimalFieldsOwnerBeing.
|
|
func (v *AnimalFieldsOwnerAnimal) GetId() string { return v.Id }
|
|
|
|
func __unmarshalAnimalFieldsOwnerBeing(v *AnimalFieldsOwnerBeing, 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 "User":
|
|
*v = new(AnimalFieldsOwnerUser)
|
|
return json.Unmarshal(m, *v)
|
|
case "Animal":
|
|
*v = new(AnimalFieldsOwnerAnimal)
|
|
return json.Unmarshal(m, *v)
|
|
case "":
|
|
return fmt.Errorf(
|
|
"Response was missing Being.__typename")
|
|
default:
|
|
return fmt.Errorf(
|
|
`Unexpected concrete type for AnimalFieldsOwnerBeing: "%v"`, tn.TypeName)
|
|
}
|
|
}
|
|
|
|
// AnimalFieldsOwnerUser includes the requested fields of the GraphQL type User.
|
|
type AnimalFieldsOwnerUser struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
UserFields `json:"-"`
|
|
LuckyFieldsUser `json:"-"`
|
|
}
|
|
|
|
func (v *AnimalFieldsOwnerUser) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*AnimalFieldsOwnerUser
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.AnimalFieldsOwnerUser = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = json.Unmarshal(
|
|
b, &v.UserFields)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = json.Unmarshal(
|
|
b, &v.LuckyFieldsUser)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// LuckyFields includes the GraphQL fields of Lucky requested by the fragment LuckyFields.
|
|
//
|
|
// LuckyFields is implemented by the following types:
|
|
// LuckyFieldsUser
|
|
type LuckyFields interface {
|
|
implementsGraphQLInterfaceLuckyFields()
|
|
// GetLuckyNumber returns the interface-field "luckyNumber" from its implementation.
|
|
GetLuckyNumber() int
|
|
}
|
|
|
|
func (v *LuckyFieldsUser) implementsGraphQLInterfaceLuckyFields() {}
|
|
|
|
// GetLuckyNumber is a part of, and documented with, the interface LuckyFields.
|
|
func (v *LuckyFieldsUser) GetLuckyNumber() int { return v.LuckyNumber }
|
|
|
|
func __unmarshalLuckyFields(v *LuckyFields, 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 "User":
|
|
*v = new(LuckyFieldsUser)
|
|
return json.Unmarshal(m, *v)
|
|
case "":
|
|
return fmt.Errorf(
|
|
"Response was missing Lucky.__typename")
|
|
default:
|
|
return fmt.Errorf(
|
|
`Unexpected concrete type for LuckyFields: "%v"`, tn.TypeName)
|
|
}
|
|
}
|
|
|
|
// LuckyFields includes the GraphQL fields of User requested by the fragment LuckyFields.
|
|
type LuckyFieldsUser struct {
|
|
MoreUserFields `json:"-"`
|
|
LuckyNumber int `json:"luckyNumber"`
|
|
}
|
|
|
|
func (v *LuckyFieldsUser) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*LuckyFieldsUser
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.LuckyFieldsUser = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = json.Unmarshal(
|
|
b, &v.MoreUserFields)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// MoreUserFields includes the GraphQL fields of User requested by the fragment MoreUserFields.
|
|
type MoreUserFields struct {
|
|
Id string `json:"id"`
|
|
Hair MoreUserFieldsHair `json:"hair"`
|
|
}
|
|
|
|
// MoreUserFieldsHair includes the requested fields of the GraphQL type Hair.
|
|
type MoreUserFieldsHair struct {
|
|
Color string `json:"color"`
|
|
}
|
|
|
|
type Species string
|
|
|
|
const (
|
|
SpeciesDog Species = "DOG"
|
|
SpeciesCoelacanth Species = "COELACANTH"
|
|
)
|
|
|
|
// UserFields includes the GraphQL fields of User requested by the fragment UserFields.
|
|
type UserFields struct {
|
|
Id string `json:"id"`
|
|
LuckyFieldsUser `json:"-"`
|
|
MoreUserFields `json:"-"`
|
|
}
|
|
|
|
func (v *UserFields) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*UserFields
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.UserFields = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = json.Unmarshal(
|
|
b, &v.LuckyFieldsUser)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = json.Unmarshal(
|
|
b, &v.MoreUserFields)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// failingQueryMeUser includes the requested fields of the GraphQL type User.
|
|
type failingQueryMeUser struct {
|
|
Id string `json:"id"`
|
|
}
|
|
|
|
// failingQueryResponse is returned by failingQuery on success.
|
|
type failingQueryResponse struct {
|
|
Fail bool `json:"fail"`
|
|
Me failingQueryMeUser `json:"me"`
|
|
}
|
|
|
|
// queryWithFragmentsBeingsAnimal includes the requested fields of the GraphQL type Animal.
|
|
type queryWithFragmentsBeingsAnimal struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
Hair queryWithFragmentsBeingsAnimalHairBeingsHair `json:"hair"`
|
|
Species Species `json:"species"`
|
|
Owner queryWithFragmentsBeingsAnimalOwnerBeing `json:"-"`
|
|
}
|
|
|
|
func (v *queryWithFragmentsBeingsAnimal) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*queryWithFragmentsBeingsAnimal
|
|
Owner json.RawMessage `json:"owner"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.queryWithFragmentsBeingsAnimal = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
{
|
|
target := &v.Owner
|
|
raw := firstPass.Owner
|
|
err = __unmarshalqueryWithFragmentsBeingsAnimalOwnerBeing(
|
|
target, raw)
|
|
if err != nil {
|
|
return fmt.Errorf(
|
|
"Unable to unmarshal queryWithFragmentsBeingsAnimal.Owner: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// queryWithFragmentsBeingsAnimalHairBeingsHair includes the requested fields of the GraphQL type BeingsHair.
|
|
type queryWithFragmentsBeingsAnimalHairBeingsHair struct {
|
|
HasHair bool `json:"hasHair"`
|
|
}
|
|
|
|
// queryWithFragmentsBeingsAnimalOwnerAnimal includes the requested fields of the GraphQL type Animal.
|
|
type queryWithFragmentsBeingsAnimalOwnerAnimal struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// queryWithFragmentsBeingsAnimalOwnerBeing includes the requested fields of the GraphQL interface Being.
|
|
//
|
|
// queryWithFragmentsBeingsAnimalOwnerBeing is implemented by the following types:
|
|
// queryWithFragmentsBeingsAnimalOwnerUser
|
|
// queryWithFragmentsBeingsAnimalOwnerAnimal
|
|
type queryWithFragmentsBeingsAnimalOwnerBeing interface {
|
|
implementsGraphQLInterfacequeryWithFragmentsBeingsAnimalOwnerBeing()
|
|
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
|
|
GetTypename() string
|
|
// GetId returns the interface-field "id" from its implementation.
|
|
GetId() string
|
|
// GetName returns the interface-field "name" from its implementation.
|
|
GetName() string
|
|
}
|
|
|
|
func (v *queryWithFragmentsBeingsAnimalOwnerUser) implementsGraphQLInterfacequeryWithFragmentsBeingsAnimalOwnerBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithFragmentsBeingsAnimalOwnerBeing.
|
|
func (v *queryWithFragmentsBeingsAnimalOwnerUser) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithFragmentsBeingsAnimalOwnerBeing.
|
|
func (v *queryWithFragmentsBeingsAnimalOwnerUser) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithFragmentsBeingsAnimalOwnerBeing.
|
|
func (v *queryWithFragmentsBeingsAnimalOwnerUser) GetName() string { return v.Name }
|
|
|
|
func (v *queryWithFragmentsBeingsAnimalOwnerAnimal) implementsGraphQLInterfacequeryWithFragmentsBeingsAnimalOwnerBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithFragmentsBeingsAnimalOwnerBeing.
|
|
func (v *queryWithFragmentsBeingsAnimalOwnerAnimal) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithFragmentsBeingsAnimalOwnerBeing.
|
|
func (v *queryWithFragmentsBeingsAnimalOwnerAnimal) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithFragmentsBeingsAnimalOwnerBeing.
|
|
func (v *queryWithFragmentsBeingsAnimalOwnerAnimal) GetName() string { return v.Name }
|
|
|
|
func __unmarshalqueryWithFragmentsBeingsAnimalOwnerBeing(v *queryWithFragmentsBeingsAnimalOwnerBeing, 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 "User":
|
|
*v = new(queryWithFragmentsBeingsAnimalOwnerUser)
|
|
return json.Unmarshal(m, *v)
|
|
case "Animal":
|
|
*v = new(queryWithFragmentsBeingsAnimalOwnerAnimal)
|
|
return json.Unmarshal(m, *v)
|
|
case "":
|
|
return fmt.Errorf(
|
|
"Response was missing Being.__typename")
|
|
default:
|
|
return fmt.Errorf(
|
|
`Unexpected concrete type for queryWithFragmentsBeingsAnimalOwnerBeing: "%v"`, tn.TypeName)
|
|
}
|
|
}
|
|
|
|
// queryWithFragmentsBeingsAnimalOwnerUser includes the requested fields of the GraphQL type User.
|
|
type queryWithFragmentsBeingsAnimalOwnerUser struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
LuckyNumber int `json:"luckyNumber"`
|
|
}
|
|
|
|
// queryWithFragmentsBeingsBeing includes the requested fields of the GraphQL interface Being.
|
|
//
|
|
// queryWithFragmentsBeingsBeing is implemented by the following types:
|
|
// queryWithFragmentsBeingsUser
|
|
// queryWithFragmentsBeingsAnimal
|
|
type queryWithFragmentsBeingsBeing interface {
|
|
implementsGraphQLInterfacequeryWithFragmentsBeingsBeing()
|
|
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
|
|
GetTypename() string
|
|
// GetId returns the interface-field "id" from its implementation.
|
|
GetId() string
|
|
// GetName returns the interface-field "name" from its implementation.
|
|
GetName() string
|
|
}
|
|
|
|
func (v *queryWithFragmentsBeingsUser) implementsGraphQLInterfacequeryWithFragmentsBeingsBeing() {}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithFragmentsBeingsBeing.
|
|
func (v *queryWithFragmentsBeingsUser) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithFragmentsBeingsBeing.
|
|
func (v *queryWithFragmentsBeingsUser) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithFragmentsBeingsBeing.
|
|
func (v *queryWithFragmentsBeingsUser) GetName() string { return v.Name }
|
|
|
|
func (v *queryWithFragmentsBeingsAnimal) implementsGraphQLInterfacequeryWithFragmentsBeingsBeing() {}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithFragmentsBeingsBeing.
|
|
func (v *queryWithFragmentsBeingsAnimal) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithFragmentsBeingsBeing.
|
|
func (v *queryWithFragmentsBeingsAnimal) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithFragmentsBeingsBeing.
|
|
func (v *queryWithFragmentsBeingsAnimal) GetName() string { return v.Name }
|
|
|
|
func __unmarshalqueryWithFragmentsBeingsBeing(v *queryWithFragmentsBeingsBeing, 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 "User":
|
|
*v = new(queryWithFragmentsBeingsUser)
|
|
return json.Unmarshal(m, *v)
|
|
case "Animal":
|
|
*v = new(queryWithFragmentsBeingsAnimal)
|
|
return json.Unmarshal(m, *v)
|
|
case "":
|
|
return fmt.Errorf(
|
|
"Response was missing Being.__typename")
|
|
default:
|
|
return fmt.Errorf(
|
|
`Unexpected concrete type for queryWithFragmentsBeingsBeing: "%v"`, tn.TypeName)
|
|
}
|
|
}
|
|
|
|
// queryWithFragmentsBeingsUser includes the requested fields of the GraphQL type User.
|
|
type queryWithFragmentsBeingsUser struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
LuckyNumber int `json:"luckyNumber"`
|
|
Hair queryWithFragmentsBeingsUserHair `json:"hair"`
|
|
}
|
|
|
|
// queryWithFragmentsBeingsUserHair includes the requested fields of the GraphQL type Hair.
|
|
type queryWithFragmentsBeingsUserHair struct {
|
|
Color string `json:"color"`
|
|
}
|
|
|
|
// queryWithFragmentsResponse is returned by queryWithFragments on success.
|
|
type queryWithFragmentsResponse struct {
|
|
Beings []queryWithFragmentsBeingsBeing `json:"-"`
|
|
}
|
|
|
|
func (v *queryWithFragmentsResponse) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*queryWithFragmentsResponse
|
|
Beings []json.RawMessage `json:"beings"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.queryWithFragmentsResponse = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
{
|
|
target := &v.Beings
|
|
raw := firstPass.Beings
|
|
*target = make(
|
|
[]queryWithFragmentsBeingsBeing,
|
|
len(raw))
|
|
for i, raw := range raw {
|
|
target := &(*target)[i]
|
|
err = __unmarshalqueryWithFragmentsBeingsBeing(
|
|
target, raw)
|
|
if err != nil {
|
|
return fmt.Errorf(
|
|
"Unable to unmarshal queryWithFragmentsResponse.Beings: %w", err)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// queryWithInterfaceListFieldBeingsAnimal includes the requested fields of the GraphQL type Animal.
|
|
type queryWithInterfaceListFieldBeingsAnimal struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// queryWithInterfaceListFieldBeingsBeing includes the requested fields of the GraphQL interface Being.
|
|
//
|
|
// queryWithInterfaceListFieldBeingsBeing is implemented by the following types:
|
|
// queryWithInterfaceListFieldBeingsUser
|
|
// queryWithInterfaceListFieldBeingsAnimal
|
|
type queryWithInterfaceListFieldBeingsBeing interface {
|
|
implementsGraphQLInterfacequeryWithInterfaceListFieldBeingsBeing()
|
|
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
|
|
GetTypename() string
|
|
// GetId returns the interface-field "id" from its implementation.
|
|
GetId() string
|
|
// GetName returns the interface-field "name" from its implementation.
|
|
GetName() string
|
|
}
|
|
|
|
func (v *queryWithInterfaceListFieldBeingsUser) implementsGraphQLInterfacequeryWithInterfaceListFieldBeingsBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithInterfaceListFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListFieldBeingsUser) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithInterfaceListFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListFieldBeingsUser) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithInterfaceListFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListFieldBeingsUser) GetName() string { return v.Name }
|
|
|
|
func (v *queryWithInterfaceListFieldBeingsAnimal) implementsGraphQLInterfacequeryWithInterfaceListFieldBeingsBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithInterfaceListFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListFieldBeingsAnimal) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithInterfaceListFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListFieldBeingsAnimal) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithInterfaceListFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListFieldBeingsAnimal) GetName() string { return v.Name }
|
|
|
|
func __unmarshalqueryWithInterfaceListFieldBeingsBeing(v *queryWithInterfaceListFieldBeingsBeing, 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 "User":
|
|
*v = new(queryWithInterfaceListFieldBeingsUser)
|
|
return json.Unmarshal(m, *v)
|
|
case "Animal":
|
|
*v = new(queryWithInterfaceListFieldBeingsAnimal)
|
|
return json.Unmarshal(m, *v)
|
|
case "":
|
|
return fmt.Errorf(
|
|
"Response was missing Being.__typename")
|
|
default:
|
|
return fmt.Errorf(
|
|
`Unexpected concrete type for queryWithInterfaceListFieldBeingsBeing: "%v"`, tn.TypeName)
|
|
}
|
|
}
|
|
|
|
// queryWithInterfaceListFieldBeingsUser includes the requested fields of the GraphQL type User.
|
|
type queryWithInterfaceListFieldBeingsUser struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// queryWithInterfaceListFieldResponse is returned by queryWithInterfaceListField on success.
|
|
type queryWithInterfaceListFieldResponse struct {
|
|
Beings []queryWithInterfaceListFieldBeingsBeing `json:"-"`
|
|
}
|
|
|
|
func (v *queryWithInterfaceListFieldResponse) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*queryWithInterfaceListFieldResponse
|
|
Beings []json.RawMessage `json:"beings"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.queryWithInterfaceListFieldResponse = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
{
|
|
target := &v.Beings
|
|
raw := firstPass.Beings
|
|
*target = make(
|
|
[]queryWithInterfaceListFieldBeingsBeing,
|
|
len(raw))
|
|
for i, raw := range raw {
|
|
target := &(*target)[i]
|
|
err = __unmarshalqueryWithInterfaceListFieldBeingsBeing(
|
|
target, raw)
|
|
if err != nil {
|
|
return fmt.Errorf(
|
|
"Unable to unmarshal queryWithInterfaceListFieldResponse.Beings: %w", err)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// queryWithInterfaceListPointerFieldBeingsAnimal includes the requested fields of the GraphQL type Animal.
|
|
type queryWithInterfaceListPointerFieldBeingsAnimal struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// queryWithInterfaceListPointerFieldBeingsBeing includes the requested fields of the GraphQL interface Being.
|
|
//
|
|
// queryWithInterfaceListPointerFieldBeingsBeing is implemented by the following types:
|
|
// queryWithInterfaceListPointerFieldBeingsUser
|
|
// queryWithInterfaceListPointerFieldBeingsAnimal
|
|
type queryWithInterfaceListPointerFieldBeingsBeing interface {
|
|
implementsGraphQLInterfacequeryWithInterfaceListPointerFieldBeingsBeing()
|
|
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
|
|
GetTypename() string
|
|
// GetId returns the interface-field "id" from its implementation.
|
|
GetId() string
|
|
// GetName returns the interface-field "name" from its implementation.
|
|
GetName() string
|
|
}
|
|
|
|
func (v *queryWithInterfaceListPointerFieldBeingsUser) implementsGraphQLInterfacequeryWithInterfaceListPointerFieldBeingsBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithInterfaceListPointerFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListPointerFieldBeingsUser) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithInterfaceListPointerFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListPointerFieldBeingsUser) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithInterfaceListPointerFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListPointerFieldBeingsUser) GetName() string { return v.Name }
|
|
|
|
func (v *queryWithInterfaceListPointerFieldBeingsAnimal) implementsGraphQLInterfacequeryWithInterfaceListPointerFieldBeingsBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithInterfaceListPointerFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListPointerFieldBeingsAnimal) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithInterfaceListPointerFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListPointerFieldBeingsAnimal) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithInterfaceListPointerFieldBeingsBeing.
|
|
func (v *queryWithInterfaceListPointerFieldBeingsAnimal) GetName() string { return v.Name }
|
|
|
|
func __unmarshalqueryWithInterfaceListPointerFieldBeingsBeing(v *queryWithInterfaceListPointerFieldBeingsBeing, 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 "User":
|
|
*v = new(queryWithInterfaceListPointerFieldBeingsUser)
|
|
return json.Unmarshal(m, *v)
|
|
case "Animal":
|
|
*v = new(queryWithInterfaceListPointerFieldBeingsAnimal)
|
|
return json.Unmarshal(m, *v)
|
|
case "":
|
|
return fmt.Errorf(
|
|
"Response was missing Being.__typename")
|
|
default:
|
|
return fmt.Errorf(
|
|
`Unexpected concrete type for queryWithInterfaceListPointerFieldBeingsBeing: "%v"`, tn.TypeName)
|
|
}
|
|
}
|
|
|
|
// queryWithInterfaceListPointerFieldBeingsUser includes the requested fields of the GraphQL type User.
|
|
type queryWithInterfaceListPointerFieldBeingsUser struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// queryWithInterfaceListPointerFieldResponse is returned by queryWithInterfaceListPointerField on success.
|
|
type queryWithInterfaceListPointerFieldResponse struct {
|
|
Beings []*queryWithInterfaceListPointerFieldBeingsBeing `json:"-"`
|
|
}
|
|
|
|
func (v *queryWithInterfaceListPointerFieldResponse) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*queryWithInterfaceListPointerFieldResponse
|
|
Beings []json.RawMessage `json:"beings"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.queryWithInterfaceListPointerFieldResponse = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
{
|
|
target := &v.Beings
|
|
raw := firstPass.Beings
|
|
*target = make(
|
|
[]*queryWithInterfaceListPointerFieldBeingsBeing,
|
|
len(raw))
|
|
for i, raw := range raw {
|
|
target := &(*target)[i]
|
|
*target = new(queryWithInterfaceListPointerFieldBeingsBeing)
|
|
err = __unmarshalqueryWithInterfaceListPointerFieldBeingsBeing(
|
|
*target, raw)
|
|
if err != nil {
|
|
return fmt.Errorf(
|
|
"Unable to unmarshal queryWithInterfaceListPointerFieldResponse.Beings: %w", err)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// queryWithInterfaceNoFragmentsBeing includes the requested fields of the GraphQL interface Being.
|
|
//
|
|
// queryWithInterfaceNoFragmentsBeing is implemented by the following types:
|
|
// queryWithInterfaceNoFragmentsBeingUser
|
|
// queryWithInterfaceNoFragmentsBeingAnimal
|
|
type queryWithInterfaceNoFragmentsBeing interface {
|
|
implementsGraphQLInterfacequeryWithInterfaceNoFragmentsBeing()
|
|
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
|
|
GetTypename() string
|
|
// GetId returns the interface-field "id" from its implementation.
|
|
GetId() string
|
|
// GetName returns the interface-field "name" from its implementation.
|
|
GetName() string
|
|
}
|
|
|
|
func (v *queryWithInterfaceNoFragmentsBeingUser) implementsGraphQLInterfacequeryWithInterfaceNoFragmentsBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithInterfaceNoFragmentsBeing.
|
|
func (v *queryWithInterfaceNoFragmentsBeingUser) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithInterfaceNoFragmentsBeing.
|
|
func (v *queryWithInterfaceNoFragmentsBeingUser) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithInterfaceNoFragmentsBeing.
|
|
func (v *queryWithInterfaceNoFragmentsBeingUser) GetName() string { return v.Name }
|
|
|
|
func (v *queryWithInterfaceNoFragmentsBeingAnimal) implementsGraphQLInterfacequeryWithInterfaceNoFragmentsBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithInterfaceNoFragmentsBeing.
|
|
func (v *queryWithInterfaceNoFragmentsBeingAnimal) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithInterfaceNoFragmentsBeing.
|
|
func (v *queryWithInterfaceNoFragmentsBeingAnimal) GetId() string { return v.Id }
|
|
|
|
// GetName is a part of, and documented with, the interface queryWithInterfaceNoFragmentsBeing.
|
|
func (v *queryWithInterfaceNoFragmentsBeingAnimal) GetName() string { return v.Name }
|
|
|
|
func __unmarshalqueryWithInterfaceNoFragmentsBeing(v *queryWithInterfaceNoFragmentsBeing, 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 "User":
|
|
*v = new(queryWithInterfaceNoFragmentsBeingUser)
|
|
return json.Unmarshal(m, *v)
|
|
case "Animal":
|
|
*v = new(queryWithInterfaceNoFragmentsBeingAnimal)
|
|
return json.Unmarshal(m, *v)
|
|
case "":
|
|
return fmt.Errorf(
|
|
"Response was missing Being.__typename")
|
|
default:
|
|
return fmt.Errorf(
|
|
`Unexpected concrete type for queryWithInterfaceNoFragmentsBeing: "%v"`, tn.TypeName)
|
|
}
|
|
}
|
|
|
|
// queryWithInterfaceNoFragmentsBeingAnimal includes the requested fields of the GraphQL type Animal.
|
|
type queryWithInterfaceNoFragmentsBeingAnimal struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// queryWithInterfaceNoFragmentsBeingUser includes the requested fields of the GraphQL type User.
|
|
type queryWithInterfaceNoFragmentsBeingUser struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// queryWithInterfaceNoFragmentsMeUser includes the requested fields of the GraphQL type User.
|
|
type queryWithInterfaceNoFragmentsMeUser struct {
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
// queryWithInterfaceNoFragmentsResponse is returned by queryWithInterfaceNoFragments on success.
|
|
type queryWithInterfaceNoFragmentsResponse struct {
|
|
Being queryWithInterfaceNoFragmentsBeing `json:"-"`
|
|
Me queryWithInterfaceNoFragmentsMeUser `json:"me"`
|
|
}
|
|
|
|
func (v *queryWithInterfaceNoFragmentsResponse) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*queryWithInterfaceNoFragmentsResponse
|
|
Being json.RawMessage `json:"being"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.queryWithInterfaceNoFragmentsResponse = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
{
|
|
target := &v.Being
|
|
raw := firstPass.Being
|
|
err = __unmarshalqueryWithInterfaceNoFragmentsBeing(
|
|
target, raw)
|
|
if err != nil {
|
|
return fmt.Errorf(
|
|
"Unable to unmarshal queryWithInterfaceNoFragmentsResponse.Being: %w", err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// queryWithNamedFragmentsBeingsAnimal includes the requested fields of the GraphQL type Animal.
|
|
type queryWithNamedFragmentsBeingsAnimal struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
AnimalFields `json:"-"`
|
|
}
|
|
|
|
func (v *queryWithNamedFragmentsBeingsAnimal) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*queryWithNamedFragmentsBeingsAnimal
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.queryWithNamedFragmentsBeingsAnimal = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = json.Unmarshal(
|
|
b, &v.AnimalFields)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// queryWithNamedFragmentsBeingsBeing includes the requested fields of the GraphQL interface Being.
|
|
//
|
|
// queryWithNamedFragmentsBeingsBeing is implemented by the following types:
|
|
// queryWithNamedFragmentsBeingsUser
|
|
// queryWithNamedFragmentsBeingsAnimal
|
|
type queryWithNamedFragmentsBeingsBeing interface {
|
|
implementsGraphQLInterfacequeryWithNamedFragmentsBeingsBeing()
|
|
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
|
|
GetTypename() string
|
|
// GetId returns the interface-field "id" from its implementation.
|
|
GetId() string
|
|
}
|
|
|
|
func (v *queryWithNamedFragmentsBeingsUser) implementsGraphQLInterfacequeryWithNamedFragmentsBeingsBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithNamedFragmentsBeingsBeing.
|
|
func (v *queryWithNamedFragmentsBeingsUser) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithNamedFragmentsBeingsBeing.
|
|
func (v *queryWithNamedFragmentsBeingsUser) GetId() string { return v.Id }
|
|
|
|
func (v *queryWithNamedFragmentsBeingsAnimal) implementsGraphQLInterfacequeryWithNamedFragmentsBeingsBeing() {
|
|
}
|
|
|
|
// GetTypename is a part of, and documented with, the interface queryWithNamedFragmentsBeingsBeing.
|
|
func (v *queryWithNamedFragmentsBeingsAnimal) GetTypename() string { return v.Typename }
|
|
|
|
// GetId is a part of, and documented with, the interface queryWithNamedFragmentsBeingsBeing.
|
|
func (v *queryWithNamedFragmentsBeingsAnimal) GetId() string { return v.Id }
|
|
|
|
func __unmarshalqueryWithNamedFragmentsBeingsBeing(v *queryWithNamedFragmentsBeingsBeing, 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 "User":
|
|
*v = new(queryWithNamedFragmentsBeingsUser)
|
|
return json.Unmarshal(m, *v)
|
|
case "Animal":
|
|
*v = new(queryWithNamedFragmentsBeingsAnimal)
|
|
return json.Unmarshal(m, *v)
|
|
case "":
|
|
return fmt.Errorf(
|
|
"Response was missing Being.__typename")
|
|
default:
|
|
return fmt.Errorf(
|
|
`Unexpected concrete type for queryWithNamedFragmentsBeingsBeing: "%v"`, tn.TypeName)
|
|
}
|
|
}
|
|
|
|
// queryWithNamedFragmentsBeingsUser includes the requested fields of the GraphQL type User.
|
|
type queryWithNamedFragmentsBeingsUser struct {
|
|
Typename string `json:"__typename"`
|
|
Id string `json:"id"`
|
|
UserFields `json:"-"`
|
|
}
|
|
|
|
func (v *queryWithNamedFragmentsBeingsUser) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*queryWithNamedFragmentsBeingsUser
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.queryWithNamedFragmentsBeingsUser = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = json.Unmarshal(
|
|
b, &v.UserFields)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// queryWithNamedFragmentsResponse is returned by queryWithNamedFragments on success.
|
|
type queryWithNamedFragmentsResponse struct {
|
|
Beings []queryWithNamedFragmentsBeingsBeing `json:"-"`
|
|
}
|
|
|
|
func (v *queryWithNamedFragmentsResponse) UnmarshalJSON(b []byte) error {
|
|
|
|
var firstPass struct {
|
|
*queryWithNamedFragmentsResponse
|
|
Beings []json.RawMessage `json:"beings"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
firstPass.queryWithNamedFragmentsResponse = v
|
|
|
|
err := json.Unmarshal(b, &firstPass)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
{
|
|
target := &v.Beings
|
|
raw := firstPass.Beings
|
|
*target = make(
|
|
[]queryWithNamedFragmentsBeingsBeing,
|
|
len(raw))
|
|
for i, raw := range raw {
|
|
target := &(*target)[i]
|
|
err = __unmarshalqueryWithNamedFragmentsBeingsBeing(
|
|
target, raw)
|
|
if err != nil {
|
|
return fmt.Errorf(
|
|
"Unable to unmarshal queryWithNamedFragmentsResponse.Beings: %w", err)
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// queryWithVariablesResponse is returned by queryWithVariables on success.
|
|
type queryWithVariablesResponse struct {
|
|
User queryWithVariablesUser `json:"user"`
|
|
}
|
|
|
|
// queryWithVariablesUser includes the requested fields of the GraphQL type User.
|
|
type queryWithVariablesUser struct {
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
LuckyNumber int `json:"luckyNumber"`
|
|
}
|
|
|
|
// simpleQueryMeUser includes the requested fields of the GraphQL type User.
|
|
type simpleQueryMeUser struct {
|
|
Id string `json:"id"`
|
|
Name string `json:"name"`
|
|
LuckyNumber int `json:"luckyNumber"`
|
|
}
|
|
|
|
// simpleQueryResponse is returned by simpleQuery on success.
|
|
type simpleQueryResponse struct {
|
|
Me simpleQueryMeUser `json:"me"`
|
|
}
|
|
|
|
func simpleQuery(
|
|
ctx context.Context,
|
|
client graphql.Client,
|
|
) (*simpleQueryResponse, error) {
|
|
var err error
|
|
|
|
var retval simpleQueryResponse
|
|
err = client.MakeRequest(
|
|
ctx,
|
|
"simpleQuery",
|
|
`
|
|
query simpleQuery {
|
|
me {
|
|
id
|
|
name
|
|
luckyNumber
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
nil,
|
|
)
|
|
return &retval, err
|
|
}
|
|
|
|
func failingQuery(
|
|
ctx context.Context,
|
|
client graphql.Client,
|
|
) (*failingQueryResponse, error) {
|
|
var err error
|
|
|
|
var retval failingQueryResponse
|
|
err = client.MakeRequest(
|
|
ctx,
|
|
"failingQuery",
|
|
`
|
|
query failingQuery {
|
|
fail
|
|
me {
|
|
id
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
nil,
|
|
)
|
|
return &retval, err
|
|
}
|
|
|
|
func queryWithVariables(
|
|
ctx context.Context,
|
|
client graphql.Client,
|
|
id string,
|
|
) (*queryWithVariablesResponse, error) {
|
|
variables := map[string]interface{}{
|
|
"id": id,
|
|
}
|
|
|
|
var err error
|
|
|
|
var retval queryWithVariablesResponse
|
|
err = client.MakeRequest(
|
|
ctx,
|
|
"queryWithVariables",
|
|
`
|
|
query queryWithVariables ($id: ID!) {
|
|
user(id: $id) {
|
|
id
|
|
name
|
|
luckyNumber
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
variables,
|
|
)
|
|
return &retval, err
|
|
}
|
|
|
|
func queryWithInterfaceNoFragments(
|
|
ctx context.Context,
|
|
client graphql.Client,
|
|
id string,
|
|
) (*queryWithInterfaceNoFragmentsResponse, error) {
|
|
variables := map[string]interface{}{
|
|
"id": id,
|
|
}
|
|
|
|
var err error
|
|
|
|
var retval queryWithInterfaceNoFragmentsResponse
|
|
err = client.MakeRequest(
|
|
ctx,
|
|
"queryWithInterfaceNoFragments",
|
|
`
|
|
query queryWithInterfaceNoFragments ($id: ID!) {
|
|
being(id: $id) {
|
|
__typename
|
|
id
|
|
name
|
|
}
|
|
me {
|
|
id
|
|
name
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
variables,
|
|
)
|
|
return &retval, err
|
|
}
|
|
|
|
func queryWithInterfaceListField(
|
|
ctx context.Context,
|
|
client graphql.Client,
|
|
ids []string,
|
|
) (*queryWithInterfaceListFieldResponse, error) {
|
|
variables := map[string]interface{}{
|
|
"ids": ids,
|
|
}
|
|
|
|
var err error
|
|
|
|
var retval queryWithInterfaceListFieldResponse
|
|
err = client.MakeRequest(
|
|
ctx,
|
|
"queryWithInterfaceListField",
|
|
`
|
|
query queryWithInterfaceListField ($ids: [ID!]!) {
|
|
beings(ids: $ids) {
|
|
__typename
|
|
id
|
|
name
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
variables,
|
|
)
|
|
return &retval, err
|
|
}
|
|
|
|
func queryWithInterfaceListPointerField(
|
|
ctx context.Context,
|
|
client graphql.Client,
|
|
ids []string,
|
|
) (*queryWithInterfaceListPointerFieldResponse, error) {
|
|
variables := map[string]interface{}{
|
|
"ids": ids,
|
|
}
|
|
|
|
var err error
|
|
|
|
var retval queryWithInterfaceListPointerFieldResponse
|
|
err = client.MakeRequest(
|
|
ctx,
|
|
"queryWithInterfaceListPointerField",
|
|
`
|
|
query queryWithInterfaceListPointerField ($ids: [ID!]!) {
|
|
beings(ids: $ids) {
|
|
__typename
|
|
id
|
|
name
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
variables,
|
|
)
|
|
return &retval, err
|
|
}
|
|
|
|
func queryWithFragments(
|
|
ctx context.Context,
|
|
client graphql.Client,
|
|
ids []string,
|
|
) (*queryWithFragmentsResponse, error) {
|
|
variables := map[string]interface{}{
|
|
"ids": ids,
|
|
}
|
|
|
|
var err error
|
|
|
|
var retval queryWithFragmentsResponse
|
|
err = client.MakeRequest(
|
|
ctx,
|
|
"queryWithFragments",
|
|
`
|
|
query queryWithFragments ($ids: [ID!]!) {
|
|
beings(ids: $ids) {
|
|
__typename
|
|
id
|
|
... on Being {
|
|
id
|
|
name
|
|
}
|
|
... on Animal {
|
|
id
|
|
hair {
|
|
hasHair
|
|
}
|
|
species
|
|
owner {
|
|
__typename
|
|
id
|
|
... on Being {
|
|
name
|
|
}
|
|
... on User {
|
|
luckyNumber
|
|
}
|
|
}
|
|
}
|
|
... on Lucky {
|
|
luckyNumber
|
|
}
|
|
... on User {
|
|
hair {
|
|
color
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
variables,
|
|
)
|
|
return &retval, err
|
|
}
|
|
|
|
func queryWithNamedFragments(
|
|
ctx context.Context,
|
|
client graphql.Client,
|
|
ids []string,
|
|
) (*queryWithNamedFragmentsResponse, error) {
|
|
variables := map[string]interface{}{
|
|
"ids": ids,
|
|
}
|
|
|
|
var err error
|
|
|
|
var retval queryWithNamedFragmentsResponse
|
|
err = client.MakeRequest(
|
|
ctx,
|
|
"queryWithNamedFragments",
|
|
`
|
|
query queryWithNamedFragments ($ids: [ID!]!) {
|
|
beings(ids: $ids) {
|
|
__typename
|
|
id
|
|
... AnimalFields
|
|
... UserFields
|
|
}
|
|
}
|
|
fragment AnimalFields on Animal {
|
|
id
|
|
hair {
|
|
hasHair
|
|
}
|
|
owner {
|
|
__typename
|
|
id
|
|
... UserFields
|
|
... LuckyFields
|
|
}
|
|
}
|
|
fragment UserFields on User {
|
|
id
|
|
... LuckyFields
|
|
... MoreUserFields
|
|
}
|
|
fragment LuckyFields on Lucky {
|
|
... MoreUserFields
|
|
luckyNumber
|
|
}
|
|
fragment MoreUserFields on User {
|
|
id
|
|
hair {
|
|
color
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
variables,
|
|
)
|
|
return &retval, err
|
|
}
|