more wiring for configurable context/client, theoretically should be good enough for khan use

This commit is contained in:
Ben Kraft
2021-03-22 19:17:06 -07:00
parent 59ca841a6b
commit dd85597577
18 changed files with 186 additions and 53 deletions
+17 -2
View File
@@ -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}}