Files
genqlient/generate/operation.go.tmpl
T

35 lines
943 B
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}}client *graphql.Client{{range .Args}}, {{.GoName}} {{.GoType}}{{end}}) (*{{.ResponseName}}, error) {
{{- if .Args -}}
variables := map[string]interface{}{
{{range .Args -}}
"{{.GraphQLName}}": {{.GoName}},
{{end}}
}
{{end}}
var retval {{.ResponseName}}
err := client.MakeRequest({{if $.Config.ContextType}}ctx{{else}}nil{{end}}, `{{.Body}}`, &retval, {{if .Args}}variables{{else}}nil{{end}})
return &retval, err
}
{{end}}