|
@ -21,6 +21,16 @@ const ( |
|
|
StoryCategoryStory StoryCategory = "Story" |
|
|
StoryCategoryStory StoryCategory = "Story" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
// IsValid returns whether the category is one of the valid values.
|
|
|
|
|
|
func (e *StoryCategory) IsValid() bool { |
|
|
|
|
|
switch *e { |
|
|
|
|
|
case StoryCategoryInfo, StoryCategoryNews, StoryCategoryDocument, StoryCategoryBackground, StoryCategoryStory: |
|
|
|
|
|
return true |
|
|
|
|
|
default: |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// UnmarshalGQL unmarshals
|
|
|
// UnmarshalGQL unmarshals
|
|
|
func (e *StoryCategory) UnmarshalGQL(v interface{}) error { |
|
|
func (e *StoryCategory) UnmarshalGQL(v interface{}) error { |
|
|
str, ok := v.(string) |
|
|
str, ok := v.(string) |
|
@ -28,13 +38,13 @@ func (e *StoryCategory) UnmarshalGQL(v interface{}) error { |
|
|
return fmt.Errorf("enums must be strings") |
|
|
return fmt.Errorf("enums must be strings") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
*e = StoryCategory(str) |
|
|
|
|
|
switch *e { |
|
|
|
|
|
case StoryCategoryInfo, StoryCategoryNews, StoryCategoryDocument, StoryCategoryBackground, StoryCategoryStory: |
|
|
|
|
|
return nil |
|
|
|
|
|
default: |
|
|
|
|
|
|
|
|
if !e.IsValid() { |
|
|
return fmt.Errorf("%s is not a valid StoryCategory", str) |
|
|
return fmt.Errorf("%s is not a valid StoryCategory", str) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
*e = StoryCategory(str) |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// MarshalGQL turns it into a JSON string
|
|
|
// MarshalGQL turns it into a JSON string
|
|
|