## Summary: Previously, we actually allowed you to put several genqlient directives on the same node, but the semantics were undocumented (and somewhat confusing, when it comes to `typename`). In order to support directives on input options, we're actually going to be encouraging this usage (see notes in #14), so it's time to fix it. To avoid confusion, I just had conflicting directives be an error, rather than defining which one "wins". The same applies to specifying the same option several times in one directive. I also fixed two small bugs: - `typename` on an operation would incorrectly cascade down to all input types in a query (causing conflicts). - directive parse errors had useless positions, now they're correct ## Test plan: make check Author: benjaminjkraft Reviewers: StevenACoffman, dnerdy, aberkan, jvoll, mahtabsabet, MiguelCastillo Required Reviewers: Approved By: StevenACoffman, dnerdy Checks: ⌛ Test (1.17), ⌛ Test (1.16), ⌛ Test (1.15), ⌛ Test (1.14), ⌛ Lint, ⌛ Test (1.17), ⌛ Test (1.16), ⌛ Test (1.15), ⌛ Test (1.14), ⌛ Lint Pull Request URL: https://github.com/Khan/genqlient/pull/105
179 lines
4.7 KiB
Go
179 lines
4.7 KiB
Go
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"
|
|
)
|
|
|
|
// UserQueryInput is the argument to Query.users.
|
|
//
|
|
// Ideally this would support anything and everything!
|
|
// Or maybe ideally it wouldn't.
|
|
// Really I'm just talking to make this documentation longer.
|
|
type MyInput struct {
|
|
Email *string `json:"email"`
|
|
Name *string `json:"name"`
|
|
// id looks the user up by ID. It's a great way to look up users.
|
|
Id *testutil.ID `json:"id"`
|
|
Role *Role `json:"role"`
|
|
Names []*string `json:"names"`
|
|
HasPokemon *testutil.Pokemon `json:"hasPokemon"`
|
|
Birthdate *time.Time `json:"-"`
|
|
}
|
|
|
|
func (v *MyInput) MarshalJSON() ([]byte, error) {
|
|
|
|
var fullObject struct {
|
|
*MyInput
|
|
Birthdate json.RawMessage `json:"birthdate"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
fullObject.MyInput = v
|
|
|
|
{
|
|
|
|
dst := &fullObject.Birthdate
|
|
src := v.Birthdate
|
|
var err error
|
|
*dst, err = testutil.MarshalDate(
|
|
src)
|
|
if err != nil {
|
|
return nil, fmt.Errorf(
|
|
"Unable to marshal MyInput.Birthdate: %w", err)
|
|
}
|
|
}
|
|
|
|
return json.Marshal(&fullObject)
|
|
}
|
|
|
|
// MyMultipleDirectivesResponse is returned by MultipleDirectives on success.
|
|
type MyMultipleDirectivesResponse 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 *MyMultipleDirectivesResponseUser `json:"user"`
|
|
Users []*MyMultipleDirectivesResponseUsersUser `json:"users"`
|
|
}
|
|
|
|
// MyMultipleDirectivesResponseUser includes the requested fields of the GraphQL type User.
|
|
// The GraphQL type's documentation follows.
|
|
//
|
|
// A User is a user!
|
|
type MyMultipleDirectivesResponseUser struct {
|
|
// id is the user's ID.
|
|
//
|
|
// It is stable, unique, and opaque, like all good IDs.
|
|
Id *testutil.ID `json:"id"`
|
|
}
|
|
|
|
// MyMultipleDirectivesResponseUsersUser includes the requested fields of the GraphQL type User.
|
|
// The GraphQL type's documentation follows.
|
|
//
|
|
// A User is a user!
|
|
type MyMultipleDirectivesResponseUsersUser struct {
|
|
// id is the user's ID.
|
|
//
|
|
// It is stable, unique, and opaque, like all good IDs.
|
|
Id *testutil.ID `json:"id"`
|
|
}
|
|
|
|
// 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))
|
|
RoleStudent Role = "STUDENT"
|
|
// Teacher is a teacher, who teaches the students.
|
|
RoleTeacher Role = "TEACHER"
|
|
)
|
|
|
|
// UserQueryInput is the argument to Query.users.
|
|
//
|
|
// Ideally this would support anything and everything!
|
|
// Or maybe ideally it wouldn't.
|
|
// Really I'm just talking to make this documentation longer.
|
|
type UserQueryInput struct {
|
|
Email *string `json:"email"`
|
|
Name *string `json:"name"`
|
|
// id looks the user up by ID. It's a great way to look up users.
|
|
Id *testutil.ID `json:"id"`
|
|
Role *Role `json:"role"`
|
|
Names []*string `json:"names"`
|
|
HasPokemon *testutil.Pokemon `json:"hasPokemon"`
|
|
Birthdate *time.Time `json:"-"`
|
|
}
|
|
|
|
func (v *UserQueryInput) MarshalJSON() ([]byte, error) {
|
|
|
|
var fullObject struct {
|
|
*UserQueryInput
|
|
Birthdate json.RawMessage `json:"birthdate"`
|
|
graphql.NoUnmarshalJSON
|
|
}
|
|
fullObject.UserQueryInput = v
|
|
|
|
{
|
|
|
|
dst := &fullObject.Birthdate
|
|
src := v.Birthdate
|
|
var err error
|
|
*dst, err = testutil.MarshalDate(
|
|
src)
|
|
if err != nil {
|
|
return nil, fmt.Errorf(
|
|
"Unable to marshal UserQueryInput.Birthdate: %w", err)
|
|
}
|
|
}
|
|
|
|
return json.Marshal(&fullObject)
|
|
}
|
|
|
|
// __MultipleDirectivesInput is used internally by genqlient
|
|
type __MultipleDirectivesInput struct {
|
|
Query MyInput `json:"query,omitempty"`
|
|
Queries []*UserQueryInput `json:"queries,omitempty"`
|
|
}
|
|
|
|
func MultipleDirectives(
|
|
client graphql.Client,
|
|
query MyInput,
|
|
queries []*UserQueryInput,
|
|
) (*MyMultipleDirectivesResponse, error) {
|
|
__input := __MultipleDirectivesInput{
|
|
Query: query,
|
|
Queries: queries,
|
|
}
|
|
var err error
|
|
|
|
var retval MyMultipleDirectivesResponse
|
|
err = client.MakeRequest(
|
|
nil,
|
|
"MultipleDirectives",
|
|
`
|
|
query MultipleDirectives ($query: UserQueryInput, $queries: [UserQueryInput]) {
|
|
user(query: $query) {
|
|
id
|
|
}
|
|
users(query: $queries) {
|
|
id
|
|
}
|
|
}
|
|
`,
|
|
&retval,
|
|
&__input,
|
|
)
|
|
return &retval, err
|
|
}
|
|
|