git-bug/vendor/github.com/vektah/gqlgen/codegen/templates/args.gotpl
2018-08-14 14:48:41 +02:00

31 lines
759 B
Plaintext

{{- if . }}args := map[string]interface{}{} {{end}}
{{- range $i, $arg := . }}
var arg{{$i}} {{$arg.Signature }}
if tmp, ok := field.Args[{{$arg.GQLName|quote}}]; ok {
var err error
{{$arg.Unmarshal (print "arg" $i) "tmp" }}
if err != nil {
ec.Error(ctx, err)
{{- if $arg.Object.Stream }}
return nil
{{- else }}
return graphql.Null
{{- end }}
}
} {{ if $arg.Default }} else {
var tmp interface{} = {{ $arg.Default | dump }}
var err error
{{$arg.Unmarshal (print "arg" $i) "tmp" }}
if err != nil {
ec.Error(ctx, err)
{{- if $arg.Object.Stream }}
return nil
{{- else }}
return graphql.Null
{{- end }}
}
}
{{end }}
args[{{$arg.GQLName|quote}}] = arg{{$i}}
{{- end -}}