50 lines
1.1 KiB
Cheetah
50 lines
1.1 KiB
Cheetah
package {{.Config.Package}}
|
|
|
|
// Code generated by github.com/Khan/genql, DO NOT EDIT.
|
|
|
|
import (
|
|
{{- if .Config.ContextType -}}
|
|
"{{.Config.ContextPackage}}"
|
|
{{end}}
|
|
{{- if .ImportJSON -}}
|
|
"encoding/json"
|
|
{{end}}
|
|
|
|
"github.com/Khan/genql/graphql"
|
|
)
|
|
|
|
{{/* TODO: type-assert that your ctx type implements context.Context */}}
|
|
|
|
{{.Types}}
|
|
|
|
{{range .Operations}}
|
|
{{.Doc}}
|
|
func {{.Name}}(
|
|
{{if $.Config.ContextType -}}
|
|
ctx {{$.Config.ContextType}},
|
|
{{end}}
|
|
{{- if not $.Config.ClientGetter -}}
|
|
client *graphql.Client,
|
|
{{end}}
|
|
{{- range .Args -}}
|
|
{{.GoName}} {{.GoType}},
|
|
{{end -}}
|
|
) (*{{.ResponseName}}, error) {
|
|
{{- if .Args -}}
|
|
variables := map[string]interface{}{
|
|
{{range .Args -}}
|
|
"{{.GraphQLName}}": {{.GoName}},
|
|
{{end}}
|
|
}
|
|
{{end}}
|
|
var retval {{.ResponseName}}
|
|
err := {{if $.Config.ClientGetter}}{{$.Config.ClientGetter}}{{else}}client{{end}}.MakeRequest(
|
|
{{if $.Config.ContextType}}ctx{{else}}nil{{end}},
|
|
`{{.Body}}`,
|
|
&retval,
|
|
{{if .Args}}variables{{else}}nil{{end}},
|
|
)
|
|
return &retval, err
|
|
}
|
|
{{end}}
|