diff options
author | Michael Muré <batolettre@gmail.com> | 2019-05-22 20:56:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 20:56:37 +0200 |
commit | 6e20bf0e73862854aea0cd759a880a6b5f473880 (patch) | |
tree | 54c7b0f20fa8588f79f7bd9c121630d502b5e1be /graphql/resolvers | |
parent | 485ca5900486b7fc3ea71cbcbb39b87272ae09fd (diff) | |
parent | aa6247ce870075922a1309718e8fafee321ef51d (diff) | |
download | git-bug-6e20bf0e73862854aea0cd759a880a6b5f473880.tar.gz |
Merge pull request #113 from ludovicm67/patch-colors
bug: add label color directly in the core
Diffstat (limited to 'graphql/resolvers')
-rw-r--r-- | graphql/resolvers/color.go | 24 | ||||
-rw-r--r-- | graphql/resolvers/label.go | 22 | ||||
-rw-r--r-- | graphql/resolvers/root.go | 8 |
3 files changed, 54 insertions, 0 deletions
diff --git a/graphql/resolvers/color.go b/graphql/resolvers/color.go new file mode 100644 index 00000000..dc6f1b9c --- /dev/null +++ b/graphql/resolvers/color.go @@ -0,0 +1,24 @@ +package resolvers + +import ( + "context" + "image/color" + + "github.com/MichaelMure/git-bug/graphql/graph" +) + +var _ graph.ColorResolver = &colorResolver{} + +type colorResolver struct{} + +func (colorResolver) R(ctx context.Context, obj *color.RGBA) (int, error) { + return int(obj.R), nil +} + +func (colorResolver) G(ctx context.Context, obj *color.RGBA) (int, error) { + return int(obj.G), nil +} + +func (colorResolver) B(ctx context.Context, obj *color.RGBA) (int, error) { + return int(obj.B), nil +} diff --git a/graphql/resolvers/label.go b/graphql/resolvers/label.go new file mode 100644 index 00000000..7619f748 --- /dev/null +++ b/graphql/resolvers/label.go @@ -0,0 +1,22 @@ +package resolvers + +import ( + "context" + "image/color" + + "github.com/MichaelMure/git-bug/bug" + "github.com/MichaelMure/git-bug/graphql/graph" +) + +var _ graph.LabelResolver = &labelResolver{} + +type labelResolver struct{} + +func (labelResolver) Name(ctx context.Context, obj *bug.Label) (string, error) { + return obj.String(), nil +} + +func (labelResolver) Color(ctx context.Context, obj *bug.Label) (*color.RGBA, error) { + rgba := obj.RGBA() + return &rgba, nil +} diff --git a/graphql/resolvers/root.go b/graphql/resolvers/root.go index 7414a097..f6a4a57b 100644 --- a/graphql/resolvers/root.go +++ b/graphql/resolvers/root.go @@ -34,6 +34,14 @@ func (RootResolver) Bug() graph.BugResolver { return &bugResolver{} } +func (RootResolver) Color() graph.ColorResolver { + return &colorResolver{} +} + +func (RootResolver) Label() graph.LabelResolver { + return &labelResolver{} +} + func (r RootResolver) Identity() graph.IdentityResolver { return &identityResolver{} } |