Skip to content

Commit

Permalink
Fix some issues with directive middlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathew Byrne committed Jul 26, 2018
1 parent 8416324 commit 73a8e3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion codegen/templates/data.go

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

17 changes: 8 additions & 9 deletions codegen/templates/generated.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,15 @@ type executionContext struct {
func (ec *executionContext) FieldMiddleware(ctx context.Context, next graphql.Resolver) interface{} {
{{- if .Directives }}
rctx := graphql.GetResolverContext(ctx)
if len(rctx.Field.Directives) != 0 {
for _, d := range rctx.Field.Directives {
switch d.Name {
{{- range $directive := .Directives }}
case "{{$directive.Name}}":
next = func(ctx context.Context) (interface{}, error) {
return ec.directives.{{$directive.GoName}}(ctx, next)
}
{{- end }}
for _, d := range rctx.Field.Definition.Directives {
switch d.Name {
{{- range $directive := .Directives }}
case "{{$directive.Name}}":
n := next
next = func(ctx context.Context) (interface{}, error) {
return ec.directives.{{$directive.GoName}}(ctx, n)
}
{{- end }}
}
}
{{- end }}
Expand Down

0 comments on commit 73a8e3a

Please sign in to comment.