diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-11 19:46:38 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-11 19:46:38 +0200 |
commit | 7b05983c19af4da70f2a9a5062913f4e4f5d5faa (patch) | |
tree | 006d9b828d249e6a7e3362164308089991c74857 /graphql/resolvers/repo.go | |
parent | 9cbd5b4ee113c660377ffe9c01ca374d6addfef4 (diff) | |
download | git-bug-7b05983c19af4da70f2a9a5062913f4e4f5d5faa.tar.gz |
graphql: AllBugs now accept a query
Diffstat (limited to 'graphql/resolvers/repo.go')
-rw-r--r-- | graphql/resolvers/repo.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/graphql/resolvers/repo.go b/graphql/resolvers/repo.go index 7922256f..c696ff34 100644 --- a/graphql/resolvers/repo.go +++ b/graphql/resolvers/repo.go @@ -11,7 +11,7 @@ import ( type repoResolver struct{} -func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (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, @@ -19,11 +19,19 @@ func (repoResolver) AllBugs(ctx context.Context, obj *models.Repository, after * Last: last, } + var query *cache.Query + if queryStr != nil { + query2, err := cache.ParseQuery(*queryStr) + if err != nil { + return models.BugConnection{}, err + } + query = query2 + } else { + query = cache.NewQuery() + } + // Simply pass a []string with the ids to the pagination algorithm - source := obj.Repo.QueryBugs(&cache.Query{ - OrderBy: cache.OrderByCreation, - OrderDirection: cache.OrderAscending, - }) + source := obj.Repo.QueryBugs(query) // The edger create a custom edge holding just the id edger := func(id string, offset int) connections.Edge { |