github.com/99designs/gqlgen@v0.17.45/plugin/modelgen/out/generated_omit_root_models.go (about) 1 // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. 2 3 package out 4 5 import ( 6 "fmt" 7 "io" 8 "strconv" 9 ) 10 11 type SomeContent string 12 13 const ( 14 SomeContentThis SomeContent = "This" 15 SomeContentIs SomeContent = "Is" 16 SomeContentA SomeContent = "A" 17 SomeContentTest SomeContent = "Test" 18 ) 19 20 var AllSomeContent = []SomeContent{ 21 SomeContentThis, 22 SomeContentIs, 23 SomeContentA, 24 SomeContentTest, 25 } 26 27 func (e SomeContent) IsValid() bool { 28 switch e { 29 case SomeContentThis, SomeContentIs, SomeContentA, SomeContentTest: 30 return true 31 } 32 return false 33 } 34 35 func (e SomeContent) String() string { 36 return string(e) 37 } 38 39 func (e *SomeContent) UnmarshalGQL(v interface{}) error { 40 str, ok := v.(string) 41 if !ok { 42 return fmt.Errorf("enums must be strings") 43 } 44 45 *e = SomeContent(str) 46 if !e.IsValid() { 47 return fmt.Errorf("%s is not a valid SomeContent", str) 48 } 49 return nil 50 } 51 52 func (e SomeContent) MarshalGQL(w io.Writer) { 53 fmt.Fprint(w, strconv.Quote(e.String())) 54 }