diff options
author | Steve Moyer <smoyer1@selesy.com> | 2022-08-23 10:33:19 -0400 |
---|---|---|
committer | Steve Moyer <smoyer1@selesy.com> | 2022-08-23 10:33:19 -0400 |
commit | 7ba98bfadc2c4c7fd3e777074976b78d6171b163 (patch) | |
tree | 4865a84837a016e9a18b566046a2aa7a1992acc7 /api/graphql/resolvers | |
parent | 2c2c449187557384fd1e5b9333e808451be86041 (diff) | |
parent | 5a70e8b3a2e0fe3d1a1dcd4c24bb6bf64633cb7f (diff) | |
download | git-bug-7ba98bfadc2c4c7fd3e777074976b78d6171b163.tar.gz |
Merge branch 'master' into fix-850-ineffective-comment-edit
Diffstat (limited to 'api/graphql/resolvers')
-rw-r--r-- | api/graphql/resolvers/bug.go | 10 | ||||
-rw-r--r-- | api/graphql/resolvers/comment.go | 7 | ||||
-rw-r--r-- | api/graphql/resolvers/label.go | 25 | ||||
-rw-r--r-- | api/graphql/resolvers/mutation.go | 12 | ||||
-rw-r--r-- | api/graphql/resolvers/operations.go | 42 | ||||
-rw-r--r-- | api/graphql/resolvers/repo.go | 2 | ||||
-rw-r--r-- | api/graphql/resolvers/root.go | 4 | ||||
-rw-r--r-- | api/graphql/resolvers/timeline.go | 27 |
8 files changed, 30 insertions, 99 deletions
diff --git a/api/graphql/resolvers/bug.go b/api/graphql/resolvers/bug.go index 18c8d7f4..c40949fa 100644 --- a/api/graphql/resolvers/bug.go +++ b/api/graphql/resolvers/bug.go @@ -6,7 +6,7 @@ import ( "github.com/MichaelMure/git-bug/api/graphql/connections" "github.com/MichaelMure/git-bug/api/graphql/graph" "github.com/MichaelMure/git-bug/api/graphql/models" - "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/entities/bug" "github.com/MichaelMure/git-bug/entity/dag" ) @@ -14,18 +14,10 @@ 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 } -func (bugResolver) Status(_ context.Context, obj models.BugWrapper) (models.Status, error) { - return convertStatus(obj.Status()) -} - func (bugResolver) Comments(_ context.Context, obj models.BugWrapper, after *string, before *string, first *int, last *int) (*models.CommentConnection, error) { input := models.ConnectionInput{ Before: before, diff --git a/api/graphql/resolvers/comment.go b/api/graphql/resolvers/comment.go index 5206e8a7..7dddc3c8 100644 --- a/api/graphql/resolvers/comment.go +++ b/api/graphql/resolvers/comment.go @@ -5,13 +5,18 @@ import ( "github.com/MichaelMure/git-bug/api/graphql/graph" "github.com/MichaelMure/git-bug/api/graphql/models" - "github.com/MichaelMure/git-bug/bug" + "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/label.go b/api/graphql/resolvers/label.go index 83e95029..5210dcc9 100644 --- a/api/graphql/resolvers/label.go +++ b/api/graphql/resolvers/label.go @@ -2,12 +2,10 @@ package resolvers import ( "context" - "fmt" "image/color" "github.com/MichaelMure/git-bug/api/graphql/graph" - "github.com/MichaelMure/git-bug/api/graphql/models" - "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/entities/bug" ) var _ graph.LabelResolver = &labelResolver{} @@ -22,24 +20,3 @@ func (labelResolver) Color(ctx context.Context, obj *bug.Label) (*color.RGBA, er rgba := obj.Color().RGBA() return &rgba, nil } - -var _ graph.LabelChangeResultResolver = &labelChangeResultResolver{} - -type labelChangeResultResolver struct{} - -func (labelChangeResultResolver) Status(ctx context.Context, obj *bug.LabelChangeResult) (models.LabelChangeStatus, error) { - switch obj.Status { - case bug.LabelChangeAdded: - return models.LabelChangeStatusAdded, nil - case bug.LabelChangeRemoved: - return models.LabelChangeStatusRemoved, nil - case bug.LabelChangeDuplicateInOp: - return models.LabelChangeStatusDuplicateInOp, nil - case bug.LabelChangeAlreadySet: - return models.LabelChangeStatusAlreadyExist, nil - case bug.LabelChangeDoesntExist: - return models.LabelChangeStatusDoesntExist, nil - } - - return "", fmt.Errorf("unknown status") -} diff --git a/api/graphql/resolvers/mutation.go b/api/graphql/resolvers/mutation.go index aa99e93d..f6296d63 100644 --- a/api/graphql/resolvers/mutation.go +++ b/api/graphql/resolvers/mutation.go @@ -7,9 +7,8 @@ import ( "github.com/MichaelMure/git-bug/api/auth" "github.com/MichaelMure/git-bug/api/graphql/graph" "github.com/MichaelMure/git-bug/api/graphql/models" - "github.com/MichaelMure/git-bug/bug" "github.com/MichaelMure/git-bug/cache" - "github.com/MichaelMure/git-bug/entity" + "github.com/MichaelMure/git-bug/entities/bug" "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 0ede9f13..91194213 100644 --- a/api/graphql/resolvers/operations.go +++ b/api/graphql/resolvers/operations.go @@ -2,22 +2,17 @@ package resolvers import ( "context" - "fmt" "time" "github.com/MichaelMure/git-bug/api/graphql/graph" "github.com/MichaelMure/git-bug/api/graphql/models" - "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/entities/bug" ) 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 } @@ -31,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 } @@ -48,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 } @@ -69,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 } @@ -86,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 } @@ -99,18 +78,10 @@ func (setStatusOperationResolver) Date(_ context.Context, obj *bug.SetStatusOper return &t, nil } -func (setStatusOperationResolver) Status(_ context.Context, obj *bug.SetStatusOperation) (models.Status, error) { - return convertStatus(obj.Status) -} - 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 } @@ -119,14 +90,3 @@ func (setTitleOperationResolver) Date(_ context.Context, obj *bug.SetTitleOperat t := obj.Time() return &t, nil } - -func convertStatus(status bug.Status) (models.Status, error) { - switch status { - case bug.OpenStatus: - return models.StatusOpen, nil - case bug.ClosedStatus: - return models.StatusClosed, nil - } - - return "", fmt.Errorf("unknown status") -} diff --git a/api/graphql/resolvers/repo.go b/api/graphql/resolvers/repo.go index c2163cbe..3fcaada1 100644 --- a/api/graphql/resolvers/repo.go +++ b/api/graphql/resolvers/repo.go @@ -7,7 +7,7 @@ import ( "github.com/MichaelMure/git-bug/api/graphql/connections" "github.com/MichaelMure/git-bug/api/graphql/graph" "github.com/MichaelMure/git-bug/api/graphql/models" - "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/entities/bug" "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/query" ) diff --git a/api/graphql/resolvers/root.go b/api/graphql/resolvers/root.go index bb3bf5cf..44ae010e 100644 --- a/api/graphql/resolvers/root.go +++ b/api/graphql/resolvers/root.go @@ -101,7 +101,3 @@ func (RootResolver) SetStatusOperation() graph.SetStatusOperationResolver { func (RootResolver) SetTitleOperation() graph.SetTitleOperationResolver { return &setTitleOperationResolver{} } - -func (r RootResolver) LabelChangeResult() graph.LabelChangeResultResolver { - return &labelChangeResultResolver{} -} diff --git a/api/graphql/resolvers/timeline.go b/api/graphql/resolvers/timeline.go index 3223b3a0..2d691173 100644 --- a/api/graphql/resolvers/timeline.go +++ b/api/graphql/resolvers/timeline.go @@ -6,7 +6,8 @@ import ( "github.com/MichaelMure/git-bug/api/graphql/graph" "github.com/MichaelMure/git-bug/api/graphql/models" - "github.com/MichaelMure/git-bug/bug" + "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) { @@ -96,16 +97,12 @@ func (setStatusTimelineItem) Date(_ context.Context, obj *bug.SetStatusTimelineI 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 (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) { |