aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers
diff options
context:
space:
mode:
Diffstat (limited to 'graphql/resolvers')
-rw-r--r--graphql/resolvers/bug.go27
-rw-r--r--graphql/resolvers/operations.go23
-rw-r--r--graphql/resolvers/root.go16
-rw-r--r--graphql/resolvers/timeline.go36
4 files changed, 88 insertions, 14 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
}
diff --git a/graphql/resolvers/operations.go b/graphql/resolvers/operations.go
index e964388b..4b78f0fb 100644
--- a/graphql/resolvers/operations.go
+++ b/graphql/resolvers/operations.go
@@ -7,60 +7,59 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/graphql/models"
- "github.com/MichaelMure/git-bug/operations"
)
type addCommentOperationResolver struct{}
-func (addCommentOperationResolver) Author(ctx context.Context, obj *operations.AddCommentOperation) (bug.Person, error) {
+func (addCommentOperationResolver) Author(ctx context.Context, obj *bug.AddCommentOperation) (bug.Person, error) {
return obj.Author, nil
}
-func (addCommentOperationResolver) Date(ctx context.Context, obj *operations.AddCommentOperation) (time.Time, error) {
+func (addCommentOperationResolver) Date(ctx context.Context, obj *bug.AddCommentOperation) (time.Time, error) {
return obj.Time(), nil
}
type createOperationResolver struct{}
-func (createOperationResolver) Author(ctx context.Context, obj *operations.CreateOperation) (bug.Person, error) {
+func (createOperationResolver) Author(ctx context.Context, obj *bug.CreateOperation) (bug.Person, error) {
return obj.Author, nil
}
-func (createOperationResolver) Date(ctx context.Context, obj *operations.CreateOperation) (time.Time, error) {
+func (createOperationResolver) Date(ctx context.Context, obj *bug.CreateOperation) (time.Time, error) {
return obj.Time(), nil
}
type labelChangeOperation struct{}
-func (labelChangeOperation) Author(ctx context.Context, obj *operations.LabelChangeOperation) (bug.Person, error) {
+func (labelChangeOperation) Author(ctx context.Context, obj *bug.LabelChangeOperation) (bug.Person, error) {
return obj.Author, nil
}
-func (labelChangeOperation) Date(ctx context.Context, obj *operations.LabelChangeOperation) (time.Time, error) {
+func (labelChangeOperation) Date(ctx context.Context, obj *bug.LabelChangeOperation) (time.Time, error) {
return obj.Time(), nil
}
type setStatusOperationResolver struct{}
-func (setStatusOperationResolver) Author(ctx context.Context, obj *operations.SetStatusOperation) (bug.Person, error) {
+func (setStatusOperationResolver) Author(ctx context.Context, obj *bug.SetStatusOperation) (bug.Person, error) {
return obj.Author, nil
}
-func (setStatusOperationResolver) Date(ctx context.Context, obj *operations.SetStatusOperation) (time.Time, error) {
+func (setStatusOperationResolver) Date(ctx context.Context, obj *bug.SetStatusOperation) (time.Time, error) {
return obj.Time(), nil
}
-func (setStatusOperationResolver) Status(ctx context.Context, obj *operations.SetStatusOperation) (models.Status, error) {
+func (setStatusOperationResolver) Status(ctx context.Context, obj *bug.SetStatusOperation) (models.Status, error) {
return convertStatus(obj.Status)
}
type setTitleOperationResolver struct{}
-func (setTitleOperationResolver) Author(ctx context.Context, obj *operations.SetTitleOperation) (bug.Person, error) {
+func (setTitleOperationResolver) Author(ctx context.Context, obj *bug.SetTitleOperation) (bug.Person, error) {
return obj.Author, nil
}
-func (setTitleOperationResolver) Date(ctx context.Context, obj *operations.SetTitleOperation) (time.Time, error) {
+func (setTitleOperationResolver) Date(ctx context.Context, obj *bug.SetTitleOperation) (time.Time, error) {
return obj.Time(), nil
}
diff --git a/graphql/resolvers/root.go b/graphql/resolvers/root.go
index ff181784..2322edc7 100644
--- a/graphql/resolvers/root.go
+++ b/graphql/resolvers/root.go
@@ -32,10 +32,22 @@ func (RootResolver) AddCommentOperation() graph.AddCommentOperationResolver {
return &addCommentOperationResolver{}
}
-func (r RootResolver) Bug() graph.BugResolver {
+func (RootResolver) Bug() graph.BugResolver {
return &bugResolver{}
}
+func (RootResolver) CommentHistoryStep() graph.CommentHistoryStepResolver {
+ return &commentHistoryStepResolver{}
+}
+
+func (RootResolver) CommentTimelineItem() graph.CommentTimelineItemResolver {
+ return &commentTimelineItemResolver{}
+}
+
+func (RootResolver) CreateTimelineItem() graph.CreateTimelineItemResolver {
+ return &createTimelineItemResolver{}
+}
+
func (RootResolver) CreateOperation() graph.CreateOperationResolver {
return &createOperationResolver{}
}
@@ -44,7 +56,7 @@ func (RootResolver) LabelChangeOperation() graph.LabelChangeOperationResolver {
return &labelChangeOperation{}
}
-func (r RootResolver) Repository() graph.RepositoryResolver {
+func (RootResolver) Repository() graph.RepositoryResolver {
return &repoResolver{}
}
diff --git a/graphql/resolvers/timeline.go b/graphql/resolvers/timeline.go
new file mode 100644
index 00000000..9b8262fe
--- /dev/null
+++ b/graphql/resolvers/timeline.go
@@ -0,0 +1,36 @@
+package resolvers
+
+import (
+ "context"
+ "time"
+
+ "github.com/MichaelMure/git-bug/bug"
+)
+
+type commentHistoryStepResolver struct{}
+
+func (commentHistoryStepResolver) Date(ctx context.Context, obj *bug.CommentHistoryStep) (time.Time, error) {
+ return obj.UnixTime.Time(), nil
+}
+
+type commentTimelineItemResolver struct{}
+
+func (commentTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.CommentTimelineItem) (time.Time, error) {
+ return obj.CreatedAt.Time(), nil
+}
+
+func (commentTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.CommentTimelineItem) (time.Time, error) {
+ return obj.LastEdit.Time(), nil
+}
+
+type createTimelineItemResolver struct{}
+
+func (createTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.CreateTimelineItem) (time.Time, error) {
+ return obj.CreatedAt.Time(), nil
+
+}
+
+func (createTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.CreateTimelineItem) (time.Time, error) {
+ return obj.LastEdit.Time(), nil
+
+}