diff options
author | Michael Muré <batolettre@gmail.com> | 2018-08-15 14:53:50 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-08-15 14:53:50 +0200 |
commit | bc1fb34c24e985b7a9d50c559d7a42726a3a2007 (patch) | |
tree | 2cfc71c61d8dd491462ec77ab8826e50c1728181 /graphql/connections/gen_comment.go | |
parent | 5c568a362b73cf163b06bc7371982f9a7ceaaf29 (diff) | |
download | git-bug-bc1fb34c24e985b7a9d50c559d7a42726a3a2007.tar.gz |
graphql: fix two bugs in the connection code
1) totalCount was incorrect when not in the first page
2) pageInfo.Has{Previous,Next}Page was incorrect when using before or after
Diffstat (limited to 'graphql/connections/gen_comment.go')
-rw-r--r-- | graphql/connections/gen_comment.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/graphql/connections/gen_comment.go b/graphql/connections/gen_comment.go index 223b25e8..5c8b0eea 100644 --- a/graphql/connections/gen_comment.go +++ b/graphql/connections/gen_comment.go @@ -28,6 +28,7 @@ func BugCommentCon(source []bug.Comment, edgeMaker BugCommentEdgeMaker, conMaker var edges []models.CommentEdge var cursors []string var pageInfo models.PageInfo + var totalCount = len(source) emptyCon, _ := conMaker(edges, nodes, pageInfo, 0) @@ -40,6 +41,7 @@ func BugCommentCon(source []bug.Comment, edgeMaker BugCommentEdgeMaker, conMaker // remove all previous element including the "after" one source = source[i+1:] offset = i + 1 + pageInfo.HasPreviousPage = true break } } @@ -51,6 +53,7 @@ func BugCommentCon(source []bug.Comment, edgeMaker BugCommentEdgeMaker, conMaker if edge.GetCursor() == *input.Before { // remove all after element including the "before" one + pageInfo.HasNextPage = true break } @@ -104,5 +107,5 @@ func BugCommentCon(source []bug.Comment, edgeMaker BugCommentEdgeMaker, conMaker pageInfo.EndCursor = cursors[len(cursors)-1] } - return conMaker(edges, nodes, pageInfo, len(source)) + return conMaker(edges, nodes, pageInfo, totalCount) } |