github.com/codykaup/genqlient@v0.6.2/generate/testdata/snapshots/TestGenerateWithConfig-StructReferences-testdata-queries-generated.go (about) 1 // Code generated by github.com/codykaup/genqlient, DO NOT EDIT. 2 3 package queries 4 5 import ( 6 "context" 7 "encoding/json" 8 "fmt" 9 "time" 10 11 "github.com/codykaup/genqlient/graphql" 12 "github.com/codykaup/genqlient/internal/testutil" 13 ) 14 15 // InputObjectQueryResponse is returned by InputObjectQuery on success. 16 type InputObjectQueryResponse struct { 17 // user looks up a user by some stuff. 18 // 19 // See UserQueryInput for what stuff is supported. 20 // If query is null, returns the current user. 21 User *InputObjectQueryUser `json:"user"` 22 } 23 24 // GetUser returns InputObjectQueryResponse.User, and is useful for accessing the field via an interface. 25 func (v *InputObjectQueryResponse) GetUser() *InputObjectQueryUser { return v.User } 26 27 // InputObjectQueryUser includes the requested fields of the GraphQL type User. 28 // The GraphQL type's documentation follows. 29 // 30 // A User is a user! 31 type InputObjectQueryUser struct { 32 // id is the user's ID. 33 // 34 // It is stable, unique, and opaque, like all good IDs. 35 Id string `json:"id"` 36 } 37 38 // GetId returns InputObjectQueryUser.Id, and is useful for accessing the field via an interface. 39 func (v *InputObjectQueryUser) GetId() string { return v.Id } 40 41 type PokemonInput struct { 42 Species string `json:"species"` 43 Level int `json:"level"` 44 } 45 46 // GetSpecies returns PokemonInput.Species, and is useful for accessing the field via an interface. 47 func (v *PokemonInput) GetSpecies() string { return v.Species } 48 49 // GetLevel returns PokemonInput.Level, and is useful for accessing the field via an interface. 50 func (v *PokemonInput) GetLevel() int { return v.Level } 51 52 // QueryWithStructsResponse is returned by QueryWithStructs on success. 53 type QueryWithStructsResponse struct { 54 // user looks up a user by some stuff. 55 // 56 // See UserQueryInput for what stuff is supported. 57 // If query is null, returns the current user. 58 User *QueryWithStructsUser `json:"user"` 59 } 60 61 // GetUser returns QueryWithStructsResponse.User, and is useful for accessing the field via an interface. 62 func (v *QueryWithStructsResponse) GetUser() *QueryWithStructsUser { return v.User } 63 64 // QueryWithStructsUser includes the requested fields of the GraphQL type User. 65 // The GraphQL type's documentation follows. 66 // 67 // A User is a user! 68 type QueryWithStructsUser struct { 69 AuthMethods []*QueryWithStructsUserAuthMethodsAuthMethod `json:"authMethods"` 70 } 71 72 // GetAuthMethods returns QueryWithStructsUser.AuthMethods, and is useful for accessing the field via an interface. 73 func (v *QueryWithStructsUser) GetAuthMethods() []*QueryWithStructsUserAuthMethodsAuthMethod { 74 return v.AuthMethods 75 } 76 77 // QueryWithStructsUserAuthMethodsAuthMethod includes the requested fields of the GraphQL type AuthMethod. 78 type QueryWithStructsUserAuthMethodsAuthMethod struct { 79 Provider string `json:"provider"` 80 Email string `json:"email"` 81 } 82 83 // GetProvider returns QueryWithStructsUserAuthMethodsAuthMethod.Provider, and is useful for accessing the field via an interface. 84 func (v *QueryWithStructsUserAuthMethodsAuthMethod) GetProvider() string { return v.Provider } 85 86 // GetEmail returns QueryWithStructsUserAuthMethodsAuthMethod.Email, and is useful for accessing the field via an interface. 87 func (v *QueryWithStructsUserAuthMethodsAuthMethod) GetEmail() string { return v.Email } 88 89 // Role is a type a user may have. 90 type Role string 91 92 const ( 93 // What is a student? 94 // 95 // 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. 96 // 97 // (from [Wikipedia](https://en.wikipedia.org/wiki/Student)) 98 RoleStudent Role = "STUDENT" 99 // Teacher is a teacher, who teaches the students. 100 RoleTeacher Role = "TEACHER" 101 ) 102 103 // UserQueryInput is the argument to Query.users. 104 // 105 // Ideally this would support anything and everything! 106 // Or maybe ideally it wouldn't. 107 // Really I'm just talking to make this documentation longer. 108 type UserQueryInput struct { 109 Email string `json:"email"` 110 Name string `json:"name"` 111 // id looks the user up by ID. It's a great way to look up users. 112 Id string `json:"id"` 113 Role Role `json:"role"` 114 Names []string `json:"names"` 115 HasPokemon *PokemonInput `json:"hasPokemon,omitempty"` 116 Birthdate time.Time `json:"-"` 117 } 118 119 // GetEmail returns UserQueryInput.Email, and is useful for accessing the field via an interface. 120 func (v *UserQueryInput) GetEmail() string { return v.Email } 121 122 // GetName returns UserQueryInput.Name, and is useful for accessing the field via an interface. 123 func (v *UserQueryInput) GetName() string { return v.Name } 124 125 // GetId returns UserQueryInput.Id, and is useful for accessing the field via an interface. 126 func (v *UserQueryInput) GetId() string { return v.Id } 127 128 // GetRole returns UserQueryInput.Role, and is useful for accessing the field via an interface. 129 func (v *UserQueryInput) GetRole() Role { return v.Role } 130 131 // GetNames returns UserQueryInput.Names, and is useful for accessing the field via an interface. 132 func (v *UserQueryInput) GetNames() []string { return v.Names } 133 134 // GetHasPokemon returns UserQueryInput.HasPokemon, and is useful for accessing the field via an interface. 135 func (v *UserQueryInput) GetHasPokemon() *PokemonInput { return v.HasPokemon } 136 137 // GetBirthdate returns UserQueryInput.Birthdate, and is useful for accessing the field via an interface. 138 func (v *UserQueryInput) GetBirthdate() time.Time { return v.Birthdate } 139 140 func (v *UserQueryInput) UnmarshalJSON(b []byte) error { 141 142 if string(b) == "null" { 143 return nil 144 } 145 146 var firstPass struct { 147 *UserQueryInput 148 Birthdate json.RawMessage `json:"birthdate"` 149 graphql.NoUnmarshalJSON 150 } 151 firstPass.UserQueryInput = v 152 153 err := json.Unmarshal(b, &firstPass) 154 if err != nil { 155 return err 156 } 157 158 { 159 dst := &v.Birthdate 160 src := firstPass.Birthdate 161 if len(src) != 0 && string(src) != "null" { 162 err = testutil.UnmarshalDate( 163 src, dst) 164 if err != nil { 165 return fmt.Errorf( 166 "unable to unmarshal UserQueryInput.Birthdate: %w", err) 167 } 168 } 169 } 170 return nil 171 } 172 173 type __premarshalUserQueryInput struct { 174 Email string `json:"email"` 175 176 Name string `json:"name"` 177 178 Id string `json:"id"` 179 180 Role Role `json:"role"` 181 182 Names []string `json:"names"` 183 184 HasPokemon *PokemonInput `json:"hasPokemon,omitempty"` 185 186 Birthdate json.RawMessage `json:"birthdate"` 187 } 188 189 func (v *UserQueryInput) MarshalJSON() ([]byte, error) { 190 premarshaled, err := v.__premarshalJSON() 191 if err != nil { 192 return nil, err 193 } 194 return json.Marshal(premarshaled) 195 } 196 197 func (v *UserQueryInput) __premarshalJSON() (*__premarshalUserQueryInput, error) { 198 var retval __premarshalUserQueryInput 199 200 retval.Email = v.Email 201 retval.Name = v.Name 202 retval.Id = v.Id 203 retval.Role = v.Role 204 retval.Names = v.Names 205 retval.HasPokemon = v.HasPokemon 206 { 207 208 dst := &retval.Birthdate 209 src := v.Birthdate 210 var err error 211 *dst, err = testutil.MarshalDate( 212 &src) 213 if err != nil { 214 return nil, fmt.Errorf( 215 "unable to marshal UserQueryInput.Birthdate: %w", err) 216 } 217 } 218 return &retval, nil 219 } 220 221 // __InputObjectQueryInput is used internally by genqlient 222 type __InputObjectQueryInput struct { 223 Query *UserQueryInput `json:"query,omitempty"` 224 } 225 226 // GetQuery returns __InputObjectQueryInput.Query, and is useful for accessing the field via an interface. 227 func (v *__InputObjectQueryInput) GetQuery() *UserQueryInput { return v.Query } 228 229 // The query or mutation executed by InputObjectQuery. 230 const InputObjectQuery_Operation = ` 231 query InputObjectQuery ($query: UserQueryInput) { 232 user(query: $query) { 233 id 234 } 235 } 236 ` 237 238 func InputObjectQuery( 239 ctx_ context.Context, 240 client_ graphql.Client, 241 query *UserQueryInput, 242 ) (*InputObjectQueryResponse, error) { 243 req_ := &graphql.Request{ 244 OpName: "InputObjectQuery", 245 Query: InputObjectQuery_Operation, 246 Variables: &__InputObjectQueryInput{ 247 Query: query, 248 }, 249 } 250 var err_ error 251 252 var data_ InputObjectQueryResponse 253 resp_ := &graphql.Response{Data: &data_} 254 255 err_ = client_.MakeRequest( 256 ctx_, 257 req_, 258 resp_, 259 ) 260 261 return &data_, err_ 262 } 263 264 // The query or mutation executed by QueryWithStructs. 265 const QueryWithStructs_Operation = ` 266 query QueryWithStructs { 267 user { 268 authMethods { 269 provider 270 email 271 } 272 } 273 } 274 ` 275 276 func QueryWithStructs( 277 ctx_ context.Context, 278 client_ graphql.Client, 279 ) (*QueryWithStructsResponse, error) { 280 req_ := &graphql.Request{ 281 OpName: "QueryWithStructs", 282 Query: QueryWithStructs_Operation, 283 } 284 var err_ error 285 286 var data_ QueryWithStructsResponse 287 resp_ := &graphql.Response{Data: &data_} 288 289 err_ = client_.MakeRequest( 290 ctx_, 291 req_, 292 resp_, 293 ) 294 295 return &data_, err_ 296 } 297