Sort operations to guarantee a stable order (#156)
Problem: currently when using a wildcard that covers multiple files in `operations:` YAML directive the generator emits functions in a non-stable ordering due to the use of map for storing file names: https://github.com/Khan/genqlient/blob/e0accbded177db9143314911bacedf61b2cda656/generate/parse.go#L68-L84 Solution: sort the operations before emitting them.
This commit is contained in:
+24
-24
@@ -69,30 +69,6 @@ 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 }
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// getUser gets the given user's name from their username.
|
||||
func getUser(
|
||||
ctx context.Context,
|
||||
@@ -121,3 +97,27 @@ query getUser ($Login: String!) {
|
||||
)
|
||||
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
|
||||
}
|
||||
|
||||
@@ -341,6 +341,12 @@ func Generate(config *Config) (map[string][]byte, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Sort operations to guarantee a stable order
|
||||
sort.Slice(g.Operations, func(i, j int) bool {
|
||||
return g.Operations[i].Name < g.Operations[j].Name
|
||||
})
|
||||
|
||||
for _, operation := range g.Operations {
|
||||
err = g.render("operation.go.tmpl", &bodyBuf, operation)
|
||||
if err != nil {
|
||||
|
||||
@@ -14,7 +14,6 @@ github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig
|
||||
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
|
||||
github.com/bradleyjkemp/cupaloy/v2 v2.6.0 h1:knToPYa2xtfg42U3I6punFEjaGFKWQRXJwj0JTv4mTs=
|
||||
github.com/bradleyjkemp/cupaloy/v2 v2.6.0/go.mod h1:bm7JXdkRd4BHJk9HpwqAI8BoAY1lps46Enkdqw6aRX0=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -36,7 +35,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
|
||||
github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007 h1:reVOUXwnhsYv/8UqjvhrMOu5CNT9UapHFLbQ2JcXsmg=
|
||||
github.com/matryer/moq v0.0.0-20200106131100-75d0ddfc0007/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
@@ -45,17 +43,14 @@ github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047 h1:zCoDWFD5
|
||||
github.com/mitchellh/mapstructure v0.0.0-20180203102830-a4e142e9c047/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
|
||||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
|
||||
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -66,9 +61,7 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
|
||||
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg=
|
||||
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U=
|
||||
github.com/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM=
|
||||
github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4=
|
||||
|
||||
+298
-298
@@ -3019,31 +3019,6 @@ type simpleQueryResponse struct {
|
||||
// GetMe returns simpleQueryResponse.Me, and is useful for accessing the field via an interface.
|
||||
func (v *simpleQueryResponse) GetMe() simpleQueryMeUser { return v.Me }
|
||||
|
||||
func simpleQuery(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
) (*simpleQueryResponse, error) {
|
||||
var err error
|
||||
|
||||
var retval simpleQueryResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"simpleQuery",
|
||||
`
|
||||
query simpleQuery {
|
||||
me {
|
||||
id
|
||||
name
|
||||
luckyNumber
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
nil,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func failingQuery(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
@@ -3068,64 +3043,6 @@ query failingQuery {
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithVariables(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
id string,
|
||||
) (*queryWithVariablesResponse, error) {
|
||||
__input := __queryWithVariablesInput{
|
||||
Id: id,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithVariablesResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithVariables",
|
||||
`
|
||||
query queryWithVariables ($id: ID!) {
|
||||
user(id: $id) {
|
||||
id
|
||||
name
|
||||
luckyNumber
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithOmitempty(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
id string,
|
||||
) (*queryWithOmitemptyResponse, error) {
|
||||
__input := __queryWithOmitemptyInput{
|
||||
Id: id,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithOmitemptyResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithOmitempty",
|
||||
`
|
||||
query queryWithOmitempty ($id: ID) {
|
||||
user(id: $id) {
|
||||
id
|
||||
name
|
||||
luckyNumber
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithCustomMarshal(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
@@ -3155,35 +3072,6 @@ query queryWithCustomMarshal ($date: Date!) {
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithCustomMarshalSlice(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
dates []time.Time,
|
||||
) (*queryWithCustomMarshalSliceResponse, error) {
|
||||
__input := __queryWithCustomMarshalSliceInput{
|
||||
Dates: dates,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithCustomMarshalSliceResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithCustomMarshalSlice",
|
||||
`
|
||||
query queryWithCustomMarshalSlice ($dates: [Date!]!) {
|
||||
usersBornOnDates(dates: $dates) {
|
||||
id
|
||||
name
|
||||
birthdate
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithCustomMarshalOptional(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
@@ -3215,202 +3103,26 @@ query queryWithCustomMarshalOptional ($date: Date, $id: ID) {
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithInterfaceNoFragments(
|
||||
func queryWithCustomMarshalSlice(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
id string,
|
||||
) (*queryWithInterfaceNoFragmentsResponse, error) {
|
||||
__input := __queryWithInterfaceNoFragmentsInput{
|
||||
Id: id,
|
||||
dates []time.Time,
|
||||
) (*queryWithCustomMarshalSliceResponse, error) {
|
||||
__input := __queryWithCustomMarshalSliceInput{
|
||||
Dates: dates,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithInterfaceNoFragmentsResponse
|
||||
var retval queryWithCustomMarshalSliceResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithInterfaceNoFragments",
|
||||
"queryWithCustomMarshalSlice",
|
||||
`
|
||||
query queryWithInterfaceNoFragments ($id: ID!) {
|
||||
being(id: $id) {
|
||||
__typename
|
||||
query queryWithCustomMarshalSlice ($dates: [Date!]!) {
|
||||
usersBornOnDates(dates: $dates) {
|
||||
id
|
||||
name
|
||||
}
|
||||
me {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithInterfaceListField(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
ids []string,
|
||||
) (*queryWithInterfaceListFieldResponse, error) {
|
||||
__input := __queryWithInterfaceListFieldInput{
|
||||
Ids: ids,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithInterfaceListFieldResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithInterfaceListField",
|
||||
`
|
||||
query queryWithInterfaceListField ($ids: [ID!]!) {
|
||||
beings(ids: $ids) {
|
||||
__typename
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithInterfaceListPointerField(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
ids []string,
|
||||
) (*queryWithInterfaceListPointerFieldResponse, error) {
|
||||
__input := __queryWithInterfaceListPointerFieldInput{
|
||||
Ids: ids,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithInterfaceListPointerFieldResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithInterfaceListPointerField",
|
||||
`
|
||||
query queryWithInterfaceListPointerField ($ids: [ID!]!) {
|
||||
beings(ids: $ids) {
|
||||
__typename
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithFragments(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
ids []string,
|
||||
) (*queryWithFragmentsResponse, error) {
|
||||
__input := __queryWithFragmentsInput{
|
||||
Ids: ids,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithFragmentsResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithFragments",
|
||||
`
|
||||
query queryWithFragments ($ids: [ID!]!) {
|
||||
beings(ids: $ids) {
|
||||
__typename
|
||||
id
|
||||
... on Being {
|
||||
id
|
||||
name
|
||||
}
|
||||
... on Animal {
|
||||
id
|
||||
hair {
|
||||
hasHair
|
||||
}
|
||||
species
|
||||
owner {
|
||||
__typename
|
||||
id
|
||||
... on Being {
|
||||
name
|
||||
}
|
||||
... on User {
|
||||
luckyNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
... on Lucky {
|
||||
luckyNumber
|
||||
}
|
||||
... on User {
|
||||
hair {
|
||||
color
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithNamedFragments(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
ids []string,
|
||||
) (*queryWithNamedFragmentsResponse, error) {
|
||||
__input := __queryWithNamedFragmentsInput{
|
||||
Ids: ids,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithNamedFragmentsResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithNamedFragments",
|
||||
`
|
||||
query queryWithNamedFragments ($ids: [ID!]!) {
|
||||
beings(ids: $ids) {
|
||||
__typename
|
||||
id
|
||||
... AnimalFields
|
||||
... UserFields
|
||||
}
|
||||
}
|
||||
fragment AnimalFields on Animal {
|
||||
id
|
||||
hair {
|
||||
hasHair
|
||||
}
|
||||
owner {
|
||||
__typename
|
||||
id
|
||||
... UserFields
|
||||
... LuckyFields
|
||||
}
|
||||
}
|
||||
fragment UserFields on User {
|
||||
id
|
||||
... LuckyFields
|
||||
... MoreUserFields
|
||||
}
|
||||
fragment LuckyFields on Lucky {
|
||||
... MoreUserFields
|
||||
luckyNumber
|
||||
}
|
||||
fragment MoreUserFields on User {
|
||||
id
|
||||
hair {
|
||||
color
|
||||
birthdate
|
||||
}
|
||||
}
|
||||
`,
|
||||
@@ -3482,3 +3194,291 @@ fragment FriendsFields on User {
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithFragments(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
ids []string,
|
||||
) (*queryWithFragmentsResponse, error) {
|
||||
__input := __queryWithFragmentsInput{
|
||||
Ids: ids,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithFragmentsResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithFragments",
|
||||
`
|
||||
query queryWithFragments ($ids: [ID!]!) {
|
||||
beings(ids: $ids) {
|
||||
__typename
|
||||
id
|
||||
... on Being {
|
||||
id
|
||||
name
|
||||
}
|
||||
... on Animal {
|
||||
id
|
||||
hair {
|
||||
hasHair
|
||||
}
|
||||
species
|
||||
owner {
|
||||
__typename
|
||||
id
|
||||
... on Being {
|
||||
name
|
||||
}
|
||||
... on User {
|
||||
luckyNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
... on Lucky {
|
||||
luckyNumber
|
||||
}
|
||||
... on User {
|
||||
hair {
|
||||
color
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithInterfaceListField(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
ids []string,
|
||||
) (*queryWithInterfaceListFieldResponse, error) {
|
||||
__input := __queryWithInterfaceListFieldInput{
|
||||
Ids: ids,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithInterfaceListFieldResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithInterfaceListField",
|
||||
`
|
||||
query queryWithInterfaceListField ($ids: [ID!]!) {
|
||||
beings(ids: $ids) {
|
||||
__typename
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithInterfaceListPointerField(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
ids []string,
|
||||
) (*queryWithInterfaceListPointerFieldResponse, error) {
|
||||
__input := __queryWithInterfaceListPointerFieldInput{
|
||||
Ids: ids,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithInterfaceListPointerFieldResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithInterfaceListPointerField",
|
||||
`
|
||||
query queryWithInterfaceListPointerField ($ids: [ID!]!) {
|
||||
beings(ids: $ids) {
|
||||
__typename
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithInterfaceNoFragments(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
id string,
|
||||
) (*queryWithInterfaceNoFragmentsResponse, error) {
|
||||
__input := __queryWithInterfaceNoFragmentsInput{
|
||||
Id: id,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithInterfaceNoFragmentsResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithInterfaceNoFragments",
|
||||
`
|
||||
query queryWithInterfaceNoFragments ($id: ID!) {
|
||||
being(id: $id) {
|
||||
__typename
|
||||
id
|
||||
name
|
||||
}
|
||||
me {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithNamedFragments(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
ids []string,
|
||||
) (*queryWithNamedFragmentsResponse, error) {
|
||||
__input := __queryWithNamedFragmentsInput{
|
||||
Ids: ids,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithNamedFragmentsResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithNamedFragments",
|
||||
`
|
||||
query queryWithNamedFragments ($ids: [ID!]!) {
|
||||
beings(ids: $ids) {
|
||||
__typename
|
||||
id
|
||||
... AnimalFields
|
||||
... UserFields
|
||||
}
|
||||
}
|
||||
fragment AnimalFields on Animal {
|
||||
id
|
||||
hair {
|
||||
hasHair
|
||||
}
|
||||
owner {
|
||||
__typename
|
||||
id
|
||||
... UserFields
|
||||
... LuckyFields
|
||||
}
|
||||
}
|
||||
fragment UserFields on User {
|
||||
id
|
||||
... LuckyFields
|
||||
... MoreUserFields
|
||||
}
|
||||
fragment LuckyFields on Lucky {
|
||||
... MoreUserFields
|
||||
luckyNumber
|
||||
}
|
||||
fragment MoreUserFields on User {
|
||||
id
|
||||
hair {
|
||||
color
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithOmitempty(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
id string,
|
||||
) (*queryWithOmitemptyResponse, error) {
|
||||
__input := __queryWithOmitemptyInput{
|
||||
Id: id,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithOmitemptyResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithOmitempty",
|
||||
`
|
||||
query queryWithOmitempty ($id: ID) {
|
||||
user(id: $id) {
|
||||
id
|
||||
name
|
||||
luckyNumber
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func queryWithVariables(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
id string,
|
||||
) (*queryWithVariablesResponse, error) {
|
||||
__input := __queryWithVariablesInput{
|
||||
Id: id,
|
||||
}
|
||||
var err error
|
||||
|
||||
var retval queryWithVariablesResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"queryWithVariables",
|
||||
`
|
||||
query queryWithVariables ($id: ID!) {
|
||||
user(id: $id) {
|
||||
id
|
||||
name
|
||||
luckyNumber
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
&__input,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
func simpleQuery(
|
||||
ctx context.Context,
|
||||
client graphql.Client,
|
||||
) (*simpleQueryResponse, error) {
|
||||
var err error
|
||||
|
||||
var retval simpleQueryResponse
|
||||
err = client.MakeRequest(
|
||||
ctx,
|
||||
"simpleQuery",
|
||||
`
|
||||
query simpleQuery {
|
||||
me {
|
||||
id
|
||||
name
|
||||
luckyNumber
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
nil,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
|
||||
@@ -1560,6 +1560,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
|
||||
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
fc := &graphql.FieldContext{
|
||||
Object: "__Directive",
|
||||
Field: field,
|
||||
Args: nil,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
}
|
||||
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.IsRepeatable, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
if !graphql.HasFieldError(ctx, fc) {
|
||||
ec.Errorf(ctx, "must not be null")
|
||||
}
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(bool)
|
||||
fc.Result = res
|
||||
return ec.marshalNBoolean2bool(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
@@ -2858,6 +2893,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
|
||||
if out.Values[i] == graphql.Null {
|
||||
invalids++
|
||||
}
|
||||
case "isRepeatable":
|
||||
out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
|
||||
if out.Values[i] == graphql.Null {
|
||||
invalids++
|
||||
}
|
||||
default:
|
||||
panic("unknown field " + strconv.Quote(field.Name))
|
||||
}
|
||||
@@ -3109,6 +3149,7 @@ func (ec *executionContext) marshalNBeing2ᚕgithubᚗcomᚋKhanᚋgenqlientᚋi
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3169,6 +3210,12 @@ func (ec *executionContext) marshalNDate2ᚕstringᚄ(ctx context.Context, sel a
|
||||
ret[i] = ec.marshalNDate2string(ctx, sel, v[i])
|
||||
}
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3214,6 +3261,12 @@ func (ec *executionContext) marshalNID2ᚕstringᚄ(ctx context.Context, sel ast
|
||||
ret[i] = ec.marshalNID2string(ctx, sel, v[i])
|
||||
}
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3291,6 +3344,13 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋKhanᚋgenqlient
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3342,6 +3402,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3415,6 +3482,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3464,6 +3538,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3505,6 +3586,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3691,6 +3779,7 @@ func (ec *executionContext) marshalOUser2ᚕᚖgithubᚗcomᚋKhanᚋgenqlient
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3738,6 +3827,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3778,6 +3874,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3818,6 +3921,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -3865,6 +3975,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
|
||||
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
for _, e := range ret {
|
||||
if e == graphql.Null {
|
||||
return graphql.Null
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user