aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers
diff options
context:
space:
mode:
Diffstat (limited to 'graphql/resolvers')
-rw-r--r--graphql/resolvers/bug.go35
-rw-r--r--graphql/resolvers/mutation.go82
-rw-r--r--graphql/resolvers/operations.go30
-rw-r--r--graphql/resolvers/repo.go30
-rw-r--r--graphql/resolvers/timeline.go40
5 files changed, 107 insertions, 110 deletions
diff --git a/graphql/resolvers/bug.go b/graphql/resolvers/bug.go
index ef35853c..2ad2310b 100644
--- a/graphql/resolvers/bug.go
+++ b/graphql/resolvers/bug.go
@@ -19,7 +19,7 @@ func (bugResolver) Status(ctx context.Context, obj *bug.Snapshot) (models.Status
return convertStatus(obj.Status)
}
-func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.CommentConnection, error) {
+func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.CommentConnection, error) {
input := models.ConnectionInput{
Before: before,
After: after,
@@ -34,8 +34,8 @@ func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, after *strin
}
}
- conMaker := func(edges []models.CommentEdge, nodes []bug.Comment, info models.PageInfo, totalCount int) (models.CommentConnection, error) {
- return models.CommentConnection{
+ conMaker := func(edges []models.CommentEdge, nodes []bug.Comment, info models.PageInfo, totalCount int) (*models.CommentConnection, error) {
+ return &models.CommentConnection{
Edges: edges,
Nodes: nodes,
PageInfo: info,
@@ -46,7 +46,7 @@ func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, after *strin
return connections.CommentCon(obj.Comments, edger, conMaker, input)
}
-func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.OperationConnection, error) {
+func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.OperationConnection, error) {
input := models.ConnectionInput{
Before: before,
After: after,
@@ -61,8 +61,8 @@ func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *str
}
}
- conMaker := func(edges []models.OperationEdge, nodes []bug.Operation, info models.PageInfo, totalCount int) (models.OperationConnection, error) {
- return models.OperationConnection{
+ conMaker := func(edges []models.OperationEdge, nodes []bug.Operation, info models.PageInfo, totalCount int) (*models.OperationConnection, error) {
+ return &models.OperationConnection{
Edges: edges,
Nodes: nodes,
PageInfo: info,
@@ -73,7 +73,7 @@ func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, after *str
return connections.OperationCon(obj.Operations, edger, conMaker, input)
}
-func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.TimelineItemConnection, error) {
+func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.TimelineItemConnection, error) {
input := models.ConnectionInput{
Before: before,
After: after,
@@ -88,8 +88,8 @@ func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *strin
}
}
- conMaker := func(edges []models.TimelineItemEdge, nodes []bug.TimelineItem, info models.PageInfo, totalCount int) (models.TimelineItemConnection, error) {
- return models.TimelineItemConnection{
+ conMaker := func(edges []models.TimelineItemEdge, nodes []bug.TimelineItem, info models.PageInfo, totalCount int) (*models.TimelineItemConnection, error) {
+ return &models.TimelineItemConnection{
Edges: edges,
Nodes: nodes,
PageInfo: info,
@@ -100,11 +100,12 @@ func (bugResolver) Timeline(ctx context.Context, obj *bug.Snapshot, after *strin
return connections.TimelineItemCon(obj.Timeline, edger, conMaker, input)
}
-func (bugResolver) LastEdit(ctx context.Context, obj *bug.Snapshot) (time.Time, error) {
- return obj.LastEditTime(), nil
+func (bugResolver) LastEdit(ctx context.Context, obj *bug.Snapshot) (*time.Time, error) {
+ t := obj.LastEditTime()
+ return &t, nil
}
-func (bugResolver) Actors(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.IdentityConnection, error) {
+func (bugResolver) Actors(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.IdentityConnection, error) {
input := models.ConnectionInput{
Before: before,
After: after,
@@ -119,8 +120,8 @@ func (bugResolver) Actors(ctx context.Context, obj *bug.Snapshot, after *string,
}
}
- conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (models.IdentityConnection, error) {
- return models.IdentityConnection{
+ conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (*models.IdentityConnection, error) {
+ return &models.IdentityConnection{
Edges: edges,
Nodes: nodes,
PageInfo: info,
@@ -131,7 +132,7 @@ func (bugResolver) Actors(ctx context.Context, obj *bug.Snapshot, after *string,
return connections.IdentityCon(obj.Actors, edger, conMaker, input)
}
-func (bugResolver) Participants(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (models.IdentityConnection, error) {
+func (bugResolver) Participants(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int) (*models.IdentityConnection, error) {
input := models.ConnectionInput{
Before: before,
After: after,
@@ -146,8 +147,8 @@ func (bugResolver) Participants(ctx context.Context, obj *bug.Snapshot, after *s
}
}
- conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (models.IdentityConnection, error) {
- return models.IdentityConnection{
+ conMaker := func(edges []models.IdentityEdge, nodes []identity.Interface, info models.PageInfo, totalCount int) (*models.IdentityConnection, error) {
+ return &models.IdentityConnection{
Edges: edges,
Nodes: nodes,
PageInfo: info,
diff --git a/graphql/resolvers/mutation.go b/graphql/resolvers/mutation.go
index 73d39da8..d10d2ea3 100644
--- a/graphql/resolvers/mutation.go
+++ b/graphql/resolvers/mutation.go
@@ -23,144 +23,130 @@ func (r mutationResolver) getRepo(repoRef *string) (*cache.RepoCache, error) {
return r.cache.DefaultRepo()
}
-func (r mutationResolver) NewBug(ctx context.Context, repoRef *string, title string, message string, files []git.Hash) (bug.Snapshot, error) {
+func (r mutationResolver) NewBug(ctx context.Context, repoRef *string, title string, message string, files []git.Hash) (*bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
b, err := repo.NewBugWithFiles(title, message, files)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
- snap := b.Snapshot()
-
- return *snap, nil
+ return b.Snapshot(), nil
}
-func (r mutationResolver) Commit(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error) {
+func (r mutationResolver) Commit(ctx context.Context, repoRef *string, prefix string) (*bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
b, err := repo.ResolveBugPrefix(prefix)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
err = b.Commit()
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
- snap := b.Snapshot()
-
- return *snap, nil
+ return b.Snapshot(), nil
}
-func (r mutationResolver) AddComment(ctx context.Context, repoRef *string, prefix string, message string, files []git.Hash) (bug.Snapshot, error) {
+func (r mutationResolver) AddComment(ctx context.Context, repoRef *string, prefix string, message string, files []git.Hash) (*bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
b, err := repo.ResolveBugPrefix(prefix)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
_, err = b.AddCommentWithFiles(message, files)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
- snap := b.Snapshot()
-
- return *snap, nil
+ return b.Snapshot(), nil
}
-func (r mutationResolver) ChangeLabels(ctx context.Context, repoRef *string, prefix string, added []string, removed []string) (bug.Snapshot, error) {
+func (r mutationResolver) ChangeLabels(ctx context.Context, repoRef *string, prefix string, added []string, removed []string) (*bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
b, err := repo.ResolveBugPrefix(prefix)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
_, _, err = b.ChangeLabels(added, removed)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
- snap := b.Snapshot()
-
- return *snap, nil
+ return b.Snapshot(), nil
}
-func (r mutationResolver) Open(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error) {
+func (r mutationResolver) Open(ctx context.Context, repoRef *string, prefix string) (*bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
b, err := repo.ResolveBugPrefix(prefix)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
_, err = b.Open()
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
- snap := b.Snapshot()
-
- return *snap, nil
+ return b.Snapshot(), nil
}
-func (r mutationResolver) Close(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error) {
+func (r mutationResolver) Close(ctx context.Context, repoRef *string, prefix string) (*bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
b, err := repo.ResolveBugPrefix(prefix)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
_, err = b.Close()
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
- snap := b.Snapshot()
-
- return *snap, nil
+ return b.Snapshot(), nil
}
-func (r mutationResolver) SetTitle(ctx context.Context, repoRef *string, prefix string, title string) (bug.Snapshot, error) {
+func (r mutationResolver) SetTitle(ctx context.Context, repoRef *string, prefix string, title string) (*bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
b, err := repo.ResolveBugPrefix(prefix)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
_, err = b.SetTitle(title)
if err != nil {
- return bug.Snapshot{}, err
+ return nil, err
}
- snap := b.Snapshot()
-
- return *snap, nil
+ return b.Snapshot(), nil
}
diff --git a/graphql/resolvers/operations.go b/graphql/resolvers/operations.go
index c8089ac1..90817567 100644
--- a/graphql/resolvers/operations.go
+++ b/graphql/resolvers/operations.go
@@ -11,32 +11,37 @@ import (
type createOperationResolver struct{}
-func (createOperationResolver) Date(ctx context.Context, obj *bug.CreateOperation) (time.Time, error) {
- return obj.Time(), nil
+func (createOperationResolver) Date(ctx context.Context, obj *bug.CreateOperation) (*time.Time, error) {
+ t := obj.Time()
+ return &t, nil
}
type addCommentOperationResolver struct{}
-func (addCommentOperationResolver) Date(ctx context.Context, obj *bug.AddCommentOperation) (time.Time, error) {
- return obj.Time(), nil
+func (addCommentOperationResolver) Date(ctx context.Context, obj *bug.AddCommentOperation) (*time.Time, error) {
+ t := obj.Time()
+ return &t, nil
}
type editCommentOperationResolver struct{}
-func (editCommentOperationResolver) Date(ctx context.Context, obj *bug.EditCommentOperation) (time.Time, error) {
- return obj.Time(), nil
+func (editCommentOperationResolver) Date(ctx context.Context, obj *bug.EditCommentOperation) (*time.Time, error) {
+ t := obj.Time()
+ return &t, nil
}
type labelChangeOperation struct{}
-func (labelChangeOperation) Date(ctx context.Context, obj *bug.LabelChangeOperation) (time.Time, error) {
- return obj.Time(), nil
+func (labelChangeOperation) Date(ctx context.Context, obj *bug.LabelChangeOperation) (*time.Time, error) {
+ t := obj.Time()
+ return &t, nil
}
type setStatusOperationResolver struct{}
-func (setStatusOperationResolver) Date(ctx context.Context, obj *bug.SetStatusOperation) (time.Time, error) {
- return obj.Time(), nil
+func (setStatusOperationResolver) Date(ctx context.Context, obj *bug.SetStatusOperation) (*time.Time, error) {
+ t := obj.Time()
+ return &t, nil
}
func (setStatusOperationResolver) Status(ctx context.Context, obj *bug.SetStatusOperation) (models.Status, error) {
@@ -45,8 +50,9 @@ func (setStatusOperationResolver) Status(ctx context.Context, obj *bug.SetStatus
type setTitleOperationResolver struct{}
-func (setTitleOperationResolver) Date(ctx context.Context, obj *bug.SetTitleOperation) (time.Time, error) {
- return obj.Time(), nil
+func (setTitleOperationResolver) Date(ctx context.Context, obj *bug.SetTitleOperation) (*time.Time, error) {
+ t := obj.Time()
+ return &t, nil
}
func convertStatus(status bug.Status) (models.Status, error) {
diff --git a/graphql/resolvers/repo.go b/graphql/resolvers/repo.go
index 9003fbf9..cf10e4ae 100644
--- a/graphql/resolvers/repo.go
+++ b/graphql/resolvers/repo.go
@@ -15,7 +15,7 @@ var _ graph.RepositoryResolver = &repoResolver{}
type repoResolver struct{}
-func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int, queryStr *string) (models.BugConnection, error) {
+func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int, queryStr *string) (*models.BugConnection, error) {
input := models.ConnectionInput{
Before: before,
After: after,
@@ -27,7 +27,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
if queryStr != nil {
query2, err := cache.ParseQuery(*queryStr)
if err != nil {
- return models.BugConnection{}, err
+ return nil, err
}
query = query2
} else {
@@ -46,7 +46,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
}
// The conMaker will finally load and compile bugs from git to replace the selected edges
- conMaker := func(lazyBugEdges []connections.LazyBugEdge, lazyNode []string, info models.PageInfo, totalCount int) (models.BugConnection, error) {
+ conMaker := func(lazyBugEdges []connections.LazyBugEdge, lazyNode []string, info models.PageInfo, totalCount int) (*models.BugConnection, error) {
edges := make([]models.BugEdge, len(lazyBugEdges))
nodes := make([]bug.Snapshot, len(lazyBugEdges))
@@ -54,7 +54,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
b, err := obj.Repo.ResolveBug(lazyBugEdge.Id)
if err != nil {
- return models.BugConnection{}, err
+ return nil, err
}
snap := b.Snapshot()
@@ -66,7 +66,7 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *
nodes[i] = *snap
}
- return models.BugConnection{
+ return &models.BugConnection{
Edges: edges,
Nodes: nodes,
PageInfo: info,
@@ -87,7 +87,7 @@ func (repoResolver) Bug(ctx context.Context, obj *models.Repository, prefix stri
return b.Snapshot(), nil
}
-func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (models.IdentityConnection, error) {
+func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.IdentityConnection, error) {
input := models.ConnectionInput{
Before: before,
After: after,
@@ -107,7 +107,7 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
}
// The conMaker will finally load and compile identities from git to replace the selected edges
- conMaker := func(lazyIdentityEdges []connections.LazyIdentityEdge, lazyNode []string, info models.PageInfo, totalCount int) (models.IdentityConnection, error) {
+ conMaker := func(lazyIdentityEdges []connections.LazyIdentityEdge, lazyNode []string, info models.PageInfo, totalCount int) (*models.IdentityConnection, error) {
edges := make([]models.IdentityEdge, len(lazyIdentityEdges))
nodes := make([]identity.Interface, len(lazyIdentityEdges))
@@ -115,7 +115,7 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
i, err := obj.Repo.ResolveIdentity(lazyIdentityEdge.Id)
if err != nil {
- return models.IdentityConnection{}, err
+ return nil, err
}
ii := identity.Interface(i.Identity)
@@ -127,7 +127,7 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
nodes[k] = ii
}
- return models.IdentityConnection{
+ return &models.IdentityConnection{
Edges: edges,
Nodes: nodes,
PageInfo: info,
@@ -138,26 +138,22 @@ func (repoResolver) AllIdentities(ctx context.Context, obj *models.Repository, a
return connections.LazyIdentityCon(source, edger, conMaker, input)
}
-func (repoResolver) Identity(ctx context.Context, obj *models.Repository, prefix string) (*identity.Interface, error) {
+func (repoResolver) Identity(ctx context.Context, obj *models.Repository, prefix string) (identity.Interface, error) {
i, err := obj.Repo.ResolveIdentityPrefix(prefix)
if err != nil {
return nil, err
}
- ii := identity.Interface(i.Identity)
-
- return &ii, nil
+ return i.Identity, nil
}
-func (repoResolver) UserIdentity(ctx context.Context, obj *models.Repository) (*identity.Interface, error) {
+func (repoResolver) UserIdentity(ctx context.Context, obj *models.Repository) (identity.Interface, error) {
i, err := obj.Repo.GetUserIdentity()
if err != nil {
return nil, err
}
- ii := identity.Interface(i.Identity)
-
- return &ii, nil
+ return i.Identity, nil
}
diff --git a/graphql/resolvers/timeline.go b/graphql/resolvers/timeline.go
index 42e0a643..27f799ba 100644
--- a/graphql/resolvers/timeline.go
+++ b/graphql/resolvers/timeline.go
@@ -10,40 +10,47 @@ import (
type commentHistoryStepResolver struct{}
-func (commentHistoryStepResolver) Date(ctx context.Context, obj *bug.CommentHistoryStep) (time.Time, error) {
- return obj.UnixTime.Time(), nil
+func (commentHistoryStepResolver) Date(ctx context.Context, obj *bug.CommentHistoryStep) (*time.Time, error) {
+ t := obj.UnixTime.Time()
+ return &t, nil
}
type addCommentTimelineItemResolver struct{}
-func (addCommentTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.AddCommentTimelineItem) (time.Time, error) {
- return obj.CreatedAt.Time(), nil
+func (addCommentTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.AddCommentTimelineItem) (*time.Time, error) {
+ t := obj.CreatedAt.Time()
+ return &t, nil
}
-func (addCommentTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.AddCommentTimelineItem) (time.Time, error) {
- return obj.LastEdit.Time(), nil
+func (addCommentTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.AddCommentTimelineItem) (*time.Time, error) {
+ t := obj.LastEdit.Time()
+ return &t, nil
}
type createTimelineItemResolver struct{}
-func (createTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.CreateTimelineItem) (time.Time, error) {
- return obj.CreatedAt.Time(), nil
+func (createTimelineItemResolver) CreatedAt(ctx context.Context, obj *bug.CreateTimelineItem) (*time.Time, error) {
+ t := obj.CreatedAt.Time()
+ return &t, nil
}
-func (createTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.CreateTimelineItem) (time.Time, error) {
- return obj.LastEdit.Time(), nil
+func (createTimelineItemResolver) LastEdit(ctx context.Context, obj *bug.CreateTimelineItem) (*time.Time, error) {
+ t := obj.LastEdit.Time()
+ return &t, nil
}
type labelChangeTimelineItem struct{}
-func (labelChangeTimelineItem) Date(ctx context.Context, obj *bug.LabelChangeTimelineItem) (time.Time, error) {
- return obj.UnixTime.Time(), nil
+func (labelChangeTimelineItem) Date(ctx context.Context, obj *bug.LabelChangeTimelineItem) (*time.Time, error) {
+ t := obj.UnixTime.Time()
+ return &t, nil
}
type setStatusTimelineItem struct{}
-func (setStatusTimelineItem) Date(ctx context.Context, obj *bug.SetStatusTimelineItem) (time.Time, error) {
- return obj.UnixTime.Time(), nil
+func (setStatusTimelineItem) Date(ctx context.Context, obj *bug.SetStatusTimelineItem) (*time.Time, error) {
+ t := obj.UnixTime.Time()
+ return &t, nil
}
func (setStatusTimelineItem) Status(ctx context.Context, obj *bug.SetStatusTimelineItem) (models.Status, error) {
@@ -52,6 +59,7 @@ func (setStatusTimelineItem) Status(ctx context.Context, obj *bug.SetStatusTimel
type setTitleTimelineItem struct{}
-func (setTitleTimelineItem) Date(ctx context.Context, obj *bug.SetTitleTimelineItem) (time.Time, error) {
- return obj.UnixTime.Time(), nil
+func (setTitleTimelineItem) Date(ctx context.Context, obj *bug.SetTitleTimelineItem) (*time.Time, error) {
+ t := obj.UnixTime.Time()
+ return &t, nil
}