github.com/fortexxx/gqlgen@v0.10.3-0.20191216030626-ca5ea8b21ead/plugin/modelgen/out/generated.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 // InterfaceWithDescription is an interface with a description 12 type InterfaceWithDescription interface { 13 IsInterfaceWithDescription() 14 } 15 16 type MissingInterface interface { 17 IsMissingInterface() 18 } 19 20 type MissingUnion interface { 21 IsMissingUnion() 22 } 23 24 // UnionWithDescription is an union with a description 25 type UnionWithDescription interface { 26 IsUnionWithDescription() 27 } 28 29 type MissingInput struct { 30 Name *string `json:"name" database:"MissingInputname"` 31 Enum *MissingEnum `json:"enum" database:"MissingInputenum"` 32 } 33 34 type MissingTypeNotNull struct { 35 Name string `json:"name" database:"MissingTypeNotNullname"` 36 Enum MissingEnum `json:"enum" database:"MissingTypeNotNullenum"` 37 Int MissingInterface `json:"int" database:"MissingTypeNotNullint"` 38 Existing *ExistingType `json:"existing" database:"MissingTypeNotNullexisting"` 39 Missing2 *MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"` 40 } 41 42 func (MissingTypeNotNull) IsMissingInterface() {} 43 func (MissingTypeNotNull) IsExistingInterface() {} 44 func (MissingTypeNotNull) IsMissingUnion() {} 45 func (MissingTypeNotNull) IsExistingUnion() {} 46 47 type MissingTypeNullable struct { 48 Name *string `json:"name" database:"MissingTypeNullablename"` 49 Enum *MissingEnum `json:"enum" database:"MissingTypeNullableenum"` 50 Int MissingInterface `json:"int" database:"MissingTypeNullableint"` 51 Existing *ExistingType `json:"existing" database:"MissingTypeNullableexisting"` 52 Missing2 *MissingTypeNotNull `json:"missing2" database:"MissingTypeNullablemissing2"` 53 } 54 55 func (MissingTypeNullable) IsMissingInterface() {} 56 func (MissingTypeNullable) IsExistingInterface() {} 57 func (MissingTypeNullable) IsMissingUnion() {} 58 func (MissingTypeNullable) IsExistingUnion() {} 59 60 // TypeWithDescription is a type with a description 61 type TypeWithDescription struct { 62 Name *string `json:"name" database:"TypeWithDescriptionname"` 63 } 64 65 func (TypeWithDescription) IsUnionWithDescription() {} 66 67 // EnumWithDescription is an enum with a description 68 type EnumWithDescription string 69 70 const ( 71 EnumWithDescriptionCat EnumWithDescription = "CAT" 72 EnumWithDescriptionDog EnumWithDescription = "DOG" 73 ) 74 75 var AllEnumWithDescription = []EnumWithDescription{ 76 EnumWithDescriptionCat, 77 EnumWithDescriptionDog, 78 } 79 80 func (e EnumWithDescription) IsValid() bool { 81 switch e { 82 case EnumWithDescriptionCat, EnumWithDescriptionDog: 83 return true 84 } 85 return false 86 } 87 88 func (e EnumWithDescription) String() string { 89 return string(e) 90 } 91 92 func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error { 93 str, ok := v.(string) 94 if !ok { 95 return fmt.Errorf("enums must be strings") 96 } 97 98 *e = EnumWithDescription(str) 99 if !e.IsValid() { 100 return fmt.Errorf("%s is not a valid EnumWithDescription", str) 101 } 102 return nil 103 } 104 105 func (e EnumWithDescription) MarshalGQL(w io.Writer) { 106 fmt.Fprint(w, strconv.Quote(e.String())) 107 } 108 109 type MissingEnum string 110 111 const ( 112 MissingEnumHello MissingEnum = "Hello" 113 MissingEnumGoodbye MissingEnum = "Goodbye" 114 ) 115 116 var AllMissingEnum = []MissingEnum{ 117 MissingEnumHello, 118 MissingEnumGoodbye, 119 } 120 121 func (e MissingEnum) IsValid() bool { 122 switch e { 123 case MissingEnumHello, MissingEnumGoodbye: 124 return true 125 } 126 return false 127 } 128 129 func (e MissingEnum) String() string { 130 return string(e) 131 } 132 133 func (e *MissingEnum) UnmarshalGQL(v interface{}) error { 134 str, ok := v.(string) 135 if !ok { 136 return fmt.Errorf("enums must be strings") 137 } 138 139 *e = MissingEnum(str) 140 if !e.IsValid() { 141 return fmt.Errorf("%s is not a valid MissingEnum", str) 142 } 143 return nil 144 } 145 146 func (e MissingEnum) MarshalGQL(w io.Writer) { 147 fmt.Fprint(w, strconv.Quote(e.String())) 148 }