This allows client code to see the operation (query or mutation) exactly
as genqlient sends it over the wire. This data was already available in
the generated safelist.json file, but now it's easily available from Go
code as well.
Fixes #236
I have:
- [x] Written a clear PR title and description (above)
- [x] Signed the [Khan Academy CLA](https://www.khanacademy.org/r/cla)
- [x] Added tests covering my changes, if applicable
- [x] Included a link to the issue fixed, if applicable
- [x] Included documentation, for new features
- [x] Added an entry to the changelog
118 lines
3.9 KiB
Go
118 lines
3.9 KiB
Go
// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
|
|
|
|
package test
|
|
|
|
import (
|
|
"github.com/Khan/genqlient/graphql"
|
|
"github.com/Khan/genqlient/internal/testutil"
|
|
)
|
|
|
|
// GetPokemonSiblingsResponse is returned by GetPokemonSiblings on success.
|
|
type GetPokemonSiblingsResponse struct {
|
|
// user looks up a user by some stuff.
|
|
//
|
|
// See UserQueryInput for what stuff is supported.
|
|
// If query is null, returns the current user.
|
|
User GetPokemonSiblingsUser `json:"user"`
|
|
}
|
|
|
|
// GetUser returns GetPokemonSiblingsResponse.User, and is useful for accessing the field via an interface.
|
|
func (v *GetPokemonSiblingsResponse) GetUser() GetPokemonSiblingsUser { return v.User }
|
|
|
|
// GetPokemonSiblingsUser includes the requested fields of the GraphQL type User.
|
|
// The GraphQL type's documentation follows.
|
|
//
|
|
// A User is a user!
|
|
type GetPokemonSiblingsUser struct {
|
|
// id is the user's ID.
|
|
//
|
|
// It is stable, unique, and opaque, like all good IDs.
|
|
Id string `json:"id"`
|
|
Roles []string `json:"roles"`
|
|
Name string `json:"name"`
|
|
Pokemon []testutil.Pokemon `json:"pokemon"`
|
|
GenqlientPokemon []GetPokemonSiblingsUserGenqlientPokemon `json:"genqlientPokemon"`
|
|
}
|
|
|
|
// GetId returns GetPokemonSiblingsUser.Id, and is useful for accessing the field via an interface.
|
|
func (v *GetPokemonSiblingsUser) GetId() string { return v.Id }
|
|
|
|
// GetRoles returns GetPokemonSiblingsUser.Roles, and is useful for accessing the field via an interface.
|
|
func (v *GetPokemonSiblingsUser) GetRoles() []string { return v.Roles }
|
|
|
|
// GetName returns GetPokemonSiblingsUser.Name, and is useful for accessing the field via an interface.
|
|
func (v *GetPokemonSiblingsUser) GetName() string { return v.Name }
|
|
|
|
// GetPokemon returns GetPokemonSiblingsUser.Pokemon, and is useful for accessing the field via an interface.
|
|
func (v *GetPokemonSiblingsUser) GetPokemon() []testutil.Pokemon { return v.Pokemon }
|
|
|
|
// GetGenqlientPokemon returns GetPokemonSiblingsUser.GenqlientPokemon, and is useful for accessing the field via an interface.
|
|
func (v *GetPokemonSiblingsUser) GetGenqlientPokemon() []GetPokemonSiblingsUserGenqlientPokemon {
|
|
return v.GenqlientPokemon
|
|
}
|
|
|
|
// GetPokemonSiblingsUserGenqlientPokemon includes the requested fields of the GraphQL type Pokemon.
|
|
type GetPokemonSiblingsUserGenqlientPokemon struct {
|
|
Species string `json:"species"`
|
|
Level int `json:"level"`
|
|
}
|
|
|
|
// GetSpecies returns GetPokemonSiblingsUserGenqlientPokemon.Species, and is useful for accessing the field via an interface.
|
|
func (v *GetPokemonSiblingsUserGenqlientPokemon) GetSpecies() string { return v.Species }
|
|
|
|
// GetLevel returns GetPokemonSiblingsUserGenqlientPokemon.Level, and is useful for accessing the field via an interface.
|
|
func (v *GetPokemonSiblingsUserGenqlientPokemon) GetLevel() int { return v.Level }
|
|
|
|
// __GetPokemonSiblingsInput is used internally by genqlient
|
|
type __GetPokemonSiblingsInput struct {
|
|
Input testutil.Pokemon `json:"input"`
|
|
}
|
|
|
|
// GetInput returns __GetPokemonSiblingsInput.Input, and is useful for accessing the field via an interface.
|
|
func (v *__GetPokemonSiblingsInput) GetInput() testutil.Pokemon { return v.Input }
|
|
|
|
// The query or mutation executed by GetPokemonSiblings.
|
|
const GetPokemonSiblingsOperation = `
|
|
query GetPokemonSiblings ($input: PokemonInput!) {
|
|
user(query: {hasPokemon:$input}) {
|
|
id
|
|
roles
|
|
name
|
|
pokemon {
|
|
species
|
|
level
|
|
}
|
|
genqlientPokemon: pokemon {
|
|
species
|
|
level
|
|
}
|
|
}
|
|
}
|
|
`
|
|
|
|
func GetPokemonSiblings(
|
|
client graphql.Client,
|
|
input testutil.Pokemon,
|
|
) (*GetPokemonSiblingsResponse, error) {
|
|
req := &graphql.Request{
|
|
OpName: "GetPokemonSiblings",
|
|
Query: GetPokemonSiblingsOperation,
|
|
Variables: &__GetPokemonSiblingsInput{
|
|
Input: input,
|
|
},
|
|
}
|
|
var err error
|
|
|
|
var data GetPokemonSiblingsResponse
|
|
resp := &graphql.Response{Data: &data}
|
|
|
|
err = client.MakeRequest(
|
|
nil,
|
|
req,
|
|
resp,
|
|
)
|
|
|
|
return &data, err
|
|
}
|
|
|