1package github
2
3import "github.com/shurcooL/githubv4"
4
5type userQuery struct {
6 RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
7 User user `graphql:"user(login: $login)"`
8}
9
10func (q *userQuery) rateLimit() rateLimit {
11 return q.RateLimit
12}
13
14type labelsQuery struct {
15 //RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
16 Repository struct {
17 Labels struct {
18 Nodes []struct {
19 ID string `graphql:"id"`
20 Name string `graphql:"name"`
21 Color string `graphql:"color"`
22 Description string `graphql:"description"`
23 }
24 PageInfo pageInfo
25 } `graphql:"labels(first: $first, after: $after)"`
26 } `graphql:"repository(owner: $owner, name: $name)"`
27}
28
29type loginQuery struct {
30 //RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
31 Viewer struct {
32 Login string `graphql:"login"`
33 } `graphql:"viewer"`
34}
35
36type issueQuery struct {
37 RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
38 Repository struct {
39 Issues issueConnection `graphql:"issues(first: $issueFirst, after: $issueAfter, orderBy: {field: CREATED_AT, direction: ASC}, filterBy: {since: $issueSince})"`
40 } `graphql:"repository(owner: $owner, name: $name)"`
41}
42
43func (q *issueQuery) rateLimit() rateLimit {
44 return q.RateLimit
45}
46
47type issueEditQuery struct {
48 RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
49 Node struct {
50 Typename githubv4.String `graphql:"__typename"`
51 Issue struct {
52 UserContentEdits userContentEditConnection `graphql:"userContentEdits(last: $issueEditLast, before: $issueEditBefore)"`
53 } `graphql:"... on Issue"`
54 } `graphql:"node(id: $gqlNodeId)"`
55}
56
57func (q *issueEditQuery) rateLimit() rateLimit {
58 return q.RateLimit
59}
60
61type timelineQuery struct {
62 RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
63 Node struct {
64 Typename githubv4.String `graphql:"__typename"`
65 Issue struct {
66 TimelineItems timelineItemsConnection `graphql:"timelineItems(first: $timelineFirst, after: $timelineAfter)"`
67 } `graphql:"... on Issue"`
68 } `graphql:"node(id: $gqlNodeId)"`
69}
70
71func (q *timelineQuery) rateLimit() rateLimit {
72 return q.RateLimit
73}
74
75type commentEditQuery struct {
76 RateLimit rateLimit `graphql:"rateLimit(dryRun: $dryRun)"`
77 Node struct {
78 Typename githubv4.String `graphql:"__typename"`
79 IssueComment struct {
80 UserContentEdits userContentEditConnection `graphql:"userContentEdits(last: $commentEditLast, before: $commentEditBefore)"`
81 } `graphql:"... on IssueComment"`
82 } `graphql:"node(id: $gqlNodeId)"`
83}
84
85func (q *commentEditQuery) rateLimit() rateLimit {
86 return q.RateLimit
87}
88
89type user struct {
90 Login githubv4.String
91 AvatarUrl githubv4.String
92 Name *githubv4.String
93}
94
95type issueConnection struct {
96 Nodes []issueNode
97 PageInfo pageInfo
98}
99
100type issueNode struct {
101 issue
102 UserContentEdits userContentEditConnection `graphql:"userContentEdits(last: $issueEditLast, before: $issueEditBefore)"`
103 TimelineItems timelineItemsConnection `graphql:"timelineItems(first: $timelineFirst, after: $timelineAfter)"`
104}
105
106type issue struct {
107 authorEvent
108 Title githubv4.String
109 Number githubv4.Int
110 Body githubv4.String
111 Url githubv4.URI
112}
113
114type timelineItemsConnection struct {
115 Nodes []timelineItem
116 PageInfo pageInfo
117}
118
119type userContentEditConnection struct {
120 Nodes []userContentEdit
121 PageInfo pageInfo
122}
123
124type userContentEdit struct {
125 Id githubv4.ID
126 CreatedAt githubv4.DateTime
127 UpdatedAt githubv4.DateTime
128 EditedAt githubv4.DateTime
129 Editor *actor
130 DeletedAt *githubv4.DateTime
131 DeletedBy *actor
132 Diff *githubv4.String
133}
134
135type timelineItem struct {
136 Typename githubv4.String `graphql:"__typename"`
137
138 // issue
139 IssueComment issueComment `graphql:"... on IssueComment"`
140
141 // Label
142 LabeledEvent struct {
143 actorEvent
144 Label struct {
145 // Color githubv4.String
146 Name githubv4.String
147 }
148 } `graphql:"... on LabeledEvent"`
149 UnlabeledEvent struct {
150 actorEvent
151 Label struct {
152 // Color githubv4.String
153 Name githubv4.String
154 }
155 } `graphql:"... on UnlabeledEvent"`
156
157 // Status
158 ClosedEvent struct {
159 actorEvent
160 // Url githubv4.URI
161 } `graphql:"... on ClosedEvent"`
162 ReopenedEvent struct {
163 actorEvent
164 } `graphql:"... on ReopenedEvent"`
165
166 // Title
167 RenamedTitleEvent struct {
168 actorEvent
169 CurrentTitle githubv4.String
170 PreviousTitle githubv4.String
171 } `graphql:"... on RenamedTitleEvent"`
172}
173
174type issueComment struct {
175 authorEvent // NOTE: contains Id
176 Body githubv4.String
177 Url githubv4.URI
178
179 UserContentEdits userContentEditConnection `graphql:"userContentEdits(last: $commentEditLast, before: $commentEditBefore)"`
180}
181
182type actor struct {
183 Typename githubv4.String `graphql:"__typename"`
184 Login githubv4.String
185 AvatarUrl githubv4.String
186 User struct {
187 Name *githubv4.String
188 Email githubv4.String
189 } `graphql:"... on User"`
190 Organization struct {
191 Name *githubv4.String
192 Email *githubv4.String
193 } `graphql:"... on Organization"`
194}
195
196type actorEvent struct {
197 Id githubv4.ID
198 CreatedAt githubv4.DateTime
199 Actor *actor
200}
201
202type authorEvent struct {
203 Id githubv4.ID
204 CreatedAt githubv4.DateTime
205 Author *actor
206}
207
208type pageInfo struct {
209 EndCursor githubv4.String
210 HasNextPage bool
211 StartCursor githubv4.String
212 HasPreviousPage bool
213}
214
215type rateLimit struct {
216 Cost githubv4.Int
217 Limit githubv4.Int
218 NodeCount githubv4.Int
219 Remaining githubv4.Int
220 ResetAt githubv4.DateTime
221 Used githubv4.Int
222}