package test // Code generated by github.com/Khan/genqlient, DO NOT EDIT. import ( "encoding/json" "fmt" "time" "github.com/Khan/genqlient/graphql" "github.com/Khan/genqlient/internal/testutil" ) // CustomMarshalResponse is returned by CustomMarshal on success. type CustomMarshalResponse struct { UsersBornOn []CustomMarshalUsersBornOnUser `json:"usersBornOn"` } // CustomMarshalUsersBornOnUser includes the requested fields of the GraphQL type User. // The GraphQL type's documentation follows. // // A User is a user! type CustomMarshalUsersBornOnUser struct { // id is the user's ID. // // It is stable, unique, and opaque, like all good IDs. Id testutil.ID `json:"id"` Birthdate time.Time `json:"-"` } func (v *CustomMarshalUsersBornOnUser) UnmarshalJSON(b []byte) error { if string(b) == "null" { return nil } var firstPass struct { *CustomMarshalUsersBornOnUser Birthdate json.RawMessage `json:"birthdate"` graphql.NoUnmarshalJSON } firstPass.CustomMarshalUsersBornOnUser = v err := json.Unmarshal(b, &firstPass) if err != nil { return err } { dst := &v.Birthdate src := firstPass.Birthdate err = testutil.UnmarshalDate( src, dst) if err != nil { return fmt.Errorf( "Unable to unmarshal CustomMarshalUsersBornOnUser.Birthdate: %w", err) } } return nil } // __CustomMarshalInput is used internally by genqlient type __CustomMarshalInput struct { Date time.Time `json:"-"` } func (v *__CustomMarshalInput) MarshalJSON() ([]byte, error) { var fullObject struct { *__CustomMarshalInput Date json.RawMessage `json:"date"` graphql.NoMarshalJSON } fullObject.__CustomMarshalInput = v { dst := &fullObject.Date src := v.Date var err error *dst, err = testutil.MarshalDate( &src) if err != nil { return nil, fmt.Errorf( "Unable to marshal __CustomMarshalInput.Date: %w", err) } } return json.Marshal(&fullObject) } func CustomMarshal( client graphql.Client, date time.Time, ) (*CustomMarshalResponse, error) { __input := __CustomMarshalInput{ Date: date, } var err error var retval CustomMarshalResponse err = client.MakeRequest( nil, "CustomMarshal", ` query CustomMarshal ($date: Date!) { usersBornOn(date: $date) { id birthdate } } `, &retval, &__input, ) return &retval, err }