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