aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorSascha <GlancingMind@outlook.com>2021-03-16 14:11:06 +0100
committerSascha <GlancingMind@outlook.com>2021-03-19 17:49:31 +0100
commit79cc9884b3d1b93c2a17b6a1e7d5cc2c7f5f7c0f (patch)
treea611199fe3fdc8589fafe50c19cd18c813813615 /api
parent0dcb48d03aae413d77c7321f461502fa54abe05f (diff)
downloadgit-bug-79cc9884b3d1b93c2a17b6a1e7d5cc2c7f5f7c0f.tar.gz
GraphQL: Resolve new EditComment mutation
Diffstat (limited to 'api')
-rw-r--r--api/graphql/resolvers/mutation.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/api/graphql/resolvers/mutation.go b/api/graphql/resolvers/mutation.go
index 642a4fb9..59e93cdd 100644
--- a/api/graphql/resolvers/mutation.go
+++ b/api/graphql/resolvers/mutation.go
@@ -89,6 +89,34 @@ func (r mutationResolver) AddComment(ctx context.Context, input models.AddCommen
}, nil
}
+func (r mutationResolver) EditComment(ctx context.Context, input models.EditCommentInput) (*models.EditCommentPayload, error) {
+ repo, b, err := r.getBug(input.RepoRef, input.Prefix)
+ if err != nil {
+ return nil, err
+ }
+
+ author, err := auth.UserFromCtx(ctx, repo)
+ if err != nil {
+ return nil, err
+ }
+
+ op, err := b.EditCommentRaw(author, time.Now().Unix(), input.Message, input.Files, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ err = b.Commit()
+ if err != nil {
+ return nil, err
+ }
+
+ return &models.EditCommentPayload{
+ ClientMutationID: input.ClientMutationID,
+ Bug: models.NewLoadedBug(b.Snapshot()),
+ Operation: op,
+ }, nil
+}
+
func (r mutationResolver) ChangeLabels(ctx context.Context, input *models.ChangeLabelInput) (*models.ChangeLabelPayload, error) {
repo, b, err := r.getBug(input.RepoRef, input.Prefix)
if err != nil {