aboutsummaryrefslogtreecommitdiffstats
path: root/graphql2/resolvers.go
blob: fa47f222b3d38a7259db592428e335baebdb6f5b (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package graphql2

import (
	"context"
	"fmt"
	"github.com/MichaelMure/git-bug/bug"
	"github.com/MichaelMure/git-bug/bug/operations"
	"github.com/MichaelMure/git-bug/cache"
	"github.com/MichaelMure/git-bug/graphql2/gen"
	"time"
)

type Backend struct {
	cache cache.RootCache
}

func (*Backend) Bug_labels(ctx context.Context, obj *bug.Snapshot) ([]*bug.Label, error) {
	return obj.Labels
}

func (*Backend) LabelChangeOperation_added(ctx context.Context, obj *operations.LabelChangeOperation) ([]*bug.Label, error) {
	panic("implement me")
}

func (*Backend) LabelChangeOperation_removed(ctx context.Context, obj *operations.LabelChangeOperation) ([]*bug.Label, error) {
	panic("implement me")
}

func (*Backend) AddCommentOperation_date(ctx context.Context, obj *operations.AddCommentOperation) (time.Time, error) {
	return obj.Time(), nil
}

func (*Backend) Bug_status(ctx context.Context, obj *bug.Snapshot) (gen.Status, error) {
	return convertStatus(obj.Status)
}

func (*Backend) Bug_comments(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int, query *string) (gen.CommentConnection, error) {
	panic("implement me")
}

func (*Backend) Bug_operations(ctx context.Context, obj *bug.Snapshot, after *string, before *string, first *int, last *int, query *string) (gen.OperationConnection, error) {
	panic("implement me")
}

func (*Backend) CreateOperation_date(ctx context.Context, obj *operations.CreateOperation) (time.Time, error) {
	return obj.Time(), nil
}

func (*Backend) LabelChangeOperation_date(ctx context.Context, obj *operations.LabelChangeOperation) (time.Time, error) {
	return obj.Time(), nil
}

func (*Backend) RootQuery_allBugs(ctx context.Context, after *string, before *string, first *int, last *int, query *string) (gen.BugConnection, error) {
	panic("implement me")
}

func (*Backend) RootQuery_bug(ctx context.Context, id string) (*bug.Snapshot, error) {
	panic("implement me")
}

func (*Backend) SetStatusOperation_date(ctx context.Context, obj *operations.SetStatusOperation) (time.Time, error) {
	return obj.Time(), nil
}

func (*Backend) SetStatusOperation_status(ctx context.Context, obj *operations.SetStatusOperation) (gen.Status, error) {
	return convertStatus(obj.Status)
}

func (*Backend) SetTitleOperation_date(ctx context.Context, obj *operations.SetTitleOperation) (time.Time, error) {
	return obj.Time(), nil
}

func convertStatus(status bug.Status) (gen.Status, error) {
	switch status {
	case bug.OpenStatus:
		return gen.StatusOpen, nil
	case bug.ClosedStatus:
		return gen.StatusClosed, nil
	}

	return "", fmt.Errorf("Unknown status")
}