aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers/query.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-29 18:58:42 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-29 18:58:42 +0200
commit8fa0b258ac89781dae269790a4bde09cbcd2f324 (patch)
treeb9bcf0826f5739f128de52123447cede23291c02 /graphql/resolvers/query.go
parent6363518c85cbd8247a5f6507b8a1dd3903cfb71d (diff)
downloadgit-bug-8fa0b258ac89781dae269790a4bde09cbcd2f324.tar.gz
cleaning
Diffstat (limited to 'graphql/resolvers/query.go')
-rw-r--r--graphql/resolvers/query.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/graphql/resolvers/query.go b/graphql/resolvers/query.go
new file mode 100644
index 00000000..cceca334
--- /dev/null
+++ b/graphql/resolvers/query.go
@@ -0,0 +1,36 @@
+package resolvers
+
+import (
+ "context"
+ "github.com/MichaelMure/git-bug/cache"
+)
+
+type rootQueryResolver struct {
+ cache cache.Cacher
+}
+
+func (r rootQueryResolver) DefaultRepository(ctx context.Context) (*repoResolver, error) {
+ repo, err := r.cache.DefaultRepo()
+
+ if err != nil {
+ return nil, err
+ }
+
+ return &repoResolver{
+ cache: r.cache,
+ repo: repo,
+ }, nil
+}
+
+func (r rootQueryResolver) Repository(ctx context.Context, id string) (*repoResolver, error) {
+ repo, err := r.cache.ResolveRepo(id)
+
+ if err != nil {
+ return nil, err
+ }
+
+ return &repoResolver{
+ cache: r.cache,
+ repo: repo,
+ }, nil
+}