Files
genqlient/generate/testdata/snapshots/TestGenerateWithConfig-EnumRawCasingSpecific-testdata-queries-generated.go
Ben KraftandGitHub ff790e1c06 Add an option to handle enums with ugly casing (#270)
There are a bunch of places in genqlient where we just kind of hope you
don't have ridiculous casing conflicts in your schema. Apparently with
enum values there are actual schemas that have this problem! Now we have
an option to disable. I ended up putting it all under `casing` instead
of in `bindings` so we can clearly document the list of algorithms we
support, and so we can have an `all_enums` value if you're working with
a schema with a lot of this; in the future we may want to add similar
behavior for types/fields, add more possible algorithms (e.g. to make
things unexported), etc.

I added tests for the new feature, although the way the tests are set up
it wasn't convenient to do so for a schema where this is actually
required. I also added a check for case conflicts that points you to
this option. (I don't want to do it automatically for reasons described
in the issue; mainly it just seemed a bit too magical.)

Fixes #265.
2023-05-07 12:15:13 -07:00

101 lines
3.0 KiB
Go

// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
package queries
import (
"context"
"github.com/Khan/genqlient/graphql"
)
// QueryWithEnumsOtherUser includes the requested fields of the GraphQL type User.
// The GraphQL type's documentation follows.
//
// A User is a user!
type QueryWithEnumsOtherUser struct {
Roles []Role `json:"roles"`
}
// GetRoles returns QueryWithEnumsOtherUser.Roles, and is useful for accessing the field via an interface.
func (v *QueryWithEnumsOtherUser) GetRoles() []Role { return v.Roles }
// QueryWithEnumsResponse is returned by QueryWithEnums on success.
type QueryWithEnumsResponse 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 QueryWithEnumsUser `json:"user"`
// user looks up a user by some stuff.
//
// See UserQueryInput for what stuff is supported.
// If query is null, returns the current user.
OtherUser QueryWithEnumsOtherUser `json:"otherUser"`
}
// GetUser returns QueryWithEnumsResponse.User, and is useful for accessing the field via an interface.
func (v *QueryWithEnumsResponse) GetUser() QueryWithEnumsUser { return v.User }
// GetOtherUser returns QueryWithEnumsResponse.OtherUser, and is useful for accessing the field via an interface.
func (v *QueryWithEnumsResponse) GetOtherUser() QueryWithEnumsOtherUser { return v.OtherUser }
// QueryWithEnumsUser includes the requested fields of the GraphQL type User.
// The GraphQL type's documentation follows.
//
// A User is a user!
type QueryWithEnumsUser struct {
Roles []Role `json:"roles"`
}
// GetRoles returns QueryWithEnumsUser.Roles, and is useful for accessing the field via an interface.
func (v *QueryWithEnumsUser) GetRoles() []Role { return v.Roles }
// Role is a type a user may have.
type Role string
const (
// What is a student?
//
// A student is primarily a person enrolled in a school or other educational institution and who is under learning with goals of acquiring knowledge, developing professions and achieving employment at desired field. In the broader sense, a student is anyone who applies themselves to the intensive intellectual engagement with some matter necessary to master it as part of some practical affair in which such mastery is basic or decisive.
//
// (from [Wikipedia](https://en.wikipedia.org/wiki/Student))
Role_STUDENT Role = "STUDENT"
// Teacher is a teacher, who teaches the students.
Role_TEACHER Role = "TEACHER"
)
// The query or mutation executed by QueryWithEnums.
const QueryWithEnums_Operation = `
query QueryWithEnums {
user {
roles
}
otherUser: user {
roles
}
}
`
func QueryWithEnums(
ctx context.Context,
client graphql.Client,
) (*QueryWithEnumsResponse, error) {
req := &graphql.Request{
OpName: "QueryWithEnums",
Query: QueryWithEnums_Operation,
}
var err error
var data QueryWithEnumsResponse
resp := &graphql.Response{Data: &data}
err = client.MakeRequest(
ctx,
req,
resp,
)
return &data, err
}