Skip to content

Commit

Permalink
graphql/executor: remove the naked return
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Mar 4, 2020
1 parent 9ae6bc0 commit fb86f7b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions graphql/executor/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,22 @@ type extensions struct {
operationContextMutators []graphql.OperationContextMutator
}

func processExtensions(extensions []graphql.HandlerExtension) (e extensions) {
e.operationMiddleware = func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
return next(ctx)
}
e.responseMiddleware = func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response {
return next(ctx)
}
e.fieldMiddleware = func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
return next(ctx)
func processExtensions(exts []graphql.HandlerExtension) extensions {
e := extensions{
operationMiddleware: func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
return next(ctx)
},
responseMiddleware: func(ctx context.Context, next graphql.ResponseHandler) *graphql.Response {
return next(ctx)
},
fieldMiddleware: func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) {
return next(ctx)
},
}

// this loop goes backwards so the first extension is the outer most middleware and runs first.
for i := len(extensions) - 1; i >= 0; i-- {
p := extensions[i]
for i := len(exts) - 1; i >= 0; i-- {
p := exts[i]
if p, ok := p.(graphql.OperationInterceptor); ok {
previous := e.operationMiddleware
e.operationMiddleware = func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
Expand Down Expand Up @@ -92,7 +94,7 @@ func processExtensions(extensions []graphql.HandlerExtension) (e extensions) {
}
}

for _, p := range extensions {
for _, p := range exts {
if p, ok := p.(graphql.OperationParameterMutator); ok {
e.operationParameterMutators = append(e.operationParameterMutators, p)
}
Expand All @@ -102,7 +104,7 @@ func processExtensions(extensions []graphql.HandlerExtension) (e extensions) {
}
}

return
return e
}

type aroundOpFunc func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler
Expand Down

0 comments on commit fb86f7b

Please sign in to comment.