blob: b06e94cc011e855248b5521222515a49067f4bde (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package resolvers
import (
"context"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
)
type mutationResolver struct {
cache cache.Cacher
}
func (r mutationResolver) getRepo(repoRef *string) (cache.RepoCacher, error) {
if repoRef != nil {
return r.cache.ResolveRepo(*repoRef)
}
return r.cache.DefaultRepo()
}
func (r mutationResolver) NewBug(ctx context.Context, repoRef *string, title string, message string) (bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
return bug.Snapshot{}, err
}
b, err := repo.NewBug(title, message)
if err != nil {
return bug.Snapshot{}, err
}
snap := b.Snapshot()
return *snap, nil
}
|