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