aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers/bug.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-01 19:24:19 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-01 19:24:19 +0200
commit15f282421941b90e1f62912cf68b7556a8ce7b33 (patch)
tree085c77b22313f1bf4650901de3197f4f200aba28 /graphql/resolvers/bug.go
parent5830dd88414608b5fc6f5f2b44293b079bce2829 (diff)
downloadgit-bug-15f282421941b90e1f62912cf68b7556a8ce7b33.tar.gz
graphql: simplify the requests with helpers
Diffstat (limited to 'graphql/resolvers/bug.go')
-rw-r--r--graphql/resolvers/bug.go30
1 files changed, 23 insertions, 7 deletions
diff --git a/graphql/resolvers/bug.go b/graphql/resolvers/bug.go
index dfb5c913..014a0f31 100644
--- a/graphql/resolvers/bug.go
+++ b/graphql/resolvers/bug.go
@@ -13,7 +13,14 @@ func (bugResolver) Status(ctx context.Context, obj *bug.Snapshot) (models.Status
return convertStatus(obj.Status)
}
-func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, input models.ConnectionInput) (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,
+ First: first,
+ Last: last,
+ }
+
edger := func(comment bug.Comment, offset int) connections.Edge {
return models.CommentEdge{
Node: comment,
@@ -21,31 +28,40 @@ func (bugResolver) Comments(ctx context.Context, obj *bug.Snapshot, input models
}
}
- conMaker := func(edges []models.CommentEdge, info models.PageInfo, totalCount int) 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,
TotalCount: totalCount,
- }
+ }, nil
}
return connections.BugCommentCon(obj.Comments, edger, conMaker, input)
}
-func (bugResolver) Operations(ctx context.Context, obj *bug.Snapshot, input models.ConnectionInput) (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,
+ First: first,
+ Last: last,
+ }
+
edger := func(op bug.Operation, offset int) connections.Edge {
return models.OperationEdge{
- Node: op.(models.Operation),
+ Node: op,
Cursor: connections.OffsetToCursor(offset),
}
}
- conMaker := func(edges []models.OperationEdge, info models.PageInfo, totalCount int) 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,
TotalCount: totalCount,
- }
+ }, nil
}
return connections.BugOperationCon(obj.Operations, edger, conMaker, input)