models2: Fixed StoryCategory UnmarshalGQL validating before writing the value.
the build failed

This commit is contained in:
2018-10-03 20:56:18 +02:00
parent b8e5ed5813
commit 0e9536b0a8
+5 -5
View File
@@ -1,6 +1,7 @@
package models
import (
"errors"
"fmt"
"io"
)
@@ -35,14 +36,13 @@ func (e *StoryCategory) IsValid() bool {
func (e *StoryCategory) UnmarshalGQL(v interface{}) error {
str, ok := v.(string)
if !ok {
return fmt.Errorf("enums must be strings")
}
if !e.IsValid() {
return fmt.Errorf("%s is not a valid StoryCategory", str)
return errors.New("enums must be strings")
}
*e = StoryCategory(str)
if !e.IsValid() {
return fmt.Errorf("\"%s\" is not a valid StoryCategory", str)
}
return nil
}