args.gotpl

 1{{ range $name, $args := .Args }}
 2func (ec *executionContext) {{ $name }}(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) {
 3	var err error
 4	args := map[string]interface{}{}
 5	{{- range $i, $arg := . }}
 6		var arg{{$i}} {{ $arg.TypeReference.GO | ref}}
 7		if tmp, ok := rawArgs[{{$arg.Name|quote}}]; ok {
 8			{{- if $arg.ImplDirectives }}
 9				directive0 := func(ctx context.Context) (interface{}, error) { return ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp) }
10				{{ template "implDirectives" $arg }}
11				tmp, err = directive{{$arg.ImplDirectives|len}}(ctx)
12				if err != nil {
13					return nil, err
14				}
15				if data, ok := tmp.({{ $arg.TypeReference.GO | ref }}) ; ok {
16					arg{{$i}} = data
17				} else {
18					return nil, fmt.Errorf(`unexpected type %T from directive, should be {{ $arg.TypeReference.GO }}`, tmp)
19				}
20			{{- else }}
21				arg{{$i}}, err = ec.{{ $arg.TypeReference.UnmarshalFunc }}(ctx, tmp)
22				if err != nil {
23					return nil, err
24				}
25			{{- end }}
26		}
27		args[{{$arg.Name|quote}}] = arg{{$i}}
28	{{- end }}
29	return args, nil
30}
31{{ end }}