diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-27 19:48:45 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-27 19:48:45 +0200 |
commit | ff2fd14e3f10a7206d4ec86f07e524cfa290e0fc (patch) | |
tree | c81ecd42f3753e0abb67e10aa031fa80dca90ac7 /bug | |
parent | 932743ac066e8c6d76cbfc1710b0d55a78dced55 (diff) | |
download | git-bug-ff2fd14e3f10a7206d4ec86f07e524cfa290e0fc.tar.gz |
wip gqlgen
Diffstat (limited to 'bug')
-rw-r--r-- | bug/label.go | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bug/label.go b/bug/label.go index 889bf455..c84c56cd 100644 --- a/bug/label.go +++ b/bug/label.go @@ -1,7 +1,29 @@ package bug +import ( + "fmt" + "io" +) + type Label string func (l Label) String() string { return string(l) } + +// UnmarshalGQL implements the graphql.Marshaler interface +func (l *Label) UnmarshalGQL(v interface{}) error { + _, ok := v.(string) + if !ok { + return fmt.Errorf("labels must be strings") + } + + *l = v.(Label) + + return nil +} + +// MarshalGQL implements the graphql.Marshaler interface +func (l Label) MarshalGQL(w io.Writer) { + w.Write([]byte(l)) +} |