From a58ecfe9be6b8aa9201a3221e2838ea7cf5b2f9f Mon Sep 17 00:00:00 2001 From: asamusev Date: Tue, 25 Jun 2019 09:49:40 +0300 Subject: [PATCH] add example and test field directive --- codegen/testserver/directive_test.go | 33 +- codegen/testserver/generated.go | 1085 +++++++++----------------- codegen/testserver/resolver.go | 3 + codegen/testserver/schema.graphql | 3 + codegen/testserver/stub.go | 4 + example/todo/generated.go | 321 +++----- example/todo/schema.graphql | 2 +- example/todo/todo_test.go | 27 +- 8 files changed, 566 insertions(+), 912 deletions(-) diff --git a/codegen/testserver/directive_test.go b/codegen/testserver/directive_test.go index 3d6badd0804..b3e73adf31f 100644 --- a/codegen/testserver/directive_test.go +++ b/codegen/testserver/directive_test.go @@ -39,6 +39,14 @@ func TestDirectives(t *testing.T) { return &s, nil } + resolvers.QueryResolver.DirectiveField = func(ctx context.Context) (*string, error) { + if s, ok := ctx.Value("request_id").(*string); ok { + return s, nil + } + + return nil, nil + } + srv := httptest.NewServer( handler.GraphQL( NewExecutableSchema(Config{ @@ -46,7 +54,7 @@ func TestDirectives(t *testing.T) { Directives: DirectiveRoot{ Length: func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message *string) (interface{}, error) { e := func(msg string) error { - if message == nil{ + if message == nil { return fmt.Errorf(msg) } return fmt.Errorf(*message) @@ -104,6 +112,9 @@ func TestDirectives(t *testing.T) { Custom: func(ctx context.Context, obj interface{}, next graphql.Resolver) (interface{}, error) { return next(ctx) }, + Logged: func(ctx context.Context, obj interface{}, next graphql.Resolver, id string) (interface{}, error) { + return next(context.WithValue(ctx, "request_id", &id)) + }, }, }), handler.ResolverMiddleware(func(ctx context.Context, next graphql.Resolver) (res interface{}, err error) { @@ -169,6 +180,26 @@ func TestDirectives(t *testing.T) { require.Equal(t, "Ok", *resp.DirectiveArg) }) }) + t.Run("field directives", func(t *testing.T) { + t.Run("add field directive", func(t *testing.T) { + var resp struct { + DirectiveField string + } + + c.MustPost(`query { directiveField@logged(id:"testes_id") }`, &resp) + + require.Equal(t, resp.DirectiveField, `testes_id`) + }) + t.Run("without field directive", func(t *testing.T) { + var resp struct { + DirectiveField *string + } + + c.MustPost(`query { directiveField }`, &resp) + + require.Nil(t, resp.DirectiveField) + }) + }) t.Run("input field directives", func(t *testing.T) { t.Run("when function errors on directives", func(t *testing.T) { var resp struct { diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 4969e4bfe7f..aac80a6b14e 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -56,6 +56,8 @@ type DirectiveRoot struct { Length func(ctx context.Context, obj interface{}, next graphql.Resolver, min int, max *int, message *string) (res interface{}, err error) + Logged func(ctx context.Context, obj interface{}, next graphql.Resolver, id string) (res interface{}, err error) + Range func(ctx context.Context, obj interface{}, next graphql.Resolver, min *int, max *int) (res interface{}, err error) } @@ -193,6 +195,7 @@ type ComplexityRoot struct { DefaultScalar func(childComplexity int, arg string) int DeprecatedField func(childComplexity int) int DirectiveArg func(childComplexity int, arg string) int + DirectiveField func(childComplexity int) int DirectiveInput func(childComplexity int, arg InputDirectives) int DirectiveInputNullable func(childComplexity int, arg *InputDirectives) int DirectiveInputType func(childComplexity int, arg InnerInput) int @@ -323,6 +326,7 @@ type QueryResolver interface { DirectiveInputNullable(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput(ctx context.Context, arg InputDirectives) (*string, error) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) + DirectiveField(ctx context.Context) (*string, error) InputSlice(ctx context.Context, arg []string) (bool, error) ShapeUnion(ctx context.Context) (ShapeUnion, error) Autobind(ctx context.Context) (*Autobind, error) @@ -765,6 +769,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.DirectiveArg(childComplexity, args["arg"].(string)), true + case "Query.directiveField": + if e.complexity.Query.DirectiveField == nil { + break + } + + return e.complexity.Query.DirectiveField(childComplexity), true + case "Query.directiveInput": if e.complexity.Query.DirectiveInput == nil { break @@ -1397,6 +1408,7 @@ type EmbeddedDefaultScalar { directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String directiveInputType(arg: InnerInput! @custom): String + directiveField: String inputSlice(arg: [String!]!): Boolean! shapeUnion: ShapeUnion! autobind: Autobind @@ -1502,6 +1514,8 @@ type EmbeddedPointer { directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION directive @custom on ARGUMENT_DEFINITION +directive @logged(id: UUID!) on FIELD +scalar UUID enum Status { OK @@ -1682,6 +1696,20 @@ func (ec *executionContext) dir_length_args(ctx context.Context, rawArgs map[str return args, nil } +func (ec *executionContext) dir_logged_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["id"]; ok { + arg0, err = ec.unmarshalNUUID2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + func (ec *executionContext) dir_range_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -2268,6 +2296,31 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region ************************** directives.gotpl ************************** +func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) interface{} { + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Directives { + switch d.Name { + case "logged": + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_logged_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.Logged(ctx, obj, n, args["id"].(string)) + } + } + } + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** @@ -2289,14 +2342,11 @@ func (ec *executionContext) _A_id(ctx context.Context, field graphql.CollectedFi } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2326,14 +2376,11 @@ func (ec *executionContext) _AIt_id(ctx context.Context, field graphql.Collected } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2363,14 +2410,11 @@ func (ec *executionContext) _AbIt_id(ctx context.Context, field graphql.Collecte } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2400,14 +2444,11 @@ func (ec *executionContext) _Autobind_int(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Int, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2437,14 +2478,11 @@ func (ec *executionContext) _Autobind_int32(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Int32, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2474,14 +2512,11 @@ func (ec *executionContext) _Autobind_int64(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Int64, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2511,14 +2546,11 @@ func (ec *executionContext) _Autobind_idStr(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IdStr, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2548,14 +2580,11 @@ func (ec *executionContext) _Autobind_idInt(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IdInt, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2585,14 +2614,11 @@ func (ec *executionContext) _B_id(ctx context.Context, field graphql.CollectedFi } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2622,14 +2648,11 @@ func (ec *executionContext) _Circle_radius(ctx context.Context, field graphql.Co } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Radius, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -2656,14 +2679,11 @@ func (ec *executionContext) _Circle_area(ctx context.Context, field graphql.Coll } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Area(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -2690,14 +2710,11 @@ func (ec *executionContext) _Content_Post_foo(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Foo, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -2724,14 +2741,11 @@ func (ec *executionContext) _Content_User_foo(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Foo, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -2758,14 +2772,11 @@ func (ec *executionContext) _EmbeddedDefaultScalar_value(ctx context.Context, fi } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Value, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -2792,14 +2803,11 @@ func (ec *executionContext) _EmbeddedPointer_ID(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -2826,14 +2834,11 @@ func (ec *executionContext) _EmbeddedPointer_Title(ctx context.Context, field gr } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Title, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -2860,14 +2865,11 @@ func (ec *executionContext) _Error_id(ctx context.Context, field graphql.Collect } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2897,14 +2899,11 @@ func (ec *executionContext) _Error_errorOnNonRequiredField(ctx context.Context, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ErrorOnNonRequiredField() }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -2931,14 +2930,11 @@ func (ec *executionContext) _Error_errorOnRequiredField(ctx context.Context, fie } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ErrorOnRequiredField() }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -2968,14 +2964,11 @@ func (ec *executionContext) _Error_nilOnRequiredField(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.NilOnRequiredField(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3005,14 +2998,11 @@ func (ec *executionContext) _Errors_a(ctx context.Context, field graphql.Collect } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().A(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3042,14 +3032,11 @@ func (ec *executionContext) _Errors_b(ctx context.Context, field graphql.Collect } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().B(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3079,14 +3066,11 @@ func (ec *executionContext) _Errors_c(ctx context.Context, field graphql.Collect } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().C(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3116,14 +3100,11 @@ func (ec *executionContext) _Errors_d(ctx context.Context, field graphql.Collect } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().D(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3153,14 +3134,11 @@ func (ec *executionContext) _Errors_e(ctx context.Context, field graphql.Collect } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Errors().E(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3190,14 +3168,11 @@ func (ec *executionContext) _ForcedResolver_field(ctx context.Context, field gra } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.ForcedResolver().Field(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -3224,14 +3199,11 @@ func (ec *executionContext) _InnerObject_id(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3261,14 +3233,11 @@ func (ec *executionContext) _InvalidIdentifier_id(ctx context.Context, field gra } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3298,14 +3267,11 @@ func (ec *executionContext) _It_id(ctx context.Context, field graphql.CollectedF } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3335,14 +3301,11 @@ func (ec *executionContext) _LoopA_b(ctx context.Context, field graphql.Collecte } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.B, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3372,14 +3335,11 @@ func (ec *executionContext) _LoopB_a(ctx context.Context, field graphql.Collecte } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.A, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3409,14 +3369,11 @@ func (ec *executionContext) _Map_id(ctx context.Context, field graphql.Collected } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3446,7 +3403,7 @@ func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children switch v := obj["a"].(type) { case *string: @@ -3459,10 +3416,7 @@ func (ec *executionContext) _MapStringInterfaceType_a(ctx context.Context, field return nil, fmt.Errorf("unexpected type %T for field %s", v, "a") } }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -3489,7 +3443,7 @@ func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children switch v := obj["b"].(type) { case *int: @@ -3502,10 +3456,7 @@ func (ec *executionContext) _MapStringInterfaceType_b(ctx context.Context, field return nil, fmt.Errorf("unexpected type %T for field %s", v, "b") } }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -3532,14 +3483,11 @@ func (ec *executionContext) _ModelMethods_resolverField(ctx context.Context, fie } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.ModelMethods().ResolverField(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3569,14 +3517,11 @@ func (ec *executionContext) _ModelMethods_noContext(ctx context.Context, field g } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.NoContext(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3606,14 +3551,11 @@ func (ec *executionContext) _ModelMethods_withContext(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.WithContext(ctx), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3643,14 +3585,11 @@ func (ec *executionContext) _OuterObject_inner(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Inner, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3680,14 +3619,11 @@ func (ec *executionContext) _OverlappingFields_oneFoo(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Foo, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3717,14 +3653,11 @@ func (ec *executionContext) _OverlappingFields_twoFoo(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Foo, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3754,14 +3687,11 @@ func (ec *executionContext) _OverlappingFields_oldFoo(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.OverlappingFields().OldFoo(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3791,14 +3721,11 @@ func (ec *executionContext) _OverlappingFields_newFoo(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.NewFoo, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3828,14 +3755,11 @@ func (ec *executionContext) _OverlappingFields_new_foo(ctx context.Context, fiel } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.NewFoo, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3865,14 +3789,11 @@ func (ec *executionContext) _Panics_fieldScalarMarshal(ctx context.Context, fiel } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Panics().FieldScalarMarshal(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3909,14 +3830,11 @@ func (ec *executionContext) _Panics_fieldFuncMarshal(ctx context.Context, field } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.FieldFuncMarshal(ctx, args["u"].([]MarshalPanic)), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3953,14 +3871,11 @@ func (ec *executionContext) _Panics_argUnmarshal(ctx context.Context, field grap } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Panics().ArgUnmarshal(rctx, obj, args["u"].([]MarshalPanic)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -3990,14 +3905,11 @@ func (ec *executionContext) _Primitive_value(ctx context.Context, field graphql. } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Primitive().Value(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4027,14 +3939,11 @@ func (ec *executionContext) _Primitive_squared(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Squared(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4064,14 +3973,11 @@ func (ec *executionContext) _PrimitiveString_value(ctx context.Context, field gr } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.PrimitiveString().Value(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4101,14 +4007,11 @@ func (ec *executionContext) _PrimitiveString_doubled(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Doubled(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4138,14 +4041,11 @@ func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.PrimitiveString().Len(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4175,14 +4075,11 @@ func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().InvalidIdentifier(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4209,14 +4106,11 @@ func (ec *executionContext) _Query_collision(ctx context.Context, field graphql. } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Collision(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4250,14 +4144,11 @@ func (ec *executionContext) _Query_mapInput(ctx context.Context, field graphql.C } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().MapInput(rctx, args["input"].(map[string]interface{})) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4291,14 +4182,11 @@ func (ec *executionContext) _Query_recursive(ctx context.Context, field graphql. } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Recursive(rctx, args["input"].(*RecursiveInputSlice)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4332,14 +4220,11 @@ func (ec *executionContext) _Query_nestedInputs(ctx context.Context, field graph } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().NestedInputs(rctx, args["input"].([][]*OuterInput)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4366,14 +4251,11 @@ func (ec *executionContext) _Query_nestedOutputs(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().NestedOutputs(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4400,14 +4282,11 @@ func (ec *executionContext) _Query_shapes(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Shapes(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4434,14 +4313,11 @@ func (ec *executionContext) _Query_modelMethods(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ModelMethods(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4475,14 +4351,11 @@ func (ec *executionContext) _Query_user(ctx context.Context, field graphql.Colle } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().User(rctx, args["id"].(int)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4519,14 +4392,11 @@ func (ec *executionContext) _Query_nullableArg(ctx context.Context, field graphq } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().NullableArg(rctx, args["arg"].(*int)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4560,14 +4430,11 @@ func (ec *executionContext) _Query_directiveArg(ctx context.Context, field graph } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveArg(rctx, args["arg"].(string)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4601,14 +4468,11 @@ func (ec *executionContext) _Query_directiveNullableArg(ctx context.Context, fie } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveNullableArg(rctx, args["arg"].(*int), args["arg2"].(*int)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4642,14 +4506,11 @@ func (ec *executionContext) _Query_directiveInputNullable(ctx context.Context, f } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveInputNullable(rctx, args["arg"].(*InputDirectives)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4683,14 +4544,11 @@ func (ec *executionContext) _Query_directiveInput(ctx context.Context, field gra } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveInput(rctx, args["arg"].(InputDirectives)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4724,14 +4582,42 @@ func (ec *executionContext) _Query_directiveInputType(ctx context.Context, field } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DirectiveInputType(rctx, args["arg"].(InnerInput)) }) - if err != nil { - ec.Error(ctx, err) + + if resTmp == nil { return graphql.Null } + res := resTmp.(*string) + rctx.Result = res + ctx = ec.Tracer.StartFieldChildExecution(ctx) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _Query_directiveField(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + ctx = ec.Tracer.StartFieldExecution(ctx, field) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + ec.Tracer.EndFieldExecution(ctx) + }() + rctx := &graphql.ResolverContext{ + Object: "Query", + Field: field, + Args: nil, + IsMethod: true, + } + ctx = graphql.WithResolverContext(ctx, rctx) + ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().DirectiveField(rctx) + }) + if resTmp == nil { return graphql.Null } @@ -4765,14 +4651,11 @@ func (ec *executionContext) _Query_inputSlice(ctx context.Context, field graphql } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().InputSlice(rctx, args["arg"].([]string)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4802,14 +4685,11 @@ func (ec *executionContext) _Query_shapeUnion(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ShapeUnion(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4839,14 +4719,11 @@ func (ec *executionContext) _Query_autobind(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Autobind(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4873,14 +4750,11 @@ func (ec *executionContext) _Query_deprecatedField(ctx context.Context, field gr } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DeprecatedField(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -4910,14 +4784,11 @@ func (ec *executionContext) _Query_overlapping(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Overlapping(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4951,14 +4822,11 @@ func (ec *executionContext) _Query_mapStringInterface(ctx context.Context, field } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().MapStringInterface(rctx, args["in"].(map[string]interface{})) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -4985,14 +4853,11 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ErrorBubble(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5019,14 +4884,11 @@ func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Errors(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5053,14 +4915,11 @@ func (ec *executionContext) _Query_valid(ctx context.Context, field graphql.Coll } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Valid(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5090,14 +4949,11 @@ func (ec *executionContext) _Query_panics(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Panics(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5124,14 +4980,11 @@ func (ec *executionContext) _Query_primitiveObject(ctx context.Context, field gr } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().PrimitiveObject(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5161,14 +5014,11 @@ func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, fi } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().PrimitiveStringObject(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5205,14 +5055,11 @@ func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field grap } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().DefaultScalar(rctx, args["arg"].(string)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5242,14 +5089,11 @@ func (ec *executionContext) _Query_slices(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Slices(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5276,14 +5120,11 @@ func (ec *executionContext) _Query_scalarSlice(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ScalarSlice(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5320,14 +5161,11 @@ func (ec *executionContext) _Query_fallback(ctx context.Context, field graphql.C } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().Fallback(rctx, args["arg"].(FallbackToStringEncoding)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5357,14 +5195,11 @@ func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().OptionalUnion(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5391,14 +5226,11 @@ func (ec *executionContext) _Query_validType(ctx context.Context, field graphql. } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().ValidType(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5425,14 +5257,11 @@ func (ec *executionContext) _Query_wrappedStruct(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().WrappedStruct(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5462,14 +5291,11 @@ func (ec *executionContext) _Query_wrappedScalar(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.Query().WrappedScalar(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5506,14 +5332,11 @@ func (ec *executionContext) _Query___type(ctx context.Context, field graphql.Col } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5540,14 +5363,11 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5574,14 +5394,11 @@ func (ec *executionContext) _Rectangle_length(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Length, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5608,14 +5425,11 @@ func (ec *executionContext) _Rectangle_width(ctx context.Context, field graphql. } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Width, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5642,14 +5456,11 @@ func (ec *executionContext) _Rectangle_area(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Area(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5676,14 +5487,11 @@ func (ec *executionContext) _Slices_test1(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Test1, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5710,14 +5518,11 @@ func (ec *executionContext) _Slices_test2(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Test2, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -5744,14 +5549,11 @@ func (ec *executionContext) _Slices_test3(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Test3, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5781,14 +5583,11 @@ func (ec *executionContext) _Slices_test4(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Test4, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5874,14 +5673,11 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5911,14 +5707,11 @@ func (ec *executionContext) _User_friends(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.User().Friends(rctx, obj) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5948,14 +5741,11 @@ func (ec *executionContext) _User_created(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Created, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -5985,14 +5775,11 @@ func (ec *executionContext) _User_updated(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Updated, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -6019,14 +5806,11 @@ func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DifferentCase, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6056,14 +5840,11 @@ func (ec *executionContext) _ValidType_different_case(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DifferentCaseOld, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6100,14 +5881,11 @@ func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, f } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ValidInputKeywords, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6144,14 +5922,11 @@ func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field grap } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ValidArgs, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6181,14 +5956,11 @@ func (ec *executionContext) _WrappedStruct_name(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6218,14 +5990,11 @@ func (ec *executionContext) _XXIt_id(ctx context.Context, field graphql.Collecte } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6255,14 +6024,11 @@ func (ec *executionContext) _XxIt_id(ctx context.Context, field graphql.Collecte } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6292,14 +6058,11 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6329,14 +6092,11 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -6363,14 +6123,11 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6400,14 +6157,11 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6437,14 +6191,11 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6474,14 +6225,11 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -6508,14 +6256,11 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6545,14 +6290,11 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -6579,14 +6321,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6616,14 +6355,11 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -6650,14 +6386,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6687,14 +6420,11 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6724,14 +6454,11 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6761,14 +6488,11 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -6795,14 +6519,11 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6832,14 +6553,11 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -6866,14 +6584,11 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6903,14 +6618,11 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -6937,14 +6649,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -6974,14 +6683,11 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -7011,14 +6717,11 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7045,14 +6748,11 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7079,14 +6779,11 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -7116,14 +6813,11 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -7153,14 +6847,11 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7187,14 +6878,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7228,14 +6916,11 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7262,14 +6947,11 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7296,14 +6978,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7337,14 +7016,11 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7371,14 +7047,11 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7405,14 +7078,11 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -7439,14 +7109,11 @@ func (ec *executionContext) _asdfIt_id(ctx context.Context, field graphql.Collec } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -7476,14 +7143,11 @@ func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.Collected } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -9013,6 +8677,17 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr res = ec._Query_directiveInputType(ctx, field) return res }) + case "directiveField": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_directiveField(ctx, field) + return res + }) case "inputSlice": field := field out.Concurrently(i, func() (res graphql.Marshaler) { @@ -10280,6 +9955,20 @@ func (ec *executionContext) marshalNTime2timeᚐTime(ctx context.Context, sel as return res } +func (ec *executionContext) unmarshalNUUID2string(ctx context.Context, v interface{}) (string, error) { + return graphql.UnmarshalString(v) +} + +func (ec *executionContext) marshalNUUID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !ec.HasError(graphql.GetResolverContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + } + return res +} + func (ec *executionContext) marshalNUser2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐUser(ctx context.Context, sel ast.SelectionSet, v User) graphql.Marshaler { return ec._User(ctx, sel, &v) } diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index e82ec74efae..ab8f7ec8bda 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -149,6 +149,9 @@ func (r *queryResolver) DirectiveInput(ctx context.Context, arg InputDirectives) func (r *queryResolver) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { panic("not implemented") } +func (r *queryResolver) DirectiveField(ctx context.Context) (*string, error) { + panic("not implemented") +} func (r *queryResolver) InputSlice(ctx context.Context, arg []string) (bool, error) { panic("not implemented") } diff --git a/codegen/testserver/schema.graphql b/codegen/testserver/schema.graphql index a230aefa374..e75b3bb2dc4 100644 --- a/codegen/testserver/schema.graphql +++ b/codegen/testserver/schema.graphql @@ -14,6 +14,7 @@ type Query { directiveInputNullable(arg: InputDirectives): String directiveInput(arg: InputDirectives!): String directiveInputType(arg: InnerInput! @custom): String + directiveField: String inputSlice(arg: [String!]!): Boolean! shapeUnion: ShapeUnion! autobind: Autobind @@ -119,6 +120,8 @@ type EmbeddedPointer { directive @length(min: Int!, max: Int, message: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION directive @range(min: Int = 0, max: Int) on ARGUMENT_DEFINITION directive @custom on ARGUMENT_DEFINITION +directive @logged(id: UUID!) on FIELD +scalar UUID enum Status { OK diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 2537853f499..7b801e2cbc4 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -53,6 +53,7 @@ type Stub struct { DirectiveInputNullable func(ctx context.Context, arg *InputDirectives) (*string, error) DirectiveInput func(ctx context.Context, arg InputDirectives) (*string, error) DirectiveInputType func(ctx context.Context, arg InnerInput) (*string, error) + DirectiveField func(ctx context.Context) (*string, error) InputSlice func(ctx context.Context, arg []string) (bool, error) ShapeUnion func(ctx context.Context) (ShapeUnion, error) Autobind func(ctx context.Context) (*Autobind, error) @@ -221,6 +222,9 @@ func (r *stubQuery) DirectiveInput(ctx context.Context, arg InputDirectives) (*s func (r *stubQuery) DirectiveInputType(ctx context.Context, arg InnerInput) (*string, error) { return r.QueryResolver.DirectiveInputType(ctx, arg) } +func (r *stubQuery) DirectiveField(ctx context.Context) (*string, error) { + return r.QueryResolver.DirectiveField(ctx) +} func (r *stubQuery) InputSlice(ctx context.Context, arg []string) (bool, error) { return r.QueryResolver.InputSlice(ctx, arg) } diff --git a/example/todo/generated.go b/example/todo/generated.go index 9037c667161..fd0177c3414 100644 --- a/example/todo/generated.go +++ b/example/todo/generated.go @@ -260,7 +260,7 @@ scalar Map "Prevents access to a field if the user doesnt have the matching role" directive @hasRole(role: Role!) on FIELD_DEFINITION -directive @user(id: ID!) on MUTATION | QUERY +directive @user(id: ID!) on MUTATION | QUERY | FIELD enum Role { ADMIN @@ -457,6 +457,31 @@ func (ec *executionContext) _mutationMiddleware(ctx context.Context, obj *ast.Op } +func (ec *executionContext) _fieldMiddleware(ctx context.Context, obj interface{}, next graphql.Resolver) interface{} { + rctx := graphql.GetResolverContext(ctx) + for _, d := range rctx.Field.Directives { + switch d.Name { + case "user": + rawArgs := d.ArgumentMap(ec.Variables) + args, err := ec.dir_user_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return nil + } + n := next + next = func(ctx context.Context) (interface{}, error) { + return ec.directives.User(ctx, obj, n, args["id"].(int)) + } + } + } + res, err := ec.ResolverMiddleware(ctx, next) + if err != nil { + ec.Error(ctx, err) + return nil + } + return res +} + // endregion ************************** directives.gotpl ************************** // region **************************** field.gotpl ***************************** @@ -485,14 +510,11 @@ func (ec *executionContext) _MyMutation_createTodo(ctx context.Context, field gr } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyMutation().CreateTodo(rctx, args["todo"].(TodoInput)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -529,14 +551,11 @@ func (ec *executionContext) _MyMutation_updateTodo(ctx context.Context, field gr } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyMutation().UpdateTodo(rctx, args["id"].(int), args["changes"].(map[string]interface{})) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -570,14 +589,11 @@ func (ec *executionContext) _MyQuery_todo(ctx context.Context, field graphql.Col } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyQuery().Todo(rctx, args["id"].(int)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -604,14 +620,11 @@ func (ec *executionContext) _MyQuery_lastTodo(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyQuery().LastTodo(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -638,14 +651,11 @@ func (ec *executionContext) _MyQuery_todos(ctx context.Context, field graphql.Co } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.resolvers.MyQuery().Todos(rctx) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -682,14 +692,11 @@ func (ec *executionContext) _MyQuery___type(ctx context.Context, field graphql.C } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectType(args["name"].(string)) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -716,14 +723,11 @@ func (ec *executionContext) _MyQuery___schema(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return ec.introspectSchema() }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -750,14 +754,11 @@ func (ec *executionContext) _Todo_id(ctx context.Context, field graphql.Collecte } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.ID, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -787,14 +788,11 @@ func (ec *executionContext) _Todo_text(ctx context.Context, field graphql.Collec } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Text, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -824,7 +822,7 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Done, nil @@ -845,10 +843,7 @@ func (ec *executionContext) _Todo_done(ctx context.Context, field graphql.Collec } return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -878,14 +873,11 @@ func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -915,14 +907,11 @@ func (ec *executionContext) ___Directive_description(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -949,14 +938,11 @@ func (ec *executionContext) ___Directive_locations(ctx context.Context, field gr } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Locations, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -986,14 +972,11 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1023,14 +1006,11 @@ func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1060,14 +1040,11 @@ func (ec *executionContext) ___EnumValue_description(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1094,14 +1071,11 @@ func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1131,14 +1105,11 @@ func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1165,14 +1136,11 @@ func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1202,14 +1170,11 @@ func (ec *executionContext) ___Field_description(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1236,14 +1201,11 @@ func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Args, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1273,14 +1235,11 @@ func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.Col } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1310,14 +1269,11 @@ func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field gra } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.IsDeprecated(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1347,14 +1303,11 @@ func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, fiel } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DeprecationReason(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1381,14 +1334,11 @@ func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1418,14 +1368,11 @@ func (ec *executionContext) ___InputValue_description(ctx context.Context, field } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1452,14 +1399,11 @@ func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Type, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1489,14 +1433,11 @@ func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, fiel } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.DefaultValue, nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1523,14 +1464,11 @@ func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.C } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Types(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1560,14 +1498,11 @@ func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.QueryType(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1597,14 +1532,11 @@ func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field gr } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.MutationType(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1631,14 +1563,11 @@ func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, fiel } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.SubscriptionType(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1665,14 +1594,11 @@ func (ec *executionContext) ___Schema_directives(ctx context.Context, field grap } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Directives(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1702,14 +1628,11 @@ func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.Coll } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Kind(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { if !ec.HasError(rctx) { ec.Errorf(ctx, "must not be null") @@ -1739,14 +1662,11 @@ func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.Coll } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Name(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1773,14 +1693,11 @@ func (ec *executionContext) ___Type_description(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Description(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1814,14 +1731,11 @@ func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.Co } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Fields(args["includeDeprecated"].(bool)), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1848,14 +1762,11 @@ func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphq } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.Interfaces(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1882,14 +1793,11 @@ func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field gra } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.PossibleTypes(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1923,14 +1831,11 @@ func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphq } rctx.Args = args ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.EnumValues(args["includeDeprecated"].(bool)), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1957,14 +1862,11 @@ func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graph } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.InputFields(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } @@ -1991,14 +1893,11 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co } ctx = graphql.WithResolverContext(ctx, rctx) ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children return obj.OfType(), nil }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } + if resTmp == nil { return graphql.Null } diff --git a/example/todo/schema.graphql b/example/todo/schema.graphql index 41a4bd1aeee..8be7b292101 100644 --- a/example/todo/schema.graphql +++ b/example/todo/schema.graphql @@ -32,7 +32,7 @@ scalar Map "Prevents access to a field if the user doesnt have the matching role" directive @hasRole(role: Role!) on FIELD_DEFINITION -directive @user(id: ID!) on MUTATION | QUERY +directive @user(id: ID!) on MUTATION | QUERY | FIELD enum Role { ADMIN diff --git a/example/todo/todo_test.go b/example/todo/todo_test.go index 7a06c7977be..5bd188625b5 100644 --- a/example/todo/todo_test.go +++ b/example/todo/todo_test.go @@ -55,7 +55,7 @@ func TestTodo(t *testing.T) { require.Equal(t, "Very important", resp.UpdateTodo.Text) }) - t.Run("update the todo status by user id", func(t *testing.T) { + t.Run("update the todo status by user id in mutation", func(t *testing.T) { var resp struct { UpdateTodo struct { Text string @@ -67,6 +67,31 @@ func TestTodo(t *testing.T) { require.Equal(t, "Somebody else's todo", resp.UpdateTodo.Text) }) + t.Run("update the todo status by user id in field", func(t *testing.T) { + var resp struct { + UpdateTodo struct { + Text string + Done bool + } + } + c.MustPost(`mutation { updateTodo(id: 3, changes:{done:true})@user(id:2) { text, done } }`, &resp) + + require.Equal(t, "Somebody else's todo", resp.UpdateTodo.Text) + }) + + t.Run("failed update the todo status by user id in field", func(t *testing.T) { + var resp struct { + UpdateTodo *struct { + Text string + Done bool + } + } + err := c.Post(`mutation { updateTodo(id: 3, changes:{done:true}) { text, done } }`, &resp) + require.EqualError(t, err, "[{\"message\":\"you dont own that\",\"path\":[\"updateTodo\",\"done\"]}]") + + require.Nil(t, resp.UpdateTodo) + }) + t.Run("select with alias", func(t *testing.T) { var resp struct { A struct{ Text string }