Skip to content

Commit

Permalink
capture args in map
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Scarr committed Apr 5, 2018
1 parent e266fab commit 28d0c81
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions codegen/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ func (f *Field) CallArgs() string {
}
}

for i := range f.Args {
args = append(args, "arg"+strconv.Itoa(i))
for _, arg := range f.Args {
args = append(args, "args["+strconv.Quote(arg.GQLName)+"].("+arg.Signature()+")")
}

return strings.Join(args, ", ")
Expand Down
2 changes: 2 additions & 0 deletions codegen/templates/args.gotpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if . }}args := map[string]interface{}{} {{end}}
{{- range $i, $arg := . }}
var arg{{$i}} {{$arg.Signature }}
if tmp, ok := field.Args[{{$arg.GQLName|quote}}]; ok {
Expand Down Expand Up @@ -25,4 +26,5 @@
}
}
{{end }}
args[{{$arg.GQLName|quote}}] = arg{{$i}}
{{- end -}}

0 comments on commit 28d0c81

Please sign in to comment.