github.com/mstephano/gqlgen-schemagen@v0.0.0-20230113041936-dd2cd4ea46aa/plugin/modelgen/out/generated.go (about) 1 // Code generated by github.com/mstephano/gqlgen-schemagen, DO NOT EDIT. 2 3 package out 4 5 import ( 6 "fmt" 7 "io" 8 "strconv" 9 ) 10 11 type A interface { 12 IsA() 13 GetA() string 14 } 15 16 type ArrayOfA interface { 17 IsArrayOfA() 18 GetTrickyField() []A 19 GetTrickyFieldPointer() []A 20 } 21 22 type B interface { 23 IsB() 24 GetB() int 25 } 26 27 type C interface { 28 IsA() 29 IsC() 30 GetA() string 31 GetC() bool 32 } 33 34 type D interface { 35 IsA() 36 IsB() 37 IsD() 38 GetA() string 39 GetB() int 40 GetD() *string 41 } 42 43 type FooBarer interface { 44 IsFooBarer() 45 GetName() string 46 } 47 48 // InterfaceWithDescription is an interface with a description 49 type InterfaceWithDescription interface { 50 IsInterfaceWithDescription() 51 GetName() *string 52 } 53 54 type MissingInterface interface { 55 IsMissingInterface() 56 GetName() *string 57 } 58 59 type MissingUnion interface { 60 IsMissingUnion() 61 } 62 63 // UnionWithDescription is an union with a description 64 type UnionWithDescription interface { 65 IsUnionWithDescription() 66 } 67 68 type X interface { 69 IsX() 70 GetId() string 71 } 72 73 type CDImplemented struct { 74 A string `json:"a" database:"CDImplementeda"` 75 B int `json:"b" database:"CDImplementedb"` 76 C bool `json:"c" database:"CDImplementedc"` 77 D *string `json:"d" database:"CDImplementedd"` 78 } 79 80 func (CDImplemented) IsC() {} 81 func (this CDImplemented) GetA() string { return this.A } 82 func (this CDImplemented) GetC() bool { return this.C } 83 84 func (CDImplemented) IsA() {} 85 86 func (CDImplemented) IsD() {} 87 88 func (this CDImplemented) GetB() int { return this.B } 89 func (this CDImplemented) GetD() *string { return this.D } 90 91 func (CDImplemented) IsB() {} 92 93 type CyclicalA struct { 94 FieldOne *CyclicalB `json:"field_one" database:"CyclicalAfield_one"` 95 FieldTwo *CyclicalB `json:"field_two" database:"CyclicalAfield_two"` 96 FieldThree *CyclicalB `json:"field_three" database:"CyclicalAfield_three"` 97 FieldFour string `json:"field_four" database:"CyclicalAfield_four"` 98 } 99 100 type CyclicalB struct { 101 FieldOne *CyclicalA `json:"field_one" database:"CyclicalBfield_one"` 102 FieldTwo *CyclicalA `json:"field_two" database:"CyclicalBfield_two"` 103 FieldThree *CyclicalA `json:"field_three" database:"CyclicalBfield_three"` 104 FieldFour *CyclicalA `json:"field_four" database:"CyclicalBfield_four"` 105 FieldFive string `json:"field_five" database:"CyclicalBfield_five"` 106 } 107 108 type FieldMutationHook struct { 109 Name *string `json:"name" anotherTag:"tag" database:"FieldMutationHookname"` 110 Enum *ExistingEnum `json:"enum" yetAnotherTag:"12" database:"FieldMutationHookenum"` 111 NoVal *string `json:"noVal" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"` 112 Repeated *string `json:"repeated" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"` 113 } 114 115 type ImplArrayOfA struct { 116 TrickyField []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"` 117 TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer" database:"ImplArrayOfAtrickyFieldPointer"` 118 } 119 120 func (ImplArrayOfA) IsArrayOfA() {} 121 func (this ImplArrayOfA) GetTrickyField() []A { 122 if this.TrickyField == nil { 123 return nil 124 } 125 interfaceSlice := make([]A, 0, len(this.TrickyField)) 126 for _, concrete := range this.TrickyField { 127 interfaceSlice = append(interfaceSlice, concrete) 128 } 129 return interfaceSlice 130 } 131 func (this ImplArrayOfA) GetTrickyFieldPointer() []A { 132 if this.TrickyFieldPointer == nil { 133 return nil 134 } 135 interfaceSlice := make([]A, 0, len(this.TrickyFieldPointer)) 136 for _, concrete := range this.TrickyFieldPointer { 137 interfaceSlice = append(interfaceSlice, concrete) 138 } 139 return interfaceSlice 140 } 141 142 type MissingInput struct { 143 Name *string `json:"name" database:"MissingInputname"` 144 Enum *MissingEnum `json:"enum" database:"MissingInputenum"` 145 } 146 147 type MissingTypeNotNull struct { 148 Name string `json:"name" database:"MissingTypeNotNullname"` 149 Enum MissingEnum `json:"enum" database:"MissingTypeNotNullenum"` 150 Int MissingInterface `json:"int" database:"MissingTypeNotNullint"` 151 Existing *ExistingType `json:"existing" database:"MissingTypeNotNullexisting"` 152 Missing2 *MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"` 153 } 154 155 func (MissingTypeNotNull) IsMissingInterface() {} 156 func (this MissingTypeNotNull) GetName() *string { return &this.Name } 157 158 func (MissingTypeNotNull) IsExistingInterface() {} 159 160 func (MissingTypeNotNull) IsMissingUnion() {} 161 162 func (MissingTypeNotNull) IsExistingUnion() {} 163 164 type MissingTypeNullable struct { 165 Name *string `json:"name" database:"MissingTypeNullablename"` 166 Enum *MissingEnum `json:"enum" database:"MissingTypeNullableenum"` 167 Int MissingInterface `json:"int" database:"MissingTypeNullableint"` 168 Existing *ExistingType `json:"existing" database:"MissingTypeNullableexisting"` 169 Missing2 *MissingTypeNotNull `json:"missing2" database:"MissingTypeNullablemissing2"` 170 } 171 172 func (MissingTypeNullable) IsMissingInterface() {} 173 func (this MissingTypeNullable) GetName() *string { return this.Name } 174 175 func (MissingTypeNullable) IsExistingInterface() {} 176 177 func (MissingTypeNullable) IsMissingUnion() {} 178 179 func (MissingTypeNullable) IsExistingUnion() {} 180 181 type NotCyclicalA struct { 182 FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"` 183 FieldTwo int `json:"FieldTwo" database:"NotCyclicalAFieldTwo"` 184 } 185 186 type NotCyclicalB struct { 187 FieldOne string `json:"FieldOne" database:"NotCyclicalBFieldOne"` 188 FieldTwo *NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"` 189 } 190 191 type Recursive struct { 192 FieldOne *Recursive `json:"FieldOne" database:"RecursiveFieldOne"` 193 FieldTwo *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"` 194 FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"` 195 FieldFour string `json:"FieldFour" database:"RecursiveFieldFour"` 196 } 197 198 type RenameFieldTest struct { 199 GOODnaME string `json:"badName" database:"RenameFieldTestbadName"` 200 OtherField string `json:"otherField" database:"RenameFieldTestotherField"` 201 } 202 203 // TypeWithDescription is a type with a description 204 type TypeWithDescription struct { 205 Name *string `json:"name" database:"TypeWithDescriptionname"` 206 } 207 208 func (TypeWithDescription) IsUnionWithDescription() {} 209 210 type Xer struct { 211 Id string `json:"Id" database:"XerId"` 212 Name string `json:"Name" database:"XerName"` 213 } 214 215 func (Xer) IsX() {} 216 func (this Xer) GetId() string { return this.Id } 217 218 type FooBarr struct { 219 Name string `json:"name" database:"_Foo_Barrname"` 220 } 221 222 func (FooBarr) IsFooBarer() {} 223 func (this FooBarr) GetName() string { return this.Name } 224 225 // EnumWithDescription is an enum with a description 226 type EnumWithDescription string 227 228 const ( 229 EnumWithDescriptionCat EnumWithDescription = "CAT" 230 EnumWithDescriptionDog EnumWithDescription = "DOG" 231 ) 232 233 var AllEnumWithDescription = []EnumWithDescription{ 234 EnumWithDescriptionCat, 235 EnumWithDescriptionDog, 236 } 237 238 func (e EnumWithDescription) IsValid() bool { 239 switch e { 240 case EnumWithDescriptionCat, EnumWithDescriptionDog: 241 return true 242 } 243 return false 244 } 245 246 func (e EnumWithDescription) String() string { 247 return string(e) 248 } 249 250 func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error { 251 str, ok := v.(string) 252 if !ok { 253 return fmt.Errorf("enums must be strings") 254 } 255 256 *e = EnumWithDescription(str) 257 if !e.IsValid() { 258 return fmt.Errorf("%s is not a valid EnumWithDescription", str) 259 } 260 return nil 261 } 262 263 func (e EnumWithDescription) MarshalGQL(w io.Writer) { 264 fmt.Fprint(w, strconv.Quote(e.String())) 265 } 266 267 type MissingEnum string 268 269 const ( 270 MissingEnumHello MissingEnum = "Hello" 271 MissingEnumGoodbye MissingEnum = "Goodbye" 272 ) 273 274 var AllMissingEnum = []MissingEnum{ 275 MissingEnumHello, 276 MissingEnumGoodbye, 277 } 278 279 func (e MissingEnum) IsValid() bool { 280 switch e { 281 case MissingEnumHello, MissingEnumGoodbye: 282 return true 283 } 284 return false 285 } 286 287 func (e MissingEnum) String() string { 288 return string(e) 289 } 290 291 func (e *MissingEnum) UnmarshalGQL(v interface{}) error { 292 str, ok := v.(string) 293 if !ok { 294 return fmt.Errorf("enums must be strings") 295 } 296 297 *e = MissingEnum(str) 298 if !e.IsValid() { 299 return fmt.Errorf("%s is not a valid MissingEnum", str) 300 } 301 return nil 302 } 303 304 func (e MissingEnum) MarshalGQL(w io.Writer) { 305 fmt.Fprint(w, strconv.Quote(e.String())) 306 }