From e7648996c8f278d061fe03a5c4d255049da765e5 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Thu, 23 Aug 2018 19:19:16 +0200 Subject: bug: add a new BugExerpt that hold a subset of a bug state for efficient sorting and retrieval --- graphql/graph/gen_graph.go | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'graphql/graph') diff --git a/graphql/graph/gen_graph.go b/graphql/graph/gen_graph.go index 06c65e84..798962e3 100644 --- a/graphql/graph/gen_graph.go +++ b/graphql/graph/gen_graph.go @@ -34,6 +34,7 @@ type Resolvers interface { Bug_status(ctx context.Context, obj *bug.Snapshot) (models.Status, error) + Bug_lastEdit(ctx context.Context, obj *bug.Snapshot) (time.Time, error) Bug_comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.CommentConnection, error) Bug_operations(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.OperationConnection, error) @@ -78,6 +79,7 @@ type AddCommentOperationResolver interface { type BugResolver interface { Status(ctx context.Context, obj *bug.Snapshot) (models.Status, error) + LastEdit(ctx context.Context, obj *bug.Snapshot) (time.Time, error) Comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.CommentConnection, error) Operations(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.OperationConnection, error) } @@ -124,6 +126,10 @@ func (s shortMapper) Bug_status(ctx context.Context, obj *bug.Snapshot) (models. return s.r.Bug().Status(ctx, obj) } +func (s shortMapper) Bug_lastEdit(ctx context.Context, obj *bug.Snapshot) (time.Time, error) { + return s.r.Bug().LastEdit(ctx, obj) +} + func (s shortMapper) Bug_comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.CommentConnection, error) { return s.r.Bug().Comments(ctx, obj, after, before, first, last) } @@ -494,14 +500,33 @@ func (ec *executionContext) _Bug_createdAt(ctx context.Context, field graphql.Co } func (ec *executionContext) _Bug_lastEdit(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { - rctx := graphql.GetResolverContext(ctx) - rctx.Object = "Bug" - rctx.Args = nil - rctx.Field = field - rctx.PushField(field.Alias) - defer rctx.Pop() - res := obj.LastEdit() - return graphql.MarshalTime(res) + ctx = graphql.WithResolverContext(ctx, &graphql.ResolverContext{ + Object: "Bug", + Args: nil, + Field: field, + }) + return graphql.Defer(func() (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + userErr := ec.Recover(ctx, r) + ec.Error(ctx, userErr) + ret = graphql.Null + } + }() + + resTmp, err := ec.ResolverMiddleware(ctx, func(ctx context.Context) (interface{}, error) { + return ec.resolvers.Bug_lastEdit(ctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(time.Time) + return graphql.MarshalTime(res) + }) } func (ec *executionContext) _Bug_comments(ctx context.Context, field graphql.CollectedField, obj *bug.Snapshot) graphql.Marshaler { -- cgit