aboutsummaryrefslogtreecommitdiffstats
path: root/api/graphql/resolvers
diff options
context:
space:
mode:
Diffstat (limited to 'api/graphql/resolvers')
-rw-r--r--api/graphql/resolvers/bug.go4
-rw-r--r--api/graphql/resolvers/comment.go5
-rw-r--r--api/graphql/resolvers/mutation.go10
-rw-r--r--api/graphql/resolvers/operations.go24
-rw-r--r--api/graphql/resolvers/timeline.go21
5 files changed, 23 insertions, 41 deletions
diff --git a/api/graphql/resolvers/bug.go b/api/graphql/resolvers/bug.go
index d17a4469..c40949fa 100644
--- a/api/graphql/resolvers/bug.go
+++ b/api/graphql/resolvers/bug.go
@@ -14,10 +14,6 @@ var _ graph.BugResolver = &bugResolver{}
type bugResolver struct{}
-func (bugResolver) ID(_ context.Context, obj models.BugWrapper) (string, error) {
- return obj.Id().String(), nil
-}
-
func (bugResolver) HumanID(_ context.Context, obj models.BugWrapper) (string, error) {
return obj.Id().Human(), nil
}
diff --git a/api/graphql/resolvers/comment.go b/api/graphql/resolvers/comment.go
index 78548156..7dddc3c8 100644
--- a/api/graphql/resolvers/comment.go
+++ b/api/graphql/resolvers/comment.go
@@ -6,12 +6,17 @@ import (
"github.com/MichaelMure/git-bug/api/graphql/graph"
"github.com/MichaelMure/git-bug/api/graphql/models"
"github.com/MichaelMure/git-bug/entities/bug"
+ "github.com/MichaelMure/git-bug/entity"
)
var _ graph.CommentResolver = &commentResolver{}
type commentResolver struct{}
+func (c commentResolver) ID(ctx context.Context, obj *bug.Comment) (entity.CombinedId, error) {
+ return obj.CombinedId(), nil
+}
+
func (c commentResolver) Author(_ context.Context, obj *bug.Comment) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author), nil
}
diff --git a/api/graphql/resolvers/mutation.go b/api/graphql/resolvers/mutation.go
index 6ad81db4..f6296d63 100644
--- a/api/graphql/resolvers/mutation.go
+++ b/api/graphql/resolvers/mutation.go
@@ -9,7 +9,6 @@ import (
"github.com/MichaelMure/git-bug/api/graphql/models"
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entities/bug"
- "github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/util/text"
)
@@ -177,7 +176,12 @@ func (r mutationResolver) AddCommentAndReopen(ctx context.Context, input models.
}
func (r mutationResolver) EditComment(ctx context.Context, input models.EditCommentInput) (*models.EditCommentPayload, error) {
- repo, b, err := r.getBug(input.RepoRef, input.Prefix)
+ repo, err := r.getRepo(input.RepoRef)
+ if err != nil {
+ return nil, err
+ }
+
+ b, target, err := repo.ResolveComment(input.TargetPrefix)
if err != nil {
return nil, err
}
@@ -190,7 +194,7 @@ func (r mutationResolver) EditComment(ctx context.Context, input models.EditComm
op, err := b.EditCommentRaw(
author,
time.Now().Unix(),
- entity.Id(input.Target),
+ target,
text.Cleanup(input.Message),
nil,
)
diff --git a/api/graphql/resolvers/operations.go b/api/graphql/resolvers/operations.go
index 53c3c0bc..91194213 100644
--- a/api/graphql/resolvers/operations.go
+++ b/api/graphql/resolvers/operations.go
@@ -13,10 +13,6 @@ var _ graph.CreateOperationResolver = createOperationResolver{}
type createOperationResolver struct{}
-func (createOperationResolver) ID(_ context.Context, obj *bug.CreateOperation) (string, error) {
- return obj.Id().String(), nil
-}
-
func (createOperationResolver) Author(_ context.Context, obj *bug.CreateOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author()), nil
}
@@ -30,10 +26,6 @@ var _ graph.AddCommentOperationResolver = addCommentOperationResolver{}
type addCommentOperationResolver struct{}
-func (addCommentOperationResolver) ID(_ context.Context, obj *bug.AddCommentOperation) (string, error) {
- return obj.Id().String(), nil
-}
-
func (addCommentOperationResolver) Author(_ context.Context, obj *bug.AddCommentOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author()), nil
}
@@ -47,10 +39,6 @@ var _ graph.EditCommentOperationResolver = editCommentOperationResolver{}
type editCommentOperationResolver struct{}
-func (editCommentOperationResolver) ID(_ context.Context, obj *bug.EditCommentOperation) (string, error) {
- return obj.Id().String(), nil
-}
-
func (editCommentOperationResolver) Target(_ context.Context, obj *bug.EditCommentOperation) (string, error) {
return obj.Target.String(), nil
}
@@ -68,10 +56,6 @@ var _ graph.LabelChangeOperationResolver = labelChangeOperationResolver{}
type labelChangeOperationResolver struct{}
-func (labelChangeOperationResolver) ID(_ context.Context, obj *bug.LabelChangeOperation) (string, error) {
- return obj.Id().String(), nil
-}
-
func (labelChangeOperationResolver) Author(_ context.Context, obj *bug.LabelChangeOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author()), nil
}
@@ -85,10 +69,6 @@ var _ graph.SetStatusOperationResolver = setStatusOperationResolver{}
type setStatusOperationResolver struct{}
-func (setStatusOperationResolver) ID(_ context.Context, obj *bug.SetStatusOperation) (string, error) {
- return obj.Id().String(), nil
-}
-
func (setStatusOperationResolver) Author(_ context.Context, obj *bug.SetStatusOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author()), nil
}
@@ -102,10 +82,6 @@ var _ graph.SetTitleOperationResolver = setTitleOperationResolver{}
type setTitleOperationResolver struct{}
-func (setTitleOperationResolver) ID(_ context.Context, obj *bug.SetTitleOperation) (string, error) {
- return obj.Id().String(), nil
-}
-
func (setTitleOperationResolver) Author(_ context.Context, obj *bug.SetTitleOperation) (models.IdentityWrapper, error) {
return models.NewLoadedIdentity(obj.Author()), nil
}
diff --git a/api/graphql/resolvers/timeline.go b/api/graphql/resolvers/timeline.go
index 2481784e..2d691173 100644
--- a/api/graphql/resolvers/timeline.go
+++ b/api/graphql/resolvers/timeline.go
@@ -7,6 +7,7 @@ import (
"github.com/MichaelMure/git-bug/api/graphql/graph"
"github.com/MichaelMure/git-bug/api/graphql/models"
"github.com/MichaelMure/git-bug/entities/bug"
+ "github.com/MichaelMure/git-bug/entity"
)
var _ graph.CommentHistoryStepResolver = commentHistoryStepResolver{}
@@ -22,8 +23,8 @@ var _ graph.AddCommentTimelineItemResolver = addCommentTimelineItemResolver{}
type addCommentTimelineItemResolver struct{}
-func (addCommentTimelineItemResolver) ID(_ context.Context, obj *bug.AddCommentTimelineItem) (string, error) {
- return obj.Id().String(), nil
+func (addCommentTimelineItemResolver) ID(_ context.Context, obj *bug.AddCommentTimelineItem) (entity.CombinedId, error) {
+ return obj.CombinedId(), nil
}
func (addCommentTimelineItemResolver) Author(_ context.Context, obj *bug.AddCommentTimelineItem) (models.IdentityWrapper, error) {
@@ -44,8 +45,8 @@ var _ graph.CreateTimelineItemResolver = createTimelineItemResolver{}
type createTimelineItemResolver struct{}
-func (createTimelineItemResolver) ID(_ context.Context, obj *bug.CreateTimelineItem) (string, error) {
- return obj.Id().String(), nil
+func (createTimelineItemResolver) ID(_ context.Context, obj *bug.CreateTimelineItem) (entity.CombinedId, error) {
+ return obj.CombinedId(), nil
}
func (r createTimelineItemResolver) Author(_ context.Context, obj *bug.CreateTimelineItem) (models.IdentityWrapper, error) {
@@ -66,8 +67,8 @@ var _ graph.LabelChangeTimelineItemResolver = labelChangeTimelineItem{}
type labelChangeTimelineItem struct{}
-func (labelChangeTimelineItem) ID(_ context.Context, obj *bug.LabelChangeTimelineItem) (string, error) {
- return obj.Id().String(), nil
+func (labelChangeTimelineItem) ID(_ context.Context, obj *bug.LabelChangeTimelineItem) (entity.CombinedId, error) {
+ return obj.CombinedId(), nil
}
func (i labelChangeTimelineItem) Author(_ context.Context, obj *bug.LabelChangeTimelineItem) (models.IdentityWrapper, error) {
@@ -83,8 +84,8 @@ var _ graph.SetStatusTimelineItemResolver = setStatusTimelineItem{}
type setStatusTimelineItem struct{}
-func (setStatusTimelineItem) ID(_ context.Context, obj *bug.SetStatusTimelineItem) (string, error) {
- return obj.Id().String(), nil
+func (setStatusTimelineItem) ID(_ context.Context, obj *bug.SetStatusTimelineItem) (entity.CombinedId, error) {
+ return obj.CombinedId(), nil
}
func (i setStatusTimelineItem) Author(_ context.Context, obj *bug.SetStatusTimelineItem) (models.IdentityWrapper, error) {
@@ -100,8 +101,8 @@ var _ graph.SetTitleTimelineItemResolver = setTitleTimelineItem{}
type setTitleTimelineItem struct{}
-func (setTitleTimelineItem) ID(_ context.Context, obj *bug.SetTitleTimelineItem) (string, error) {
- return obj.Id().String(), nil
+func (setTitleTimelineItem) ID(_ context.Context, obj *bug.SetTitleTimelineItem) (entity.CombinedId, error) {
+ return obj.CombinedId(), nil
}
func (i setTitleTimelineItem) Author(_ context.Context, obj *bug.SetTitleTimelineItem) (models.IdentityWrapper, error) {