aboutsummaryrefslogtreecommitdiffstats
path: root/api/graphql/resolvers/timeline.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-06-21 22:12:04 +0200
committerMichael Muré <batolettre@gmail.com>2020-06-27 23:03:05 +0200
commit2ab6381a94d55fa22b80acdbb18849d6b24951f9 (patch)
tree99942b000955623ea7466b9fa4cc7dab37645df6 /api/graphql/resolvers/timeline.go
parent5f72b04ef8e84b1c367ca6874519706318e351f5 (diff)
downloadgit-bug-2ab6381a94d55fa22b80acdbb18849d6b24951f9.tar.gz
Reorganize the webUI and API code
Included in the changes: - create a new /api root package to hold all API code, migrate /graphql in there - git API handlers all use the cache instead of the repo directly - git API handlers are now tested - git API handlers now require a "repo" mux parameter - lots of untangling of API/handlers/middleware - less code in commands/webui.go
Diffstat (limited to 'api/graphql/resolvers/timeline.go')
-rw-r--r--api/graphql/resolvers/timeline.go118
1 files changed, 118 insertions, 0 deletions
diff --git a/api/graphql/resolvers/timeline.go b/api/graphql/resolvers/timeline.go
new file mode 100644
index 00000000..3223b3a0
--- /dev/null
+++ b/api/graphql/resolvers/timeline.go
@@ -0,0 +1,118 @@
+package resolvers
+
+import (
+ "context"
+ "time"
+
+ "github.com/MichaelMure/git-bug/api/graphql/graph"
+ "github.com/MichaelMure/git-bug/api/graphql/models"
+ "github.com/MichaelMure/git-bug/bug"
+)
+
+var _ graph.CommentHistoryStepResolver = commentHistoryStepResolver{}
+
+type commentHistoryStepResolver struct{}
+
+func (commentHistoryStepResolver) Date(_ context.Context, obj *bug.CommentHistoryStep) (*time.Time, error) {
+ t := obj.UnixTime.Time()
+ return &t, nil
+}
+
+var _ graph.AddCommentTimelineItemResolver = addCommentTimelineItemResolver{}
+
+type addCommentTimelineItemResolver struct{}
+
+func (addCommentTimelineItemResolver) ID(_ context.Context, obj *bug.AddCommentTimelineItem) (string, error) {
+ return obj.Id().String(), nil
+}
+
+func (addCommentTimelineItemResolver) Author(_ context.Context, obj *bug.AddCommentTimelineItem) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (addCommentTimelineItemResolver) CreatedAt(_ context.Context, obj *bug.AddCommentTimelineItem) (*time.Time, error) {
+ t := obj.CreatedAt.Time()
+ return &t, nil
+}
+
+func (addCommentTimelineItemResolver) LastEdit(_ context.Context, obj *bug.AddCommentTimelineItem) (*time.Time, error) {
+ t := obj.LastEdit.Time()
+ return &t, nil
+}
+
+var _ graph.CreateTimelineItemResolver = createTimelineItemResolver{}
+
+type createTimelineItemResolver struct{}
+
+func (createTimelineItemResolver) ID(_ context.Context, obj *bug.CreateTimelineItem) (string, error) {
+ return obj.Id().String(), nil
+}
+
+func (r createTimelineItemResolver) Author(_ context.Context, obj *bug.CreateTimelineItem) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (createTimelineItemResolver) CreatedAt(_ context.Context, obj *bug.CreateTimelineItem) (*time.Time, error) {
+ t := obj.CreatedAt.Time()
+ return &t, nil
+}
+
+func (createTimelineItemResolver) LastEdit(_ context.Context, obj *bug.CreateTimelineItem) (*time.Time, error) {
+ t := obj.LastEdit.Time()
+ return &t, nil
+}
+
+var _ graph.LabelChangeTimelineItemResolver = labelChangeTimelineItem{}
+
+type labelChangeTimelineItem struct{}
+
+func (labelChangeTimelineItem) ID(_ context.Context, obj *bug.LabelChangeTimelineItem) (string, error) {
+ return obj.Id().String(), nil
+}
+
+func (i labelChangeTimelineItem) Author(_ context.Context, obj *bug.LabelChangeTimelineItem) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (labelChangeTimelineItem) Date(_ context.Context, obj *bug.LabelChangeTimelineItem) (*time.Time, error) {
+ t := obj.UnixTime.Time()
+ return &t, nil
+}
+
+var _ graph.SetStatusTimelineItemResolver = setStatusTimelineItem{}
+
+type setStatusTimelineItem struct{}
+
+func (setStatusTimelineItem) ID(_ context.Context, obj *bug.SetStatusTimelineItem) (string, error) {
+ return obj.Id().String(), nil
+}
+
+func (i setStatusTimelineItem) Author(_ context.Context, obj *bug.SetStatusTimelineItem) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (setStatusTimelineItem) Date(_ context.Context, obj *bug.SetStatusTimelineItem) (*time.Time, error) {
+ t := obj.UnixTime.Time()
+ return &t, nil
+}
+
+func (setStatusTimelineItem) Status(_ context.Context, obj *bug.SetStatusTimelineItem) (models.Status, error) {
+ return convertStatus(obj.Status)
+}
+
+var _ graph.SetTitleTimelineItemResolver = setTitleTimelineItem{}
+
+type setTitleTimelineItem struct{}
+
+func (setTitleTimelineItem) ID(_ context.Context, obj *bug.SetTitleTimelineItem) (string, error) {
+ return obj.Id().String(), nil
+}
+
+func (i setTitleTimelineItem) Author(_ context.Context, obj *bug.SetTitleTimelineItem) (models.IdentityWrapper, error) {
+ return models.NewLoadedIdentity(obj.Author), nil
+}
+
+func (setTitleTimelineItem) Date(_ context.Context, obj *bug.SetTitleTimelineItem) (*time.Time, error) {
+ t := obj.UnixTime.Time()
+ return &t, nil
+}