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