more wiring for configurable context/client, theoretically should be good enough for khan use
This commit is contained in:
@@ -19,7 +19,17 @@ import (
|
||||
|
||||
{{range .Operations}}
|
||||
{{.Doc}}
|
||||
func {{.Name}}({{if $.Config.ContextType}}ctx {{$.Config.ContextType}}, {{end}}client *graphql.Client{{range .Args}}, {{.GoName}} {{.GoType}}{{end}}) (*{{.ResponseName}}, error) {
|
||||
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 -}}
|
||||
@@ -28,7 +38,12 @@ func {{.Name}}({{if $.Config.ContextType}}ctx {{$.Config.ContextType}}, {{end}}c
|
||||
}
|
||||
{{end}}
|
||||
var retval {{.ResponseName}}
|
||||
err := client.MakeRequest({{if $.Config.ContextType}}ctx{{else}}nil{{end}}, `{{.Body}}`, &retval, {{if .Args}}variables{{else}}nil{{end}})
|
||||
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}}
|
||||
|
||||
Reference in New Issue
Block a user