aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers/repo.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-09-04 21:04:05 +0200
committerMichael Muré <batolettre@gmail.com>2019-09-04 21:04:05 +0200
commit7df170939f2bad0f03b834dda5af1b55bd0d6830 (patch)
tree923011eb7e421c44cb6bcec4f1f5806066c51264 /graphql/resolvers/repo.go
parent16af70894c0348ec90dfee69274f7d44ef2eb079 (diff)
downloadgit-bug-7df170939f2bad0f03b834dda5af1b55bd0d6830.tar.gz
graphql: make repository.validLabels a connection
Diffstat (limited to 'graphql/resolvers/repo.go')
-rw-r--r--graphql/resolvers/repo.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/graphql/resolvers/repo.go b/graphql/resolvers/repo.go
index ac9c162f..5a37ae18 100644
--- a/graphql/resolvers/repo.go
+++ b/graphql/resolvers/repo.go
@@ -159,6 +159,29 @@ func (repoResolver) UserIdentity(ctx context.Context, obj *models.Repository) (i
return i.Identity, nil
}
-func (repoResolver) ValidLabels(ctx context.Context, obj *models.Repository) ([]bug.Label, error) {
- return obj.Repo.ValidLabels(), nil
+func (resolver repoResolver) ValidLabels(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.LabelConnection, error) {
+ input := models.ConnectionInput{
+ Before: before,
+ After: after,
+ First: first,
+ Last: last,
+ }
+
+ edger := func(label bug.Label, offset int) connections.Edge {
+ return models.LabelEdge{
+ Node: label,
+ Cursor: connections.OffsetToCursor(offset),
+ }
+ }
+
+ conMaker := func(edges []*models.LabelEdge, nodes []bug.Label, info *models.PageInfo, totalCount int) (*models.LabelConnection, error) {
+ return &models.LabelConnection{
+ Edges: edges,
+ Nodes: nodes,
+ PageInfo: info,
+ TotalCount: totalCount,
+ }, nil
+ }
+
+ return connections.LabelCon(obj.Repo.ValidLabels(), edger, conMaker, input)
}