github.com/codykaup/genqlient@v0.6.2/generate/testdata/snapshots/TestGenerate-Omitempty.graphql-Omitempty.graphql.go (about) 1 // Code generated by github.com/codykaup/genqlient, DO NOT EDIT. 2 3 package test 4 5 import ( 6 "encoding/json" 7 "fmt" 8 "time" 9 10 "github.com/codykaup/genqlient/graphql" 11 "github.com/codykaup/genqlient/internal/testutil" 12 ) 13 14 // OmitEmptyQueryResponse is returned by OmitEmptyQuery on success. 15 type OmitEmptyQueryResponse struct { 16 // user looks up a user by some stuff. 17 // 18 // See UserQueryInput for what stuff is supported. 19 // If query is null, returns the current user. 20 User OmitEmptyQueryUser `json:"user"` 21 Users []OmitEmptyQueryUsersUser `json:"users"` 22 MaybeConvert time.Time `json:"maybeConvert"` 23 Convert2 time.Time `json:"convert2"` 24 } 25 26 // GetUser returns OmitEmptyQueryResponse.User, and is useful for accessing the field via an interface. 27 func (v *OmitEmptyQueryResponse) GetUser() OmitEmptyQueryUser { return v.User } 28 29 // GetUsers returns OmitEmptyQueryResponse.Users, and is useful for accessing the field via an interface. 30 func (v *OmitEmptyQueryResponse) GetUsers() []OmitEmptyQueryUsersUser { return v.Users } 31 32 // GetMaybeConvert returns OmitEmptyQueryResponse.MaybeConvert, and is useful for accessing the field via an interface. 33 func (v *OmitEmptyQueryResponse) GetMaybeConvert() time.Time { return v.MaybeConvert } 34 35 // GetConvert2 returns OmitEmptyQueryResponse.Convert2, and is useful for accessing the field via an interface. 36 func (v *OmitEmptyQueryResponse) GetConvert2() time.Time { return v.Convert2 } 37 38 // OmitEmptyQueryUser includes the requested fields of the GraphQL type User. 39 // The GraphQL type's documentation follows. 40 // 41 // A User is a user! 42 type OmitEmptyQueryUser struct { 43 // id is the user's ID. 44 // 45 // It is stable, unique, and opaque, like all good IDs. 46 Id testutil.ID `json:"id"` 47 } 48 49 // GetId returns OmitEmptyQueryUser.Id, and is useful for accessing the field via an interface. 50 func (v *OmitEmptyQueryUser) GetId() testutil.ID { return v.Id } 51 52 // OmitEmptyQueryUsersUser includes the requested fields of the GraphQL type User. 53 // The GraphQL type's documentation follows. 54 // 55 // A User is a user! 56 type OmitEmptyQueryUsersUser struct { 57 // id is the user's ID. 58 // 59 // It is stable, unique, and opaque, like all good IDs. 60 Id testutil.ID `json:"id"` 61 } 62 63 // GetId returns OmitEmptyQueryUsersUser.Id, and is useful for accessing the field via an interface. 64 func (v *OmitEmptyQueryUsersUser) GetId() testutil.ID { return v.Id } 65 66 // Role is a type a user may have. 67 type Role string 68 69 const ( 70 // What is a student? 71 // 72 // A student is primarily a person enrolled in a school or other educational institution and who is under learning with goals of acquiring knowledge, developing professions and achieving employment at desired field. In the broader sense, a student is anyone who applies themselves to the intensive intellectual engagement with some matter necessary to master it as part of some practical affair in which such mastery is basic or decisive. 73 // 74 // (from [Wikipedia](https://en.wikipedia.org/wiki/Student)) 75 RoleStudent Role = "STUDENT" 76 // Teacher is a teacher, who teaches the students. 77 RoleTeacher Role = "TEACHER" 78 ) 79 80 // UserQueryInput is the argument to Query.users. 81 // 82 // Ideally this would support anything and everything! 83 // Or maybe ideally it wouldn't. 84 // Really I'm just talking to make this documentation longer. 85 type UserQueryInput struct { 86 Email string `json:"email,omitempty"` 87 Name string `json:"name,omitempty"` 88 // id looks the user up by ID. It's a great way to look up users. 89 Id testutil.ID `json:"id"` 90 Role Role `json:"role,omitempty"` 91 Names []string `json:"names,omitempty"` 92 HasPokemon testutil.Pokemon `json:"hasPokemon,omitempty"` 93 Birthdate time.Time `json:"-"` 94 } 95 96 // GetEmail returns UserQueryInput.Email, and is useful for accessing the field via an interface. 97 func (v *UserQueryInput) GetEmail() string { return v.Email } 98 99 // GetName returns UserQueryInput.Name, and is useful for accessing the field via an interface. 100 func (v *UserQueryInput) GetName() string { return v.Name } 101 102 // GetId returns UserQueryInput.Id, and is useful for accessing the field via an interface. 103 func (v *UserQueryInput) GetId() testutil.ID { return v.Id } 104 105 // GetRole returns UserQueryInput.Role, and is useful for accessing the field via an interface. 106 func (v *UserQueryInput) GetRole() Role { return v.Role } 107 108 // GetNames returns UserQueryInput.Names, and is useful for accessing the field via an interface. 109 func (v *UserQueryInput) GetNames() []string { return v.Names } 110 111 // GetHasPokemon returns UserQueryInput.HasPokemon, and is useful for accessing the field via an interface. 112 func (v *UserQueryInput) GetHasPokemon() testutil.Pokemon { return v.HasPokemon } 113 114 // GetBirthdate returns UserQueryInput.Birthdate, and is useful for accessing the field via an interface. 115 func (v *UserQueryInput) GetBirthdate() time.Time { return v.Birthdate } 116 117 func (v *UserQueryInput) UnmarshalJSON(b []byte) error { 118 119 if string(b) == "null" { 120 return nil 121 } 122 123 var firstPass struct { 124 *UserQueryInput 125 Birthdate json.RawMessage `json:"birthdate"` 126 graphql.NoUnmarshalJSON 127 } 128 firstPass.UserQueryInput = v 129 130 err := json.Unmarshal(b, &firstPass) 131 if err != nil { 132 return err 133 } 134 135 { 136 dst := &v.Birthdate 137 src := firstPass.Birthdate 138 if len(src) != 0 && string(src) != "null" { 139 err = testutil.UnmarshalDate( 140 src, dst) 141 if err != nil { 142 return fmt.Errorf( 143 "unable to unmarshal UserQueryInput.Birthdate: %w", err) 144 } 145 } 146 } 147 return nil 148 } 149 150 type __premarshalUserQueryInput struct { 151 Email string `json:"email,omitempty"` 152 153 Name string `json:"name,omitempty"` 154 155 Id testutil.ID `json:"id"` 156 157 Role Role `json:"role,omitempty"` 158 159 Names []string `json:"names,omitempty"` 160 161 HasPokemon testutil.Pokemon `json:"hasPokemon,omitempty"` 162 163 Birthdate json.RawMessage `json:"birthdate,omitempty"` 164 } 165 166 func (v *UserQueryInput) MarshalJSON() ([]byte, error) { 167 premarshaled, err := v.__premarshalJSON() 168 if err != nil { 169 return nil, err 170 } 171 return json.Marshal(premarshaled) 172 } 173 174 func (v *UserQueryInput) __premarshalJSON() (*__premarshalUserQueryInput, error) { 175 var retval __premarshalUserQueryInput 176 177 retval.Email = v.Email 178 retval.Name = v.Name 179 retval.Id = v.Id 180 retval.Role = v.Role 181 retval.Names = v.Names 182 retval.HasPokemon = v.HasPokemon 183 { 184 185 dst := &retval.Birthdate 186 src := v.Birthdate 187 var err error 188 *dst, err = testutil.MarshalDate( 189 &src) 190 if err != nil { 191 return nil, fmt.Errorf( 192 "unable to marshal UserQueryInput.Birthdate: %w", err) 193 } 194 } 195 return &retval, nil 196 } 197 198 // __OmitEmptyQueryInput is used internally by genqlient 199 type __OmitEmptyQueryInput struct { 200 Query UserQueryInput `json:"query,omitempty"` 201 Queries []UserQueryInput `json:"queries,omitempty"` 202 Dt time.Time `json:"dt,omitempty"` 203 Tz string `json:"tz,omitempty"` 204 TzNoOmitEmpty string `json:"tzNoOmitEmpty"` 205 } 206 207 // GetQuery returns __OmitEmptyQueryInput.Query, and is useful for accessing the field via an interface. 208 func (v *__OmitEmptyQueryInput) GetQuery() UserQueryInput { return v.Query } 209 210 // GetQueries returns __OmitEmptyQueryInput.Queries, and is useful for accessing the field via an interface. 211 func (v *__OmitEmptyQueryInput) GetQueries() []UserQueryInput { return v.Queries } 212 213 // GetDt returns __OmitEmptyQueryInput.Dt, and is useful for accessing the field via an interface. 214 func (v *__OmitEmptyQueryInput) GetDt() time.Time { return v.Dt } 215 216 // GetTz returns __OmitEmptyQueryInput.Tz, and is useful for accessing the field via an interface. 217 func (v *__OmitEmptyQueryInput) GetTz() string { return v.Tz } 218 219 // GetTzNoOmitEmpty returns __OmitEmptyQueryInput.TzNoOmitEmpty, and is useful for accessing the field via an interface. 220 func (v *__OmitEmptyQueryInput) GetTzNoOmitEmpty() string { return v.TzNoOmitEmpty } 221 222 // The query or mutation executed by OmitEmptyQuery. 223 const OmitEmptyQuery_Operation = ` 224 query OmitEmptyQuery ($query: UserQueryInput, $queries: [UserQueryInput], $dt: DateTime, $tz: String, $tzNoOmitEmpty: String) { 225 user(query: $query) { 226 id 227 } 228 users(query: $queries) { 229 id 230 } 231 maybeConvert(dt: $dt, tz: $tz) 232 convert2: maybeConvert(dt: $dt, tz: $tzNoOmitEmpty) 233 } 234 ` 235 236 func OmitEmptyQuery( 237 client_ graphql.Client, 238 query UserQueryInput, 239 queries []UserQueryInput, 240 dt time.Time, 241 tz string, 242 tzNoOmitEmpty string, 243 ) (*OmitEmptyQueryResponse, error) { 244 req_ := &graphql.Request{ 245 OpName: "OmitEmptyQuery", 246 Query: OmitEmptyQuery_Operation, 247 Variables: &__OmitEmptyQueryInput{ 248 Query: query, 249 Queries: queries, 250 Dt: dt, 251 Tz: tz, 252 TzNoOmitEmpty: tzNoOmitEmpty, 253 }, 254 } 255 var err_ error 256 257 var data_ OmitEmptyQueryResponse 258 resp_ := &graphql.Response{Data: &data_} 259 260 err_ = client_.MakeRequest( 261 nil, 262 req_, 263 resp_, 264 ) 265 266 return &data_, err_ 267 } 268