Files
genqlient/example/generated.go
T
Adam BabikandGitHub f0c2ac17a9 Move 'Code generated by' disclaimer up (#161)
`Code generated by` disclaimer should be at the top of the file, as it is demonstrated in [this article](https://go.dev/blog/generate) on The Go Blog.

The current placing breaks integration with some code formatters and linters which do no skip files generated by `genqlient`.
2021-12-20 10:04:13 -05:00

124 lines
3.3 KiB
Go

// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
package main
import (
"context"
"time"
"github.com/Khan/genqlient/graphql"
)
// __getUserInput is used internally by genqlient
type __getUserInput struct {
Login string `json:"Login"`
}
// GetLogin returns __getUserInput.Login, and is useful for accessing the field via an interface.
func (v *__getUserInput) GetLogin() string { return v.Login }
// getUserResponse is returned by getUser on success.
type getUserResponse struct {
// Lookup a user by login.
User getUserUser `json:"user"`
}
// GetUser returns getUserResponse.User, and is useful for accessing the field via an interface.
func (v *getUserResponse) GetUser() getUserUser { return v.User }
// getUserUser includes the requested fields of the GraphQL type User.
// The GraphQL type's documentation follows.
//
// A user is an individual's account on GitHub that owns repositories and can make new content.
type getUserUser struct {
// The user's public profile name.
TheirName string `json:"theirName"`
// Identifies the date and time when the object was created.
CreatedAt time.Time `json:"createdAt"`
}
// GetTheirName returns getUserUser.TheirName, and is useful for accessing the field via an interface.
func (v *getUserUser) GetTheirName() string { return v.TheirName }
// GetCreatedAt returns getUserUser.CreatedAt, and is useful for accessing the field via an interface.
func (v *getUserUser) GetCreatedAt() time.Time { return v.CreatedAt }
// getViewerResponse is returned by getViewer on success.
type getViewerResponse struct {
// The currently authenticated user.
Viewer getViewerViewerUser `json:"viewer"`
}
// GetViewer returns getViewerResponse.Viewer, and is useful for accessing the field via an interface.
func (v *getViewerResponse) GetViewer() getViewerViewerUser { return v.Viewer }
// getViewerViewerUser includes the requested fields of the GraphQL type User.
// The GraphQL type's documentation follows.
//
// A user is an individual's account on GitHub that owns repositories and can make new content.
type getViewerViewerUser struct {
// The user's public profile name.
MyName string `json:"MyName"`
// Identifies the date and time when the object was created.
CreatedAt time.Time `json:"createdAt"`
}
// GetMyName returns getViewerViewerUser.MyName, and is useful for accessing the field via an interface.
func (v *getViewerViewerUser) GetMyName() string { return v.MyName }
// GetCreatedAt returns getViewerViewerUser.CreatedAt, and is useful for accessing the field via an interface.
func (v *getViewerViewerUser) GetCreatedAt() time.Time { return v.CreatedAt }
// getUser gets the given user's name from their username.
func getUser(
ctx context.Context,
client graphql.Client,
Login string,
) (*getUserResponse, error) {
__input := __getUserInput{
Login: Login,
}
var err error
var retval getUserResponse
err = client.MakeRequest(
ctx,
"getUser",
`
query getUser ($Login: String!) {
user(login: $Login) {
theirName: name
createdAt
}
}
`,
&retval,
&__input,
)
return &retval, err
}
func getViewer(
ctx context.Context,
client graphql.Client,
) (*getViewerResponse, error) {
var err error
var retval getViewerResponse
err = client.MakeRequest(
ctx,
"getViewer",
`
query getViewer {
viewer {
MyName: name
createdAt
}
}
`,
&retval,
nil,
)
return &retval, err
}