genql: quick hack at variables
This commit is contained in:
@@ -9,10 +9,17 @@ import (
|
||||
{{range .Operations}}
|
||||
type {{.ResponseName}} = {{.ResponseType}}
|
||||
|
||||
// {{.OperationDoc}}
|
||||
func {{.OperationName}}(ctx context.Context, client *graphql.Client) (*{{.ResponseName}}, error) {
|
||||
// {{.Doc}}
|
||||
func {{.Name}}(ctx context.Context, 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(ctx, `{{.Operation}}`, &retval)
|
||||
err := client.MakeRequest(ctx, `{{.Body}}`, &retval, {{if .Args}}variables{{else}}nil{{end}})
|
||||
return &retval, err
|
||||
}
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user