Files
genqlient/generate/testdata/snapshots/TestGenerate-CustomMarshalSlice.graphql-CustomMarshalSlice.graphql.go
T
Craig Silverstein e3227388fe Rename the query constant to have an underscore in it. (#241)
We got reports of conflicts with the old constant-name and symbols that
people were defining in their app.
2022-11-22 14:12:38 -08:00

241 lines
5.6 KiB
Go

// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
package test
import (
"encoding/json"
"fmt"
"time"
"github.com/Khan/genqlient/graphql"
"github.com/Khan/genqlient/internal/testutil"
)
// CustomMarshalSliceResponse is returned by CustomMarshalSlice on success.
type CustomMarshalSliceResponse struct {
AcceptsListOfListOfListsOfDates bool `json:"acceptsListOfListOfListsOfDates"`
WithPointer bool `json:"withPointer"`
}
// GetAcceptsListOfListOfListsOfDates returns CustomMarshalSliceResponse.AcceptsListOfListOfListsOfDates, and is useful for accessing the field via an interface.
func (v *CustomMarshalSliceResponse) GetAcceptsListOfListOfListsOfDates() bool {
return v.AcceptsListOfListOfListsOfDates
}
// GetWithPointer returns CustomMarshalSliceResponse.WithPointer, and is useful for accessing the field via an interface.
func (v *CustomMarshalSliceResponse) GetWithPointer() bool { return v.WithPointer }
// __CustomMarshalSliceInput is used internally by genqlient
type __CustomMarshalSliceInput struct {
Datesss [][][]time.Time `json:"-"`
Datesssp [][][]*time.Time `json:"-"`
}
// GetDatesss returns __CustomMarshalSliceInput.Datesss, and is useful for accessing the field via an interface.
func (v *__CustomMarshalSliceInput) GetDatesss() [][][]time.Time { return v.Datesss }
// GetDatesssp returns __CustomMarshalSliceInput.Datesssp, and is useful for accessing the field via an interface.
func (v *__CustomMarshalSliceInput) GetDatesssp() [][][]*time.Time { return v.Datesssp }
func (v *__CustomMarshalSliceInput) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*__CustomMarshalSliceInput
Datesss [][][]json.RawMessage `json:"datesss"`
Datesssp [][][]json.RawMessage `json:"datesssp"`
graphql.NoUnmarshalJSON
}
firstPass.__CustomMarshalSliceInput = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.Datesss
src := firstPass.Datesss
*dst = make(
[][][]time.Time,
len(src))
for i, src := range src {
dst := &(*dst)[i]
*dst = make(
[][]time.Time,
len(src))
for i, src := range src {
dst := &(*dst)[i]
*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 __CustomMarshalSliceInput.Datesss: %w", err)
}
}
}
}
}
}
{
dst := &v.Datesssp
src := firstPass.Datesssp
*dst = make(
[][][]*time.Time,
len(src))
for i, src := range src {
dst := &(*dst)[i]
*dst = make(
[][]*time.Time,
len(src))
for i, src := range src {
dst := &(*dst)[i]
*dst = make(
[]*time.Time,
len(src))
for i, src := range src {
dst := &(*dst)[i]
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 __CustomMarshalSliceInput.Datesssp: %w", err)
}
}
}
}
}
}
return nil
}
type __premarshal__CustomMarshalSliceInput struct {
Datesss [][][]json.RawMessage `json:"datesss"`
Datesssp [][][]json.RawMessage `json:"datesssp"`
}
func (v *__CustomMarshalSliceInput) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *__CustomMarshalSliceInput) __premarshalJSON() (*__premarshal__CustomMarshalSliceInput, error) {
var retval __premarshal__CustomMarshalSliceInput
{
dst := &retval.Datesss
src := v.Datesss
*dst = make(
[][][]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
*dst = make(
[][]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
*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 __CustomMarshalSliceInput.Datesss: %w", err)
}
}
}
}
}
{
dst := &retval.Datesssp
src := v.Datesssp
*dst = make(
[][][]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
*dst = make(
[][]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
*dst = make(
[]json.RawMessage,
len(src))
for i, src := range src {
dst := &(*dst)[i]
if src != nil {
var err error
*dst, err = testutil.MarshalDate(
src)
if err != nil {
return nil, fmt.Errorf(
"unable to marshal __CustomMarshalSliceInput.Datesssp: %w", err)
}
}
}
}
}
}
return &retval, nil
}
// The query or mutation executed by CustomMarshalSlice.
const CustomMarshalSlice_Operation = `
query CustomMarshalSlice ($datesss: [[[Date!]!]!]!, $datesssp: [[[Date!]!]!]!) {
acceptsListOfListOfListsOfDates(datesss: $datesss)
withPointer: acceptsListOfListOfListsOfDates(datesss: $datesssp)
}
`
func CustomMarshalSlice(
client graphql.Client,
datesss [][][]time.Time,
datesssp [][][]*time.Time,
) (*CustomMarshalSliceResponse, error) {
req := &graphql.Request{
OpName: "CustomMarshalSlice",
Query: CustomMarshalSlice_Operation,
Variables: &__CustomMarshalSliceInput{
Datesss: datesss,
Datesssp: datesssp,
},
}
var err error
var data CustomMarshalSliceResponse
resp := &graphql.Response{Data: &data}
err = client.MakeRequest(
nil,
req,
resp,
)
return &data, err
}