diff options
Diffstat (limited to 'graphql2/resolvers/query.go')
-rw-r--r-- | graphql2/resolvers/query.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/graphql2/resolvers/query.go b/graphql2/resolvers/query.go new file mode 100644 index 00000000..cceca334 --- /dev/null +++ b/graphql2/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 +} |