resolvers.go

 1package graphql2
 2
 3import (
 4	"context"
 5	"fmt"
 6	"github.com/MichaelMure/git-bug/bug"
 7	"github.com/MichaelMure/git-bug/bug/operations"
 8	"github.com/MichaelMure/git-bug/cache"
 9	"github.com/MichaelMure/git-bug/graphql2/gen"
10	"time"
11)
12
13type Backend struct {
14	cache cache.RootCache
15}
16
17func (*Backend) Bug_labels(ctx context.Context, obj *bug.Snapshot) ([]*bug.Label, error) {
18	return obj.Labels
19}
20
21func (*Backend) LabelChangeOperation_added(ctx context.Context, obj *operations.LabelChangeOperation) ([]*bug.Label, error) {
22	panic("implement me")
23}
24
25func (*Backend) LabelChangeOperation_removed(ctx context.Context, obj *operations.LabelChangeOperation) ([]*bug.Label, error) {
26	panic("implement me")
27}
28
29func (*Backend) AddCommentOperation_date(ctx context.Context, obj *operations.AddCommentOperation) (time.Time, error) {
30	return obj.Time(), nil
31}
32
33func (*Backend) Bug_status(ctx context.Context, obj *bug.Snapshot) (gen.Status, error) {
34	return convertStatus(obj.Status)
35}
36
37func (*Backend) Bug_comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int, query *string) (gen.CommentConnection, error) {
38	panic("implement me")
39}
40
41func (*Backend) Bug_operations(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int, query *string) (gen.OperationConnection, error) {
42	panic("implement me")
43}
44
45func (*Backend) CreateOperation_date(ctx context.Context, obj *operations.CreateOperation) (time.Time, error) {
46	return obj.Time(), nil
47}
48
49func (*Backend) LabelChangeOperation_date(ctx context.Context, obj *operations.LabelChangeOperation) (time.Time, error) {
50	return obj.Time(), nil
51}
52
53func (*Backend) RootQuery_allBugs(ctx context.Context, after *string, before *string, first *int, last *int, query *string) (gen.BugConnection, error) {
54	panic("implement me")
55}
56
57func (*Backend) RootQuery_bug(ctx context.Context, id string) (*bug.Snapshot, error) {
58	panic("implement me")
59}
60
61func (*Backend) SetStatusOperation_date(ctx context.Context, obj *operations.SetStatusOperation) (time.Time, error) {
62	return obj.Time(), nil
63}
64
65func (*Backend) SetStatusOperation_status(ctx context.Context, obj *operations.SetStatusOperation) (gen.Status, error) {
66	return convertStatus(obj.Status)
67}
68
69func (*Backend) SetTitleOperation_date(ctx context.Context, obj *operations.SetTitleOperation) (time.Time, error) {
70	return obj.Time(), nil
71}
72
73func convertStatus(status bug.Status) (gen.Status, error) {
74	switch status {
75	case bug.OpenStatus:
76		return gen.StatusOpen, nil
77	case bug.ClosedStatus:
78		return gen.StatusClosed, nil
79	}
80
81	return "", fmt.Errorf("Unknown status")
82}