allow globbing, and extract queries from .go files
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
package test
|
||||
|
||||
// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/Khan/genqlient/graphql"
|
||||
)
|
||||
|
||||
type InterfaceNoFragmentsQueryResponse struct {
|
||||
Root InterfaceNoFragmentsQueryRootTopic `json:"root"`
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopic struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []InterfaceNoFragmentsQueryRootTopicChildrenContent `json:"-"`
|
||||
}
|
||||
|
||||
func (v *InterfaceNoFragmentsQueryRootTopic) UnmarshalJSON(b []byte) error {
|
||||
var firstPass struct {
|
||||
*InterfaceNoFragmentsQueryRootTopic
|
||||
Children json.RawMessage `json:"children"`
|
||||
}
|
||||
firstPass.InterfaceNoFragmentsQueryRootTopic = v
|
||||
|
||||
err := json.Unmarshal(b, &firstPass)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var tn struct {
|
||||
TypeName string `json:"__typename"`
|
||||
}
|
||||
err = json.Unmarshal(firstPass.Children, &tn)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch tn.TypeName {
|
||||
|
||||
case "Article":
|
||||
|
||||
v.Children = InterfaceNoFragmentsQueryRootTopicChildrenArticle{}
|
||||
err = json.Unmarshal(
|
||||
firstPass.Children, &v.Children)
|
||||
|
||||
case "Video":
|
||||
|
||||
v.Children = InterfaceNoFragmentsQueryRootTopicChildrenVideo{}
|
||||
err = json.Unmarshal(
|
||||
firstPass.Children, &v.Children)
|
||||
|
||||
case "Topic":
|
||||
|
||||
v.Children = InterfaceNoFragmentsQueryRootTopicChildrenTopic{}
|
||||
err = json.Unmarshal(
|
||||
firstPass.Children, &v.Children)
|
||||
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenArticle struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenContent interface {
|
||||
implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent()
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenTopic struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenVideo struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
}
|
||||
|
||||
func InterfaceNoFragmentsQuery(
|
||||
client graphql.Client,
|
||||
) (*InterfaceNoFragmentsQueryResponse, error) {
|
||||
var retval InterfaceNoFragmentsQueryResponse
|
||||
err := client.MakeRequest(
|
||||
nil,
|
||||
"InterfaceNoFragmentsQuery",
|
||||
`
|
||||
query InterfaceNoFragmentsQuery {
|
||||
root {
|
||||
id
|
||||
name
|
||||
children {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
&retval,
|
||||
nil,
|
||||
)
|
||||
return &retval, err
|
||||
}
|
||||
Reference in New Issue
Block a user