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