Skip to content

Commit

Permalink
remove DirectiveMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
vektah committed Nov 5, 2019
1 parent 40f0886 commit 848c627
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 26 deletions.
30 changes: 13 additions & 17 deletions graphql/context_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,32 @@ type OperationContext struct {
DisableIntrospection bool
Recover RecoverFunc
ResolverMiddleware FieldMiddleware
DirectiveMiddleware FieldMiddleware

Stats Stats
}

const operationCtx key = "operation_context"

func (rc *OperationContext) Validate(ctx context.Context) error {
if rc.Doc == nil {
return errors.New("field 'Doc' must be required")
}
if rc.RawQuery == "" {
return errors.New("field 'RawQuery' must be required")
func (c *OperationContext) Validate(ctx context.Context) error {
if c.Doc == nil {
return errors.New("field 'Doc'is required")
}
if rc.Variables == nil {
rc.Variables = make(map[string]interface{})
if c.RawQuery == "" {
return errors.New("field 'RawQuery' is required")
}
if rc.ResolverMiddleware == nil {
rc.ResolverMiddleware = DefaultResolverMiddleware
if c.Variables == nil {
c.Variables = make(map[string]interface{})
}
if rc.DirectiveMiddleware == nil {
rc.DirectiveMiddleware = DefaultDirectiveMiddleware
if c.ResolverMiddleware == nil {
return errors.New("field 'ResolverMiddleware' is required")
}
if rc.Recover == nil {
rc.Recover = DefaultRecover
if c.Recover == nil {
c.Recover = DefaultRecover
}

return nil
}

const operationCtx key = "operation_context"

// Deprecated: Please update all references to GetOperationContext instead
func GetRequestContext(ctx context.Context) *RequestContext {
return GetOperationContext(ctx)
Expand Down
8 changes: 0 additions & 8 deletions graphql/context_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import (
"context"
)

func DefaultResolverMiddleware(ctx context.Context, next Resolver) (res interface{}, err error) {
return next(ctx)
}

func DefaultDirectiveMiddleware(ctx context.Context, next Resolver) (res interface{}, err error) {
return next(ctx)
}

type key string

const resolverCtx key = "resolver_context"
Expand Down
1 change: 0 additions & 1 deletion graphql/handler/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func (e executor) CreateOperationContext(ctx context.Context, params *graphql.Ra
DisableIntrospection: true,
Recover: graphql.DefaultRecover,
ResolverMiddleware: e.fieldMiddleware,
DirectiveMiddleware: nil, //todo fixme
Stats: stats,
}

Expand Down

0 comments on commit 848c627

Please sign in to comment.