Skip to content

Commit

Permalink
codegen: fix resolvers execution order (#2267)
Browse files Browse the repository at this point in the history
* codegen: fix run order of resolver

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>

* fix: update code generate

* fix: update stub, root to generate resolver for input

* fix: added unit-test for input field order

* fix: added test for singlefile

Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
  • Loading branch information
giautm and a8m authored Jul 3, 2022
1 parent 8481457 commit c287a7b
Show file tree
Hide file tree
Showing 34 changed files with 1,018 additions and 54 deletions.
7 changes: 6 additions & 1 deletion _examples/config/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion _examples/fileupload/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion _examples/scalars/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion _examples/starwars/generated/exec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion _examples/todo/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion _examples/type-system-extension/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion codegen/input.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
{{- end}}
{{- end }}

for k, v := range asMap {
fieldsInOrder := [...]string{ {{ range .Fields }}{{ quote .Name }},{{ end }} }
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
continue
}
switch k {
{{- range $field := .Fields }}
case {{$field.Name|quote}}:
Expand Down
5 changes: 5 additions & 0 deletions codegen/root_.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ type ResolverRoot interface {
{{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver
{{ end }}
{{- end }}
{{- range $object := .Inputs -}}
{{ if $object.HasResolvers -}}
{{ucFirst $object.Name}}() {{ucFirst $object.Name}}Resolver
{{ end }}
{{- end }}
}

type DirectiveRoot struct {
Expand Down
88 changes: 87 additions & 1 deletion codegen/testserver/followschema/defaults.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions codegen/testserver/followschema/directive.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion codegen/testserver/followschema/enum.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c287a7b

Please sign in to comment.