From 79cc9884b3d1b93c2a17b6a1e7d5cc2c7f5f7c0f Mon Sep 17 00:00:00 2001 From: Sascha Date: Tue, 16 Mar 2021 14:11:06 +0100 Subject: GraphQL: Resolve new EditComment mutation --- api/graphql/resolvers/mutation.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'api/graphql/resolvers/mutation.go') 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 { -- cgit From c6d15bd52b415b6fbc7a63e6072472402a1491d6 Mon Sep 17 00:00:00 2001 From: Sascha Date: Tue, 16 Mar 2021 15:16:24 +0100 Subject: Fix compilation errors --- api/graphql/resolvers/mutation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'api/graphql/resolvers/mutation.go') diff --git a/api/graphql/resolvers/mutation.go b/api/graphql/resolvers/mutation.go index 59e93cdd..60746b8b 100644 --- a/api/graphql/resolvers/mutation.go +++ b/api/graphql/resolvers/mutation.go @@ -100,7 +100,7 @@ func (r mutationResolver) EditComment(ctx context.Context, input models.EditComm return nil, err } - op, err := b.EditCommentRaw(author, time.Now().Unix(), input.Message, input.Files, nil) + op, err := b.EditCommentRaw(author, time.Now().Unix(), input.Target, input.Message, nil) if err != nil { return nil, err } -- cgit From cc7788ad44bbf6d3a272c15cd8858fb6dc3c1536 Mon Sep 17 00:00:00 2001 From: Sascha Date: Tue, 16 Mar 2021 17:29:56 +0100 Subject: GraphQL: Add target to EditCommentInput --- api/graphql/resolvers/mutation.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'api/graphql/resolvers/mutation.go') diff --git a/api/graphql/resolvers/mutation.go b/api/graphql/resolvers/mutation.go index 60746b8b..9cd936a6 100644 --- a/api/graphql/resolvers/mutation.go +++ b/api/graphql/resolvers/mutation.go @@ -5,6 +5,7 @@ import ( "time" "github.com/MichaelMure/git-bug/api/auth" + "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/api/graphql/graph" "github.com/MichaelMure/git-bug/api/graphql/models" "github.com/MichaelMure/git-bug/bug" @@ -100,7 +101,7 @@ func (r mutationResolver) EditComment(ctx context.Context, input models.EditComm return nil, err } - op, err := b.EditCommentRaw(author, time.Now().Unix(), input.Target, input.Message, nil) + op, err := b.EditCommentRaw(author, time.Now().Unix(), entity.Id(input.Target), input.Message, nil) if err != nil { return nil, err } -- cgit