Skip to content

Commit

Permalink
Use arg function for generated Complexity method
Browse files Browse the repository at this point in the history
  • Loading branch information
edsrzf committed Sep 5, 2018
1 parent ebdbeba commit 31505ff
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 691 deletions.
2 changes: 1 addition & 1 deletion codegen/templates/data.go

Large diffs are not rendered by default.

14 changes: 4 additions & 10 deletions codegen/templates/generated.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,11 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
if e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}} == nil {
break
}
{{ if $field.Args }}args := map[string]interface{}{} {{end}}
{{ range $i, $arg := $field.Args }}
var arg{{$i}} {{$arg.Signature }}
if tmp, ok := rawArgs[{{$arg.GQLName|quote}}]; ok {
var err error
{{$arg.Unmarshal (print "arg" $i) "tmp" }}
if err != nil {
return 0, false
}
{{ if $field.Args }}
args, err := {{ $field.ArgsFunc }}(rawArgs)
if err != nil {
return 0, false
}
args[{{$arg.GQLName|quote}}] = arg{{$i}}
{{ end }}
return e.complexity.{{$object.GQLType|toCamel}}.{{$field.GQLName|toCamel}}(childComplexity{{if $field.Args}}, {{$field.ComplexityArgs}} {{end}}), true
{{ end }}
Expand Down
Loading

0 comments on commit 31505ff

Please sign in to comment.