aboutsummaryrefslogtreecommitdiffstats
path: root/graphql
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-23 00:04:46 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-23 00:04:46 +0200
commit17e2ec8f5679c1ba7ae2ea45290e9303beb3c227 (patch)
treec8862ebf6e9e9314361120127bf3fc59877c3e02 /graphql
parente1f597639bfc2f796f74afa87e41581087f0b26e (diff)
downloadgit-bug-17e2ec8f5679c1ba7ae2ea45290e9303beb3c227.tar.gz
bug: refactor to limit abstraction leak and to have a more reusable code for the UIs
Diffstat (limited to 'graphql')
-rw-r--r--graphql/schema.go19
1 files changed, 6 insertions, 13 deletions
diff --git a/graphql/schema.go b/graphql/schema.go
index 7419e98a..8312933d 100644
--- a/graphql/schema.go
+++ b/graphql/schema.go
@@ -18,12 +18,12 @@ func graphqlSchema() (graphql.Schema, error) {
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
repo := p.Context.Value("repo").(repository.Repo)
id, _ := p.Args["id"].(string)
- bug, err := bug.FindBug(repo, id)
+ b, err := bug.FindLocalBug(repo, id)
if err != nil {
return nil, err
}
- snapshot := bug.Compile()
+ snapshot := b.Compile()
return snapshot, nil
},
@@ -33,22 +33,15 @@ func graphqlSchema() (graphql.Schema, error) {
Type: graphql.NewList(bugType),
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
repo := p.Context.Value("repo").(repository.Repo)
- ids, err := repo.ListRefs(bug.BugsRefPattern)
-
- if err != nil {
- return nil, err
- }
var snapshots []bug.Snapshot
- for _, ref := range ids {
- bug, err := bug.ReadBug(repo, bug.BugsRefPattern+ref)
-
- if err != nil {
- return nil, err
+ for sb := range bug.ReadAllLocalBugs(repo) {
+ if sb.Err != nil {
+ return nil, sb.Err
}
- snapshots = append(snapshots, bug.Compile())
+ snapshots = append(snapshots, sb.Bug.Compile())
}
return snapshots, nil