aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers/query.go
diff options
context:
space:
mode:
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
+}