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