github.com/opiuman/genqlient@v1.0.0/generate/testdata/snapshots/TestGenerate-PointersInline.graphql-PointersInline.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 err = testutil.UnmarshalDate( 156 src, dst) 157 if err != nil { 158 return fmt.Errorf( 159 "Unable to unmarshal UserQueryInput.Birthdate: %w", err) 160 } 161 } 162 } 163 return nil 164 } 165 166 type __premarshalUserQueryInput struct { 167 Email string `json:"email"` 168 169 Name string `json:"name"` 170 171 Id testutil.ID `json:"id"` 172 173 Role Role `json:"role"` 174 175 Names []string `json:"names"` 176 177 HasPokemon testutil.Pokemon `json:"hasPokemon"` 178 179 Birthdate json.RawMessage `json:"birthdate"` 180 } 181 182 func (v *UserQueryInput) MarshalJSON() ([]byte, error) { 183 premarshaled, err := v.__premarshalJSON() 184 if err != nil { 185 return nil, err 186 } 187 return json.Marshal(premarshaled) 188 } 189 190 func (v *UserQueryInput) __premarshalJSON() (*__premarshalUserQueryInput, error) { 191 var retval __premarshalUserQueryInput 192 193 retval.Email = v.Email 194 retval.Name = v.Name 195 retval.Id = v.Id 196 retval.Role = v.Role 197 retval.Names = v.Names 198 retval.HasPokemon = v.HasPokemon 199 { 200 201 dst := &retval.Birthdate 202 src := v.Birthdate 203 var err error 204 *dst, err = testutil.MarshalDate( 205 &src) 206 if err != nil { 207 return nil, fmt.Errorf( 208 "Unable to marshal UserQueryInput.Birthdate: %w", err) 209 } 210 } 211 return &retval, nil 212 } 213 214 // __PointersQueryInput is used internally by genqlient 215 type __PointersQueryInput struct { 216 Query *UserQueryInput `json:"query"` 217 Dt *time.Time `json:"dt"` 218 Tz string `json:"tz"` 219 } 220 221 // GetQuery returns __PointersQueryInput.Query, and is useful for accessing the field via an interface. 222 func (v *__PointersQueryInput) GetQuery() *UserQueryInput { return v.Query } 223 224 // GetDt returns __PointersQueryInput.Dt, and is useful for accessing the field via an interface. 225 func (v *__PointersQueryInput) GetDt() *time.Time { return v.Dt } 226 227 // GetTz returns __PointersQueryInput.Tz, and is useful for accessing the field via an interface. 228 func (v *__PointersQueryInput) GetTz() string { return v.Tz } 229 230 func PointersQuery( 231 client graphql.Client, 232 query *UserQueryInput, 233 dt *time.Time, 234 tz string, 235 ) (*PointersQueryResponse, error) { 236 req := &graphql.Request{ 237 OpName: "PointersQuery", 238 Query: ` 239 query PointersQuery ($query: UserQueryInput, $dt: DateTime, $tz: String) { 240 user(query: $query) { 241 id 242 roles 243 name 244 emails 245 emailsNoPtr: emails 246 } 247 otherUser: user(query: $query) { 248 id 249 } 250 maybeConvert(dt: $dt, tz: $tz) 251 } 252 `, 253 Variables: &__PointersQueryInput{ 254 Query: query, 255 Dt: dt, 256 Tz: tz, 257 }, 258 } 259 var err error 260 261 var data PointersQueryResponse 262 resp := &graphql.Response{Data: &data} 263 264 err = client.MakeRequest( 265 nil, 266 req, 267 resp, 268 ) 269 270 return &data, err 271 } 272