Files
genqlient/internal/integration/generated.go
T
Ben KraftandGitHub f4c981031e Allow genqlient types to be marshaled safely (#120)
## Summary:
When genqlient generates output types, it generates whatever code is
necessary to unmarshal them.  Conversely, when it generates input types,
it generates whatever code is necessary to marshal.  This is all that's
needed for genqlient itself: it never needs to marshal output types or
unmarshal input types.

But maybe you do!  (For example, to put the responses in a cache, which
is the use case that @csilvers hit at Khan, although there are others
one can imagine.)  While we can't support every serialization format you
might want (at least not without adding plugins or some such), it's not
unreasonable to expect that since genqlient can read JSON, it can write
it too.  Sadly, in the past this was not true for types requiring custom
unmarshaling logic, for several reasons.

In this commit I implement logic to always write both marshalers and
unmarshalers whenever they're needed to be able to correctly round-trip
the types, even though genqlient doesn't do so.  I wasn't starting from
scratch, since of course we already write both marshalers and
unmarshalers in some cases.  But this ended up requiring surprisingly
large changes on the marshaling side, mostly to correctly support
embedding (which we use for named fragments).

Specifically, as the comments in `types.go` discuss, the most difficult
issue is spreads with duplicate fields, which translate to Go embedded
fields which end up hidden from the json-marshaler.  Ultimately, I had
to do things quite differently from unmarshaling, and essentially
flatten the type when we write marshaler.  But in the end it's not so
ugly -- indeed arguably it's cleaner!  Mainly it's just different.

One thing to note is that we do marshal `__typename` based on
what we know about the types; users need not fill it in (and if they
do we'll ignore it).  This seemed to me to be a better UX, and
didn't add much complexity.

In general, I begin to wonder whether using `encoding/json` at all is
really right for genqlient: we're doing a lot of work to appease it,
despite knowing what our types look like.  I think it would still be a
significant increase in lines of code to roll our own, but that code
would perhaps be simpler, and would surely be faster (although if we
just want the speed gains we could use another JSON-generator library,
see also #47).  Anyway, something to think about in the future.

## Test plan:
make tesc


Author: benjaminjkraft

Reviewers: csilvers, StevenACoffman, benjaminjkraft, dnerdy, aberkan, jvoll, mahtabsabet, MiguelCastillo

Required Reviewers: 

Approved By: StevenACoffman, dnerdy

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/120
2021-09-29 10:30:43 -07:00

2681 lines
68 KiB
Go

package integration
// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
import (
"context"
"encoding/json"
"fmt"
"time"
"github.com/Khan/genqlient/graphql"
"github.com/Khan/genqlient/internal/testutil"
)
// 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 {
if string(b) == "null" {
return nil
}
var firstPass struct {
*AnimalFields
Owner json.RawMessage `json:"owner"`
graphql.NoUnmarshalJSON
}
firstPass.AnimalFields = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Owner
src := firstPass.Owner
if len(src) != 0 && string(src) != "null" {
err = __unmarshalAnimalFieldsOwnerBeing(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal AnimalFields.Owner: %w", err)
}
}
}
return nil
}
type __premarshalAnimalFields struct {
Id string `json:"id"`
Hair AnimalFieldsHairBeingsHair `json:"hair"`
Owner json.RawMessage `json:"owner"`
}
func (v *AnimalFields) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *AnimalFields) __premarshalJSON() (*__premarshalAnimalFields, error) {
var retval __premarshalAnimalFields
retval.Id = v.Id
retval.Hair = v.Hair
{
dst := &retval.Owner
src := v.Owner
var err error
*dst, err = __marshalAnimalFieldsOwnerBeing(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal AnimalFields.Owner: %w", err)
}
}
return &retval, 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(b []byte, v *AnimalFieldsOwnerBeing) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(AnimalFieldsOwnerUser)
return json.Unmarshal(b, *v)
case "Animal":
*v = new(AnimalFieldsOwnerAnimal)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"Response was missing Being.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for AnimalFieldsOwnerBeing: "%v"`, tn.TypeName)
}
}
func __marshalAnimalFieldsOwnerBeing(v *AnimalFieldsOwnerBeing) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *AnimalFieldsOwnerUser:
typename = "User"
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
result := struct {
TypeName string `json:"__typename"`
*__premarshalAnimalFieldsOwnerUser
}{typename, premarshaled}
return json.Marshal(result)
case *AnimalFieldsOwnerAnimal:
typename = "Animal"
result := struct {
TypeName string `json:"__typename"`
*AnimalFieldsOwnerAnimal
}{typename, v}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`Unexpected concrete type for AnimalFieldsOwnerBeing: "%T"`, v)
}
}
// 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 {
if string(b) == "null" {
return nil
}
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
}
type __premarshalAnimalFieldsOwnerUser struct {
Typename string `json:"__typename"`
Id string `json:"id"`
LuckyNumber int `json:"luckyNumber"`
Hair MoreUserFieldsHair `json:"hair"`
}
func (v *AnimalFieldsOwnerUser) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *AnimalFieldsOwnerUser) __premarshalJSON() (*__premarshalAnimalFieldsOwnerUser, error) {
var retval __premarshalAnimalFieldsOwnerUser
retval.Typename = v.Typename
retval.Id = v.Id
retval.LuckyNumber = v.LuckyFieldsUser.LuckyNumber
retval.Hair = v.UserFields.MoreUserFields.Hair
return &retval, 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(b []byte, v *LuckyFields) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(LuckyFieldsUser)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"Response was missing Lucky.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for LuckyFields: "%v"`, tn.TypeName)
}
}
func __marshalLuckyFields(v *LuckyFields) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *LuckyFieldsUser:
typename = "User"
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
result := struct {
TypeName string `json:"__typename"`
*__premarshalLuckyFieldsUser
}{typename, premarshaled}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`Unexpected concrete type for LuckyFields: "%T"`, v)
}
}
// 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 {
if string(b) == "null" {
return nil
}
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
}
type __premarshalLuckyFieldsUser struct {
LuckyNumber int `json:"luckyNumber"`
Id string `json:"id"`
Hair MoreUserFieldsHair `json:"hair"`
}
func (v *LuckyFieldsUser) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *LuckyFieldsUser) __premarshalJSON() (*__premarshalLuckyFieldsUser, error) {
var retval __premarshalLuckyFieldsUser
retval.LuckyNumber = v.LuckyNumber
retval.Id = v.MoreUserFields.Id
retval.Hair = v.MoreUserFields.Hair
return &retval, 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 {
if string(b) == "null" {
return nil
}
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
}
type __premarshalUserFields struct {
Id string `json:"id"`
LuckyNumber int `json:"luckyNumber"`
Hair MoreUserFieldsHair `json:"hair"`
}
func (v *UserFields) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *UserFields) __premarshalJSON() (*__premarshalUserFields, error) {
var retval __premarshalUserFields
retval.Id = v.Id
retval.LuckyNumber = v.LuckyFieldsUser.LuckyNumber
retval.Hair = v.MoreUserFields.Hair
return &retval, nil
}
// __queryWithCustomMarshalInput is used internally by genqlient
type __queryWithCustomMarshalInput struct {
Date time.Time `json:"-"`
}
func (v *__queryWithCustomMarshalInput) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*__queryWithCustomMarshalInput
Date json.RawMessage `json:"date"`
graphql.NoUnmarshalJSON
}
firstPass.__queryWithCustomMarshalInput = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Date
src := firstPass.Date
if len(src) != 0 && string(src) != "null" {
err = testutil.UnmarshalDate(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal __queryWithCustomMarshalInput.Date: %w", err)
}
}
}
return nil
}
type __premarshal__queryWithCustomMarshalInput struct {
Date json.RawMessage `json:"date"`
}
func (v *__queryWithCustomMarshalInput) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *__queryWithCustomMarshalInput) __premarshalJSON() (*__premarshal__queryWithCustomMarshalInput, error) {
var retval __premarshal__queryWithCustomMarshalInput
{
dst := &retval.Date
src := v.Date
var err error
*dst, err = testutil.MarshalDate(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal __queryWithCustomMarshalInput.Date: %w", err)
}
}
return &retval, nil
}
// __queryWithCustomMarshalOptionalInput is used internally by genqlient
type __queryWithCustomMarshalOptionalInput struct {
Date *time.Time `json:"-"`
Id *string `json:"id"`
}
func (v *__queryWithCustomMarshalOptionalInput) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*__queryWithCustomMarshalOptionalInput
Date json.RawMessage `json:"date"`
graphql.NoUnmarshalJSON
}
firstPass.__queryWithCustomMarshalOptionalInput = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Date
src := firstPass.Date
if len(src) != 0 && string(src) != "null" {
*dst = new(time.Time)
err = testutil.UnmarshalDate(
src, *dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal __queryWithCustomMarshalOptionalInput.Date: %w", err)
}
}
}
return nil
}
type __premarshal__queryWithCustomMarshalOptionalInput struct {
Date json.RawMessage `json:"date"`
Id *string `json:"id"`
}
func (v *__queryWithCustomMarshalOptionalInput) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *__queryWithCustomMarshalOptionalInput) __premarshalJSON() (*__premarshal__queryWithCustomMarshalOptionalInput, error) {
var retval __premarshal__queryWithCustomMarshalOptionalInput
{
dst := &retval.Date
src := v.Date
if src != nil {
var err error
*dst, err = testutil.MarshalDate(
src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal __queryWithCustomMarshalOptionalInput.Date: %w", err)
}
}
}
retval.Id = v.Id
return &retval, nil
}
// __queryWithCustomMarshalSliceInput is used internally by genqlient
type __queryWithCustomMarshalSliceInput struct {
Dates []time.Time `json:"-"`
}
func (v *__queryWithCustomMarshalSliceInput) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*__queryWithCustomMarshalSliceInput
Dates []json.RawMessage `json:"dates"`
graphql.NoUnmarshalJSON
}
firstPass.__queryWithCustomMarshalSliceInput = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Dates
src := firstPass.Dates
*dst = make(
[]time.Time,
len(src))
for i, src := range src {
dst := &(*dst)[i]
if len(src) != 0 && string(src) != "null" {
err = testutil.UnmarshalDate(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal __queryWithCustomMarshalSliceInput.Dates: %w", err)
}
}
}
}
return nil
}
type __premarshal__queryWithCustomMarshalSliceInput struct {
Dates []json.RawMessage `json:"dates"`
}
func (v *__queryWithCustomMarshalSliceInput) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *__queryWithCustomMarshalSliceInput) __premarshalJSON() (*__premarshal__queryWithCustomMarshalSliceInput, error) {
var retval __premarshal__queryWithCustomMarshalSliceInput
{
dst := &retval.Dates
src := v.Dates
*dst = make(
[]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
var err error
*dst, err = testutil.MarshalDate(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal __queryWithCustomMarshalSliceInput.Dates: %w", err)
}
}
}
return &retval, nil
}
// __queryWithFragmentsInput is used internally by genqlient
type __queryWithFragmentsInput struct {
Ids []string `json:"ids"`
}
// __queryWithInterfaceListFieldInput is used internally by genqlient
type __queryWithInterfaceListFieldInput struct {
Ids []string `json:"ids"`
}
// __queryWithInterfaceListPointerFieldInput is used internally by genqlient
type __queryWithInterfaceListPointerFieldInput struct {
Ids []string `json:"ids"`
}
// __queryWithInterfaceNoFragmentsInput is used internally by genqlient
type __queryWithInterfaceNoFragmentsInput struct {
Id string `json:"id"`
}
// __queryWithNamedFragmentsInput is used internally by genqlient
type __queryWithNamedFragmentsInput struct {
Ids []string `json:"ids"`
}
// __queryWithOmitemptyInput is used internally by genqlient
type __queryWithOmitemptyInput struct {
Id string `json:"id,omitempty"`
}
// __queryWithVariablesInput is used internally by genqlient
type __queryWithVariablesInput struct {
Id string `json:"id"`
}
// 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"`
}
// queryWithCustomMarshalOptionalResponse is returned by queryWithCustomMarshalOptional on success.
type queryWithCustomMarshalOptionalResponse struct {
UserSearch []queryWithCustomMarshalOptionalUserSearchUser `json:"userSearch"`
}
// queryWithCustomMarshalOptionalUserSearchUser includes the requested fields of the GraphQL type User.
type queryWithCustomMarshalOptionalUserSearchUser struct {
Id string `json:"id"`
Name string `json:"name"`
Birthdate time.Time `json:"-"`
}
func (v *queryWithCustomMarshalOptionalUserSearchUser) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithCustomMarshalOptionalUserSearchUser
Birthdate json.RawMessage `json:"birthdate"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithCustomMarshalOptionalUserSearchUser = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Birthdate
src := firstPass.Birthdate
if len(src) != 0 && string(src) != "null" {
err = testutil.UnmarshalDate(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithCustomMarshalOptionalUserSearchUser.Birthdate: %w", err)
}
}
}
return nil
}
type __premarshalqueryWithCustomMarshalOptionalUserSearchUser struct {
Id string `json:"id"`
Name string `json:"name"`
Birthdate json.RawMessage `json:"birthdate"`
}
func (v *queryWithCustomMarshalOptionalUserSearchUser) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithCustomMarshalOptionalUserSearchUser) __premarshalJSON() (*__premarshalqueryWithCustomMarshalOptionalUserSearchUser, error) {
var retval __premarshalqueryWithCustomMarshalOptionalUserSearchUser
retval.Id = v.Id
retval.Name = v.Name
{
dst := &retval.Birthdate
src := v.Birthdate
var err error
*dst, err = testutil.MarshalDate(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithCustomMarshalOptionalUserSearchUser.Birthdate: %w", err)
}
}
return &retval, nil
}
// queryWithCustomMarshalResponse is returned by queryWithCustomMarshal on success.
type queryWithCustomMarshalResponse struct {
UsersBornOn []queryWithCustomMarshalUsersBornOnUser `json:"usersBornOn"`
}
// queryWithCustomMarshalSliceResponse is returned by queryWithCustomMarshalSlice on success.
type queryWithCustomMarshalSliceResponse struct {
UsersBornOnDates []queryWithCustomMarshalSliceUsersBornOnDatesUser `json:"usersBornOnDates"`
}
// queryWithCustomMarshalSliceUsersBornOnDatesUser includes the requested fields of the GraphQL type User.
type queryWithCustomMarshalSliceUsersBornOnDatesUser struct {
Id string `json:"id"`
Name string `json:"name"`
Birthdate time.Time `json:"-"`
}
func (v *queryWithCustomMarshalSliceUsersBornOnDatesUser) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithCustomMarshalSliceUsersBornOnDatesUser
Birthdate json.RawMessage `json:"birthdate"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithCustomMarshalSliceUsersBornOnDatesUser = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Birthdate
src := firstPass.Birthdate
if len(src) != 0 && string(src) != "null" {
err = testutil.UnmarshalDate(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithCustomMarshalSliceUsersBornOnDatesUser.Birthdate: %w", err)
}
}
}
return nil
}
type __premarshalqueryWithCustomMarshalSliceUsersBornOnDatesUser struct {
Id string `json:"id"`
Name string `json:"name"`
Birthdate json.RawMessage `json:"birthdate"`
}
func (v *queryWithCustomMarshalSliceUsersBornOnDatesUser) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithCustomMarshalSliceUsersBornOnDatesUser) __premarshalJSON() (*__premarshalqueryWithCustomMarshalSliceUsersBornOnDatesUser, error) {
var retval __premarshalqueryWithCustomMarshalSliceUsersBornOnDatesUser
retval.Id = v.Id
retval.Name = v.Name
{
dst := &retval.Birthdate
src := v.Birthdate
var err error
*dst, err = testutil.MarshalDate(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithCustomMarshalSliceUsersBornOnDatesUser.Birthdate: %w", err)
}
}
return &retval, nil
}
// queryWithCustomMarshalUsersBornOnUser includes the requested fields of the GraphQL type User.
type queryWithCustomMarshalUsersBornOnUser struct {
Id string `json:"id"`
Name string `json:"name"`
Birthdate time.Time `json:"-"`
}
func (v *queryWithCustomMarshalUsersBornOnUser) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithCustomMarshalUsersBornOnUser
Birthdate json.RawMessage `json:"birthdate"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithCustomMarshalUsersBornOnUser = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Birthdate
src := firstPass.Birthdate
if len(src) != 0 && string(src) != "null" {
err = testutil.UnmarshalDate(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithCustomMarshalUsersBornOnUser.Birthdate: %w", err)
}
}
}
return nil
}
type __premarshalqueryWithCustomMarshalUsersBornOnUser struct {
Id string `json:"id"`
Name string `json:"name"`
Birthdate json.RawMessage `json:"birthdate"`
}
func (v *queryWithCustomMarshalUsersBornOnUser) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithCustomMarshalUsersBornOnUser) __premarshalJSON() (*__premarshalqueryWithCustomMarshalUsersBornOnUser, error) {
var retval __premarshalqueryWithCustomMarshalUsersBornOnUser
retval.Id = v.Id
retval.Name = v.Name
{
dst := &retval.Birthdate
src := v.Birthdate
var err error
*dst, err = testutil.MarshalDate(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithCustomMarshalUsersBornOnUser.Birthdate: %w", err)
}
}
return &retval, nil
}
// 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 {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithFragmentsBeingsAnimal
Owner json.RawMessage `json:"owner"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithFragmentsBeingsAnimal = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Owner
src := firstPass.Owner
if len(src) != 0 && string(src) != "null" {
err = __unmarshalqueryWithFragmentsBeingsAnimalOwnerBeing(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithFragmentsBeingsAnimal.Owner: %w", err)
}
}
}
return nil
}
type __premarshalqueryWithFragmentsBeingsAnimal struct {
Typename string `json:"__typename"`
Id string `json:"id"`
Name string `json:"name"`
Hair queryWithFragmentsBeingsAnimalHairBeingsHair `json:"hair"`
Species Species `json:"species"`
Owner json.RawMessage `json:"owner"`
}
func (v *queryWithFragmentsBeingsAnimal) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithFragmentsBeingsAnimal) __premarshalJSON() (*__premarshalqueryWithFragmentsBeingsAnimal, error) {
var retval __premarshalqueryWithFragmentsBeingsAnimal
retval.Typename = v.Typename
retval.Id = v.Id
retval.Name = v.Name
retval.Hair = v.Hair
retval.Species = v.Species
{
dst := &retval.Owner
src := v.Owner
var err error
*dst, err = __marshalqueryWithFragmentsBeingsAnimalOwnerBeing(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithFragmentsBeingsAnimal.Owner: %w", err)
}
}
return &retval, 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(b []byte, v *queryWithFragmentsBeingsAnimalOwnerBeing) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(queryWithFragmentsBeingsAnimalOwnerUser)
return json.Unmarshal(b, *v)
case "Animal":
*v = new(queryWithFragmentsBeingsAnimalOwnerAnimal)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"Response was missing Being.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for queryWithFragmentsBeingsAnimalOwnerBeing: "%v"`, tn.TypeName)
}
}
func __marshalqueryWithFragmentsBeingsAnimalOwnerBeing(v *queryWithFragmentsBeingsAnimalOwnerBeing) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *queryWithFragmentsBeingsAnimalOwnerUser:
typename = "User"
result := struct {
TypeName string `json:"__typename"`
*queryWithFragmentsBeingsAnimalOwnerUser
}{typename, v}
return json.Marshal(result)
case *queryWithFragmentsBeingsAnimalOwnerAnimal:
typename = "Animal"
result := struct {
TypeName string `json:"__typename"`
*queryWithFragmentsBeingsAnimalOwnerAnimal
}{typename, v}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`Unexpected concrete type for queryWithFragmentsBeingsAnimalOwnerBeing: "%T"`, v)
}
}
// 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(b []byte, v *queryWithFragmentsBeingsBeing) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(queryWithFragmentsBeingsUser)
return json.Unmarshal(b, *v)
case "Animal":
*v = new(queryWithFragmentsBeingsAnimal)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"Response was missing Being.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for queryWithFragmentsBeingsBeing: "%v"`, tn.TypeName)
}
}
func __marshalqueryWithFragmentsBeingsBeing(v *queryWithFragmentsBeingsBeing) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *queryWithFragmentsBeingsUser:
typename = "User"
result := struct {
TypeName string `json:"__typename"`
*queryWithFragmentsBeingsUser
}{typename, v}
return json.Marshal(result)
case *queryWithFragmentsBeingsAnimal:
typename = "Animal"
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
result := struct {
TypeName string `json:"__typename"`
*__premarshalqueryWithFragmentsBeingsAnimal
}{typename, premarshaled}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`Unexpected concrete type for queryWithFragmentsBeingsBeing: "%T"`, v)
}
}
// 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 {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithFragmentsResponse
Beings []json.RawMessage `json:"beings"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithFragmentsResponse = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Beings
src := firstPass.Beings
*dst = make(
[]queryWithFragmentsBeingsBeing,
len(src))
for i, src := range src {
dst := &(*dst)[i]
if len(src) != 0 && string(src) != "null" {
err = __unmarshalqueryWithFragmentsBeingsBeing(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithFragmentsResponse.Beings: %w", err)
}
}
}
}
return nil
}
type __premarshalqueryWithFragmentsResponse struct {
Beings []json.RawMessage `json:"beings"`
}
func (v *queryWithFragmentsResponse) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithFragmentsResponse) __premarshalJSON() (*__premarshalqueryWithFragmentsResponse, error) {
var retval __premarshalqueryWithFragmentsResponse
{
dst := &retval.Beings
src := v.Beings
*dst = make(
[]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
var err error
*dst, err = __marshalqueryWithFragmentsBeingsBeing(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithFragmentsResponse.Beings: %w", err)
}
}
}
return &retval, 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(b []byte, v *queryWithInterfaceListFieldBeingsBeing) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(queryWithInterfaceListFieldBeingsUser)
return json.Unmarshal(b, *v)
case "Animal":
*v = new(queryWithInterfaceListFieldBeingsAnimal)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"Response was missing Being.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for queryWithInterfaceListFieldBeingsBeing: "%v"`, tn.TypeName)
}
}
func __marshalqueryWithInterfaceListFieldBeingsBeing(v *queryWithInterfaceListFieldBeingsBeing) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *queryWithInterfaceListFieldBeingsUser:
typename = "User"
result := struct {
TypeName string `json:"__typename"`
*queryWithInterfaceListFieldBeingsUser
}{typename, v}
return json.Marshal(result)
case *queryWithInterfaceListFieldBeingsAnimal:
typename = "Animal"
result := struct {
TypeName string `json:"__typename"`
*queryWithInterfaceListFieldBeingsAnimal
}{typename, v}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`Unexpected concrete type for queryWithInterfaceListFieldBeingsBeing: "%T"`, v)
}
}
// 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 {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithInterfaceListFieldResponse
Beings []json.RawMessage `json:"beings"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithInterfaceListFieldResponse = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Beings
src := firstPass.Beings
*dst = make(
[]queryWithInterfaceListFieldBeingsBeing,
len(src))
for i, src := range src {
dst := &(*dst)[i]
if len(src) != 0 && string(src) != "null" {
err = __unmarshalqueryWithInterfaceListFieldBeingsBeing(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithInterfaceListFieldResponse.Beings: %w", err)
}
}
}
}
return nil
}
type __premarshalqueryWithInterfaceListFieldResponse struct {
Beings []json.RawMessage `json:"beings"`
}
func (v *queryWithInterfaceListFieldResponse) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithInterfaceListFieldResponse) __premarshalJSON() (*__premarshalqueryWithInterfaceListFieldResponse, error) {
var retval __premarshalqueryWithInterfaceListFieldResponse
{
dst := &retval.Beings
src := v.Beings
*dst = make(
[]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
var err error
*dst, err = __marshalqueryWithInterfaceListFieldBeingsBeing(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithInterfaceListFieldResponse.Beings: %w", err)
}
}
}
return &retval, 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(b []byte, v *queryWithInterfaceListPointerFieldBeingsBeing) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(queryWithInterfaceListPointerFieldBeingsUser)
return json.Unmarshal(b, *v)
case "Animal":
*v = new(queryWithInterfaceListPointerFieldBeingsAnimal)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"Response was missing Being.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for queryWithInterfaceListPointerFieldBeingsBeing: "%v"`, tn.TypeName)
}
}
func __marshalqueryWithInterfaceListPointerFieldBeingsBeing(v *queryWithInterfaceListPointerFieldBeingsBeing) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *queryWithInterfaceListPointerFieldBeingsUser:
typename = "User"
result := struct {
TypeName string `json:"__typename"`
*queryWithInterfaceListPointerFieldBeingsUser
}{typename, v}
return json.Marshal(result)
case *queryWithInterfaceListPointerFieldBeingsAnimal:
typename = "Animal"
result := struct {
TypeName string `json:"__typename"`
*queryWithInterfaceListPointerFieldBeingsAnimal
}{typename, v}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`Unexpected concrete type for queryWithInterfaceListPointerFieldBeingsBeing: "%T"`, v)
}
}
// 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 {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithInterfaceListPointerFieldResponse
Beings []json.RawMessage `json:"beings"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithInterfaceListPointerFieldResponse = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Beings
src := firstPass.Beings
*dst = make(
[]*queryWithInterfaceListPointerFieldBeingsBeing,
len(src))
for i, src := range src {
dst := &(*dst)[i]
if len(src) != 0 && string(src) != "null" {
*dst = new(queryWithInterfaceListPointerFieldBeingsBeing)
err = __unmarshalqueryWithInterfaceListPointerFieldBeingsBeing(
src, *dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithInterfaceListPointerFieldResponse.Beings: %w", err)
}
}
}
}
return nil
}
type __premarshalqueryWithInterfaceListPointerFieldResponse struct {
Beings []json.RawMessage `json:"beings"`
}
func (v *queryWithInterfaceListPointerFieldResponse) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithInterfaceListPointerFieldResponse) __premarshalJSON() (*__premarshalqueryWithInterfaceListPointerFieldResponse, error) {
var retval __premarshalqueryWithInterfaceListPointerFieldResponse
{
dst := &retval.Beings
src := v.Beings
*dst = make(
[]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
if src != nil {
var err error
*dst, err = __marshalqueryWithInterfaceListPointerFieldBeingsBeing(
src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithInterfaceListPointerFieldResponse.Beings: %w", err)
}
}
}
}
return &retval, 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(b []byte, v *queryWithInterfaceNoFragmentsBeing) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(queryWithInterfaceNoFragmentsBeingUser)
return json.Unmarshal(b, *v)
case "Animal":
*v = new(queryWithInterfaceNoFragmentsBeingAnimal)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"Response was missing Being.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for queryWithInterfaceNoFragmentsBeing: "%v"`, tn.TypeName)
}
}
func __marshalqueryWithInterfaceNoFragmentsBeing(v *queryWithInterfaceNoFragmentsBeing) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *queryWithInterfaceNoFragmentsBeingUser:
typename = "User"
result := struct {
TypeName string `json:"__typename"`
*queryWithInterfaceNoFragmentsBeingUser
}{typename, v}
return json.Marshal(result)
case *queryWithInterfaceNoFragmentsBeingAnimal:
typename = "Animal"
result := struct {
TypeName string `json:"__typename"`
*queryWithInterfaceNoFragmentsBeingAnimal
}{typename, v}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`Unexpected concrete type for queryWithInterfaceNoFragmentsBeing: "%T"`, v)
}
}
// 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 {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithInterfaceNoFragmentsResponse
Being json.RawMessage `json:"being"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithInterfaceNoFragmentsResponse = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Being
src := firstPass.Being
if len(src) != 0 && string(src) != "null" {
err = __unmarshalqueryWithInterfaceNoFragmentsBeing(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithInterfaceNoFragmentsResponse.Being: %w", err)
}
}
}
return nil
}
type __premarshalqueryWithInterfaceNoFragmentsResponse struct {
Being json.RawMessage `json:"being"`
Me queryWithInterfaceNoFragmentsMeUser `json:"me"`
}
func (v *queryWithInterfaceNoFragmentsResponse) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithInterfaceNoFragmentsResponse) __premarshalJSON() (*__premarshalqueryWithInterfaceNoFragmentsResponse, error) {
var retval __premarshalqueryWithInterfaceNoFragmentsResponse
{
dst := &retval.Being
src := v.Being
var err error
*dst, err = __marshalqueryWithInterfaceNoFragmentsBeing(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithInterfaceNoFragmentsResponse.Being: %w", err)
}
}
retval.Me = v.Me
return &retval, 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 {
if string(b) == "null" {
return nil
}
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
}
type __premarshalqueryWithNamedFragmentsBeingsAnimal struct {
Typename string `json:"__typename"`
Id string `json:"id"`
Hair AnimalFieldsHairBeingsHair `json:"hair"`
Owner json.RawMessage `json:"owner"`
}
func (v *queryWithNamedFragmentsBeingsAnimal) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithNamedFragmentsBeingsAnimal) __premarshalJSON() (*__premarshalqueryWithNamedFragmentsBeingsAnimal, error) {
var retval __premarshalqueryWithNamedFragmentsBeingsAnimal
retval.Typename = v.Typename
retval.Id = v.Id
retval.Hair = v.AnimalFields.Hair
{
dst := &retval.Owner
src := v.AnimalFields.Owner
var err error
*dst, err = __marshalAnimalFieldsOwnerBeing(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithNamedFragmentsBeingsAnimal.AnimalFields.Owner: %w", err)
}
}
return &retval, 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(b []byte, v *queryWithNamedFragmentsBeingsBeing) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "User":
*v = new(queryWithNamedFragmentsBeingsUser)
return json.Unmarshal(b, *v)
case "Animal":
*v = new(queryWithNamedFragmentsBeingsAnimal)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"Response was missing Being.__typename")
default:
return fmt.Errorf(
`Unexpected concrete type for queryWithNamedFragmentsBeingsBeing: "%v"`, tn.TypeName)
}
}
func __marshalqueryWithNamedFragmentsBeingsBeing(v *queryWithNamedFragmentsBeingsBeing) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *queryWithNamedFragmentsBeingsUser:
typename = "User"
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
result := struct {
TypeName string `json:"__typename"`
*__premarshalqueryWithNamedFragmentsBeingsUser
}{typename, premarshaled}
return json.Marshal(result)
case *queryWithNamedFragmentsBeingsAnimal:
typename = "Animal"
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
result := struct {
TypeName string `json:"__typename"`
*__premarshalqueryWithNamedFragmentsBeingsAnimal
}{typename, premarshaled}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`Unexpected concrete type for queryWithNamedFragmentsBeingsBeing: "%T"`, v)
}
}
// 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 {
if string(b) == "null" {
return nil
}
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
}
type __premarshalqueryWithNamedFragmentsBeingsUser struct {
Typename string `json:"__typename"`
Id string `json:"id"`
LuckyNumber int `json:"luckyNumber"`
Hair MoreUserFieldsHair `json:"hair"`
}
func (v *queryWithNamedFragmentsBeingsUser) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithNamedFragmentsBeingsUser) __premarshalJSON() (*__premarshalqueryWithNamedFragmentsBeingsUser, error) {
var retval __premarshalqueryWithNamedFragmentsBeingsUser
retval.Typename = v.Typename
retval.Id = v.Id
retval.LuckyNumber = v.UserFields.LuckyFieldsUser.LuckyNumber
retval.Hair = v.UserFields.MoreUserFields.Hair
return &retval, nil
}
// queryWithNamedFragmentsResponse is returned by queryWithNamedFragments on success.
type queryWithNamedFragmentsResponse struct {
Beings []queryWithNamedFragmentsBeingsBeing `json:"-"`
}
func (v *queryWithNamedFragmentsResponse) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*queryWithNamedFragmentsResponse
Beings []json.RawMessage `json:"beings"`
graphql.NoUnmarshalJSON
}
firstPass.queryWithNamedFragmentsResponse = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Beings
src := firstPass.Beings
*dst = make(
[]queryWithNamedFragmentsBeingsBeing,
len(src))
for i, src := range src {
dst := &(*dst)[i]
if len(src) != 0 && string(src) != "null" {
err = __unmarshalqueryWithNamedFragmentsBeingsBeing(
src, dst)
if err != nil {
return fmt.Errorf(
"Unable to unmarshal queryWithNamedFragmentsResponse.Beings: %w", err)
}
}
}
}
return nil
}
type __premarshalqueryWithNamedFragmentsResponse struct {
Beings []json.RawMessage `json:"beings"`
}
func (v *queryWithNamedFragmentsResponse) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *queryWithNamedFragmentsResponse) __premarshalJSON() (*__premarshalqueryWithNamedFragmentsResponse, error) {
var retval __premarshalqueryWithNamedFragmentsResponse
{
dst := &retval.Beings
src := v.Beings
*dst = make(
[]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
var err error
*dst, err = __marshalqueryWithNamedFragmentsBeingsBeing(
&src)
if err != nil {
return nil, fmt.Errorf(
"Unable to marshal queryWithNamedFragmentsResponse.Beings: %w", err)
}
}
}
return &retval, nil
}
// queryWithOmitemptyResponse is returned by queryWithOmitempty on success.
type queryWithOmitemptyResponse struct {
User queryWithOmitemptyUser `json:"user"`
}
// queryWithOmitemptyUser includes the requested fields of the GraphQL type User.
type queryWithOmitemptyUser struct {
Id string `json:"id"`
Name string `json:"name"`
LuckyNumber int `json:"luckyNumber"`
}
// 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) {
__input := __queryWithVariablesInput{
Id: id,
}
var err error
var retval queryWithVariablesResponse
err = client.MakeRequest(
ctx,
"queryWithVariables",
`
query queryWithVariables ($id: ID!) {
user(id: $id) {
id
name
luckyNumber
}
}
`,
&retval,
&__input,
)
return &retval, err
}
func queryWithOmitempty(
ctx context.Context,
client graphql.Client,
id string,
) (*queryWithOmitemptyResponse, error) {
__input := __queryWithOmitemptyInput{
Id: id,
}
var err error
var retval queryWithOmitemptyResponse
err = client.MakeRequest(
ctx,
"queryWithOmitempty",
`
query queryWithOmitempty ($id: ID) {
user(id: $id) {
id
name
luckyNumber
}
}
`,
&retval,
&__input,
)
return &retval, err
}
func queryWithCustomMarshal(
ctx context.Context,
client graphql.Client,
date time.Time,
) (*queryWithCustomMarshalResponse, error) {
__input := __queryWithCustomMarshalInput{
Date: date,
}
var err error
var retval queryWithCustomMarshalResponse
err = client.MakeRequest(
ctx,
"queryWithCustomMarshal",
`
query queryWithCustomMarshal ($date: Date!) {
usersBornOn(date: $date) {
id
name
birthdate
}
}
`,
&retval,
&__input,
)
return &retval, err
}
func queryWithCustomMarshalSlice(
ctx context.Context,
client graphql.Client,
dates []time.Time,
) (*queryWithCustomMarshalSliceResponse, error) {
__input := __queryWithCustomMarshalSliceInput{
Dates: dates,
}
var err error
var retval queryWithCustomMarshalSliceResponse
err = client.MakeRequest(
ctx,
"queryWithCustomMarshalSlice",
`
query queryWithCustomMarshalSlice ($dates: [Date!]!) {
usersBornOnDates(dates: $dates) {
id
name
birthdate
}
}
`,
&retval,
&__input,
)
return &retval, err
}
func queryWithCustomMarshalOptional(
ctx context.Context,
client graphql.Client,
date *time.Time,
id *string,
) (*queryWithCustomMarshalOptionalResponse, error) {
__input := __queryWithCustomMarshalOptionalInput{
Date: date,
Id: id,
}
var err error
var retval queryWithCustomMarshalOptionalResponse
err = client.MakeRequest(
ctx,
"queryWithCustomMarshalOptional",
`
query queryWithCustomMarshalOptional ($date: Date, $id: ID) {
userSearch(birthdate: $date, id: $id) {
id
name
birthdate
}
}
`,
&retval,
&__input,
)
return &retval, err
}
func queryWithInterfaceNoFragments(
ctx context.Context,
client graphql.Client,
id string,
) (*queryWithInterfaceNoFragmentsResponse, error) {
__input := __queryWithInterfaceNoFragmentsInput{
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,
&__input,
)
return &retval, err
}
func queryWithInterfaceListField(
ctx context.Context,
client graphql.Client,
ids []string,
) (*queryWithInterfaceListFieldResponse, error) {
__input := __queryWithInterfaceListFieldInput{
Ids: ids,
}
var err error
var retval queryWithInterfaceListFieldResponse
err = client.MakeRequest(
ctx,
"queryWithInterfaceListField",
`
query queryWithInterfaceListField ($ids: [ID!]!) {
beings(ids: $ids) {
__typename
id
name
}
}
`,
&retval,
&__input,
)
return &retval, err
}
func queryWithInterfaceListPointerField(
ctx context.Context,
client graphql.Client,
ids []string,
) (*queryWithInterfaceListPointerFieldResponse, error) {
__input := __queryWithInterfaceListPointerFieldInput{
Ids: ids,
}
var err error
var retval queryWithInterfaceListPointerFieldResponse
err = client.MakeRequest(
ctx,
"queryWithInterfaceListPointerField",
`
query queryWithInterfaceListPointerField ($ids: [ID!]!) {
beings(ids: $ids) {
__typename
id
name
}
}
`,
&retval,
&__input,
)
return &retval, err
}
func queryWithFragments(
ctx context.Context,
client graphql.Client,
ids []string,
) (*queryWithFragmentsResponse, error) {
__input := __queryWithFragmentsInput{
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,
&__input,
)
return &retval, err
}
func queryWithNamedFragments(
ctx context.Context,
client graphql.Client,
ids []string,
) (*queryWithNamedFragmentsResponse, error) {
__input := __queryWithNamedFragmentsInput{
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,
&__input,
)
return &retval, err
}