-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerated.go
327 lines (274 loc) · 11.6 KB
/
generated.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
// Code generated by github.com/Khan/genqlient, DO NOT EDIT.
package main
import (
"context"
"encoding/json"
"fmt"
"github.com/Khan/genqlient/graphql"
)
type UpdatesSinceErrorCode string
const (
UpdatesSinceErrorCodeUnauthorized UpdatesSinceErrorCode = "UNAUTHORIZED"
)
// __getUpdatesInput is used internally by genqlient
type __getUpdatesInput struct {
Since string `json:"since"`
After string `json:"after"`
}
// GetSince returns __getUpdatesInput.Since, and is useful for accessing the field via an interface.
func (v *__getUpdatesInput) GetSince() string { return v.Since }
// GetAfter returns __getUpdatesInput.After, and is useful for accessing the field via an interface.
func (v *__getUpdatesInput) GetAfter() string { return v.After }
// getUpdatesResponse is returned by getUpdates on success.
type getUpdatesResponse struct {
UpdatesSince getUpdatesUpdatesSinceUpdatesSinceResult `json:"-"`
}
// GetUpdatesSince returns getUpdatesResponse.UpdatesSince, and is useful for accessing the field via an interface.
func (v *getUpdatesResponse) GetUpdatesSince() getUpdatesUpdatesSinceUpdatesSinceResult {
return v.UpdatesSince
}
func (v *getUpdatesResponse) UnmarshalJSON(b []byte) error {
if string(b) == "null" {
return nil
}
var firstPass struct {
*getUpdatesResponse
UpdatesSince json.RawMessage `json:"updatesSince"`
graphql.NoUnmarshalJSON
}
firstPass.getUpdatesResponse = v
err := json.Unmarshal(b, &firstPass)
if err != nil {
return err
}
{
dst := &v.UpdatesSince
src := firstPass.UpdatesSince
if len(src) != 0 && string(src) != "null" {
err = __unmarshalgetUpdatesUpdatesSinceUpdatesSinceResult(
src, dst)
if err != nil {
return fmt.Errorf(
"unable to unmarshal getUpdatesResponse.UpdatesSince: %w", err)
}
}
}
return nil
}
type __premarshalgetUpdatesResponse struct {
UpdatesSince json.RawMessage `json:"updatesSince"`
}
func (v *getUpdatesResponse) MarshalJSON() ([]byte, error) {
premarshaled, err := v.__premarshalJSON()
if err != nil {
return nil, err
}
return json.Marshal(premarshaled)
}
func (v *getUpdatesResponse) __premarshalJSON() (*__premarshalgetUpdatesResponse, error) {
var retval __premarshalgetUpdatesResponse
{
dst := &retval.UpdatesSince
src := v.UpdatesSince
var err error
*dst, err = __marshalgetUpdatesUpdatesSinceUpdatesSinceResult(
&src)
if err != nil {
return nil, fmt.Errorf(
"unable to marshal getUpdatesResponse.UpdatesSince: %w", err)
}
}
return &retval, nil
}
// getUpdatesUpdatesSinceUpdatesSinceError includes the requested fields of the GraphQL type UpdatesSinceError.
type getUpdatesUpdatesSinceUpdatesSinceError struct {
Typename string `json:"__typename"`
ErrorCodes []UpdatesSinceErrorCode `json:"errorCodes"`
}
// GetTypename returns getUpdatesUpdatesSinceUpdatesSinceError.Typename, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceError) GetTypename() string { return v.Typename }
// GetErrorCodes returns getUpdatesUpdatesSinceUpdatesSinceError.ErrorCodes, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceError) GetErrorCodes() []UpdatesSinceErrorCode {
return v.ErrorCodes
}
// getUpdatesUpdatesSinceUpdatesSinceResult includes the requested fields of the GraphQL interface UpdatesSinceResult.
//
// getUpdatesUpdatesSinceUpdatesSinceResult is implemented by the following types:
// getUpdatesUpdatesSinceUpdatesSinceError
// getUpdatesUpdatesSinceUpdatesSinceSuccess
type getUpdatesUpdatesSinceUpdatesSinceResult interface {
implementsGraphQLInterfacegetUpdatesUpdatesSinceUpdatesSinceResult()
// GetTypename returns the receiver's concrete GraphQL type-name (see interface doc for possible values).
GetTypename() string
}
func (v *getUpdatesUpdatesSinceUpdatesSinceError) implementsGraphQLInterfacegetUpdatesUpdatesSinceUpdatesSinceResult() {
}
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccess) implementsGraphQLInterfacegetUpdatesUpdatesSinceUpdatesSinceResult() {
}
func __unmarshalgetUpdatesUpdatesSinceUpdatesSinceResult(b []byte, v *getUpdatesUpdatesSinceUpdatesSinceResult) error {
if string(b) == "null" {
return nil
}
var tn struct {
TypeName string `json:"__typename"`
}
err := json.Unmarshal(b, &tn)
if err != nil {
return err
}
switch tn.TypeName {
case "UpdatesSinceError":
*v = new(getUpdatesUpdatesSinceUpdatesSinceError)
return json.Unmarshal(b, *v)
case "UpdatesSinceSuccess":
*v = new(getUpdatesUpdatesSinceUpdatesSinceSuccess)
return json.Unmarshal(b, *v)
case "":
return fmt.Errorf(
"response was missing UpdatesSinceResult.__typename")
default:
return fmt.Errorf(
`unexpected concrete type for getUpdatesUpdatesSinceUpdatesSinceResult: "%v"`, tn.TypeName)
}
}
func __marshalgetUpdatesUpdatesSinceUpdatesSinceResult(v *getUpdatesUpdatesSinceUpdatesSinceResult) ([]byte, error) {
var typename string
switch v := (*v).(type) {
case *getUpdatesUpdatesSinceUpdatesSinceError:
typename = "UpdatesSinceError"
result := struct {
TypeName string `json:"__typename"`
*getUpdatesUpdatesSinceUpdatesSinceError
}{typename, v}
return json.Marshal(result)
case *getUpdatesUpdatesSinceUpdatesSinceSuccess:
typename = "UpdatesSinceSuccess"
result := struct {
TypeName string `json:"__typename"`
*getUpdatesUpdatesSinceUpdatesSinceSuccess
}{typename, v}
return json.Marshal(result)
case nil:
return []byte("null"), nil
default:
return nil, fmt.Errorf(
`unexpected concrete type for getUpdatesUpdatesSinceUpdatesSinceResult: "%T"`, v)
}
}
// getUpdatesUpdatesSinceUpdatesSinceSuccess includes the requested fields of the GraphQL type UpdatesSinceSuccess.
type getUpdatesUpdatesSinceUpdatesSinceSuccess struct {
Typename string `json:"__typename"`
Edges []getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdge `json:"edges"`
PageInfo getUpdatesUpdatesSinceUpdatesSinceSuccessPageInfo `json:"pageInfo"`
}
// GetTypename returns getUpdatesUpdatesSinceUpdatesSinceSuccess.Typename, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccess) GetTypename() string { return v.Typename }
// GetEdges returns getUpdatesUpdatesSinceUpdatesSinceSuccess.Edges, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccess) GetEdges() []getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdge {
return v.Edges
}
// GetPageInfo returns getUpdatesUpdatesSinceUpdatesSinceSuccess.PageInfo, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccess) GetPageInfo() getUpdatesUpdatesSinceUpdatesSinceSuccessPageInfo {
return v.PageInfo
}
// getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdge includes the requested fields of the GraphQL type SyncUpdatedItemEdge.
type getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdge struct {
Node getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem `json:"node"`
}
// GetNode returns getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdge.Node, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdge) GetNode() getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem {
return v.Node
}
// getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem includes the requested fields of the GraphQL type SearchItem.
type getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem struct {
Url string `json:"url"`
Title string `json:"title"`
Highlights []getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItemHighlightsHighlight `json:"highlights"`
}
// GetUrl returns getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem.Url, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem) GetUrl() string {
return v.Url
}
// GetTitle returns getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem.Title, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem) GetTitle() string {
return v.Title
}
// GetHighlights returns getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem.Highlights, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItem) GetHighlights() []getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItemHighlightsHighlight {
return v.Highlights
}
// getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItemHighlightsHighlight includes the requested fields of the GraphQL type Highlight.
type getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItemHighlightsHighlight struct {
Quote string `json:"quote"`
Annotation string `json:"annotation"`
}
// GetQuote returns getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItemHighlightsHighlight.Quote, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItemHighlightsHighlight) GetQuote() string {
return v.Quote
}
// GetAnnotation returns getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItemHighlightsHighlight.Annotation, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccessEdgesSyncUpdatedItemEdgeNodeSearchItemHighlightsHighlight) GetAnnotation() string {
return v.Annotation
}
// getUpdatesUpdatesSinceUpdatesSinceSuccessPageInfo includes the requested fields of the GraphQL type PageInfo.
type getUpdatesUpdatesSinceUpdatesSinceSuccessPageInfo struct {
HasNextPage bool `json:"hasNextPage"`
EndCursor string `json:"endCursor"`
}
// GetHasNextPage returns getUpdatesUpdatesSinceUpdatesSinceSuccessPageInfo.HasNextPage, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccessPageInfo) GetHasNextPage() bool {
return v.HasNextPage
}
// GetEndCursor returns getUpdatesUpdatesSinceUpdatesSinceSuccessPageInfo.EndCursor, and is useful for accessing the field via an interface.
func (v *getUpdatesUpdatesSinceUpdatesSinceSuccessPageInfo) GetEndCursor() string { return v.EndCursor }
// The query or mutation executed by getUpdates.
const getUpdates_Operation = `
query getUpdates ($since: Date!, $after: String!) {
updatesSince(sort: {by:UPDATED_TIME,order:DESCENDING}, since: $since, after: $after) {
__typename
... on UpdatesSinceSuccess {
edges {
node {
url
title
highlights {
quote
annotation
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
... on UpdatesSinceError {
errorCodes
}
}
}
`
func getUpdates(
ctx_ context.Context,
client_ graphql.Client,
since string,
after string,
) (*getUpdatesResponse, error) {
req_ := &graphql.Request{
OpName: "getUpdates",
Query: getUpdates_Operation,
Variables: &__getUpdatesInput{
Since: since,
After: after,
},
}
var err_ error
var data_ getUpdatesResponse
resp_ := &graphql.Response{Data: &data_}
err_ = client_.MakeRequest(
ctx_,
req_,
resp_,
)
return &data_, err_
}