This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
@@ -35,14 +36,13 @@ func (e *StoryCategory) IsValid() bool {
|
|||||||
func (e *StoryCategory) UnmarshalGQL(v interface{}) error {
|
func (e *StoryCategory) UnmarshalGQL(v interface{}) error {
|
||||||
str, ok := v.(string)
|
str, ok := v.(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("enums must be strings")
|
return errors.New("enums must be strings")
|
||||||
}
|
|
||||||
|
|
||||||
if !e.IsValid() {
|
|
||||||
return fmt.Errorf("%s is not a valid StoryCategory", str)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*e = StoryCategory(str)
|
*e = StoryCategory(str)
|
||||||
|
if !e.IsValid() {
|
||||||
|
return fmt.Errorf("\"%s\" is not a valid StoryCategory", str)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user