diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-29 20:58:25 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-29 20:59:25 +0200 |
commit | 36ebbe0cf4078070c3a6710f2e1f781c03de3d1a (patch) | |
tree | 1c739320485c55d2b68e766d6f15609c86a0eefe /graphql/resolvers | |
parent | c46d01f8c10e6363b680fa6876e91bd8eaf3bb3e (diff) | |
download | git-bug-36ebbe0cf4078070c3a6710f2e1f781c03de3d1a.tar.gz |
graphql: expose the new Timeline
Diffstat (limited to 'graphql/resolvers')
-rw-r--r-- | graphql/resolvers/bug.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/graphql/resolvers/bug.go b/graphql/resolvers/bug.go index 858feb16..76eed55d 100644 --- a/graphql/resolvers/bug.go +++ b/graphql/resolvers/bug.go @@ -69,6 +69,33 @@ func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *str return connections.BugOperationCon(obj.Operations, edger, conMaker, input) } +func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.TimelineItemConnection, error) { + input := models.ConnectionInput{ + Before: before, + After: after, + First: first, + Last: last, + } + + edger := func(op bug.TimelineItem, offset int) connections.Edge { + return models.TimelineItemEdge{ + Node: op, + Cursor: connections.OffsetToCursor(offset), + } + } + + conMaker := func(edges []models.TimelineItemEdge, nodes []bug.TimelineItem, info models.PageInfo, totalCount int) (models.TimelineItemConnection, error) { + return models.TimelineItemConnection{ + Edges: edges, + Nodes: nodes, + PageInfo: info, + TotalCount: totalCount, + }, nil + } + + return connections.BugTimelineItemCon(obj.Timeline, edger, conMaker, input) +} + func (bugResolver) LastEdit(ctx context.Context, obj *bug.Snapshot) (time.Time, error) { return obj.LastEditTime(), nil } |