You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
package models
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
)
|
|
|
|
// TagKind represents the kind of tags.
|
|
type TagKind string
|
|
|
|
const (
|
|
// TagKindOrganization is a tag kind, see GraphQL documentation.
|
|
TagKindOrganization TagKind = "Organization"
|
|
|
|
// TagKindCharacter is a tag kind, see GraphQL documentation.
|
|
TagKindCharacter TagKind = "Character"
|
|
|
|
// TagKindLocation is a tag kind, see GraphQL documentation.
|
|
TagKindLocation TagKind = "Location"
|
|
|
|
// TagKindEvent is a tag kind, see GraphQL documentation.
|
|
TagKindEvent TagKind = "Event"
|
|
|
|
// TagKindSeries is a tag kind, see GraphQL documentation.
|
|
TagKindSeries TagKind = "Series"
|
|
)
|
|
|
|
// UnmarshalGQL unmarshals
|
|
func (e *TagKind) UnmarshalGQL(v interface{}) error {
|
|
str, ok := v.(string)
|
|
if !ok {
|
|
return fmt.Errorf("enums must be strings")
|
|
}
|
|
|
|
*e = TagKind(str)
|
|
switch *e {
|
|
case TagKindOrganization, TagKindCharacter, TagKindLocation, TagKindEvent, TagKindSeries:
|
|
return nil
|
|
default:
|
|
return fmt.Errorf("%s is not a valid TagKind", str)
|
|
}
|
|
}
|
|
|
|
// MarshalGQL turns it into a JSON string
|
|
func (e TagKind) MarshalGQL(w io.Writer) {
|
|
fmt.Fprint(w, "\""+string(e), "\"")
|
|
}
|