From 8bf8a4408592e67b71d699b438114df7438d6c6f Mon Sep 17 00:00:00 2001 From: Matias Anaya Date: Wed, 6 Nov 2019 07:16:38 +1100 Subject: [PATCH] Add generated code --- codegen/testserver/generated.go | 46 +++++++-------------------------- codegen/testserver/resolver.go | 18 ------------- codegen/testserver/stub.go | 24 ----------------- 3 files changed, 10 insertions(+), 78 deletions(-) diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go index 297ecdf70fc..069155f7b5f 100644 --- a/codegen/testserver/generated.go +++ b/codegen/testserver/generated.go @@ -39,8 +39,6 @@ type Config struct { } type ResolverRoot interface { - Case1() Case1Resolver - Case2() Case2Resolver Errors() ErrorsResolver ForcedResolver() ForcedResolverResolver ModelMethods() ModelMethodsResolver @@ -323,12 +321,6 @@ type ComplexityRoot struct { } } -type Case1Resolver interface { - ExportedEmbeddedPointerExportedMethod(ctx context.Context, obj *Case1) (string, error) -} -type Case2Resolver interface { - UnexportedEmbeddedPointerExportedMethod(ctx context.Context, obj *Case2) (string, error) -} type ErrorsResolver interface { A(ctx context.Context, obj *Errors) (*Error, error) B(ctx context.Context, obj *Errors) (*Error, error) @@ -3115,7 +3107,7 @@ func (ec *executionContext) _Case1_exportedEmbeddedPointerExportedMethod(ctx con ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Case1().ExportedEmbeddedPointerExportedMethod(rctx, obj) + return obj.ExportedEmbeddedPointerExportedMethod(), nil }) if resTmp == nil { @@ -3149,7 +3141,7 @@ func (ec *executionContext) _Case2_unexportedEmbeddedPointerExportedMethod(ctx c ctx = ec.Tracer.StartFieldResolverExecution(ctx, rctx) resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Case2().UnexportedEmbeddedPointerExportedMethod(rctx, obj) + return obj.UnexportedEmbeddedPointerExportedMethod(), nil }) if resTmp == nil { @@ -9126,19 +9118,10 @@ func (ec *executionContext) _Case1(ctx context.Context, sel ast.SelectionSet, ob case "__typename": out.Values[i] = graphql.MarshalString("Case1") case "exportedEmbeddedPointerExportedMethod": - 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._Case1_exportedEmbeddedPointerExportedMethod(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) + out.Values[i] = ec._Case1_exportedEmbeddedPointerExportedMethod(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -9162,19 +9145,10 @@ func (ec *executionContext) _Case2(ctx context.Context, sel ast.SelectionSet, ob case "__typename": out.Values[i] = graphql.MarshalString("Case2") case "unexportedEmbeddedPointerExportedMethod": - 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._Case2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) + out.Values[i] = ec._Case2_unexportedEmbeddedPointerExportedMethod(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go index 80574f0a75b..ba7290f8db8 100644 --- a/codegen/testserver/resolver.go +++ b/codegen/testserver/resolver.go @@ -11,12 +11,6 @@ import ( type Resolver struct{} -func (r *Resolver) Case1() Case1Resolver { - return &case1Resolver{r} -} -func (r *Resolver) Case2() Case2Resolver { - return &case2Resolver{r} -} func (r *Resolver) Errors() ErrorsResolver { return &errorsResolver{r} } @@ -48,18 +42,6 @@ func (r *Resolver) User() UserResolver { return &userResolver{r} } -type case1Resolver struct{ *Resolver } - -func (r *case1Resolver) ExportedEmbeddedPointerExportedMethod(ctx context.Context, obj *Case1) (string, error) { - panic("not implemented") -} - -type case2Resolver struct{ *Resolver } - -func (r *case2Resolver) UnexportedEmbeddedPointerExportedMethod(ctx context.Context, obj *Case2) (string, error) { - panic("not implemented") -} - type errorsResolver struct{ *Resolver } func (r *errorsResolver) A(ctx context.Context, obj *Errors) (*Error, error) { diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go index 402487a79ed..b31ab8eec0b 100644 --- a/codegen/testserver/stub.go +++ b/codegen/testserver/stub.go @@ -10,12 +10,6 @@ import ( ) type Stub struct { - Case1Resolver struct { - ExportedEmbeddedPointerExportedMethod func(ctx context.Context, obj *Case1) (string, error) - } - Case2Resolver struct { - UnexportedEmbeddedPointerExportedMethod func(ctx context.Context, obj *Case2) (string, error) - } ErrorsResolver struct { A func(ctx context.Context, obj *Errors) (*Error, error) B func(ctx context.Context, obj *Errors) (*Error, error) @@ -103,12 +97,6 @@ type Stub struct { } } -func (r *Stub) Case1() Case1Resolver { - return &stubCase1{r} -} -func (r *Stub) Case2() Case2Resolver { - return &stubCase2{r} -} func (r *Stub) Errors() ErrorsResolver { return &stubErrors{r} } @@ -140,18 +128,6 @@ func (r *Stub) User() UserResolver { return &stubUser{r} } -type stubCase1 struct{ *Stub } - -func (r *stubCase1) ExportedEmbeddedPointerExportedMethod(ctx context.Context, obj *Case1) (string, error) { - return r.Case1Resolver.ExportedEmbeddedPointerExportedMethod(ctx, obj) -} - -type stubCase2 struct{ *Stub } - -func (r *stubCase2) UnexportedEmbeddedPointerExportedMethod(ctx context.Context, obj *Case2) (string, error) { - return r.Case2Resolver.UnexportedEmbeddedPointerExportedMethod(ctx, obj) -} - type stubErrors struct{ *Stub } func (r *stubErrors) A(ctx context.Context, obj *Errors) (*Error, error) {