1package github
2
3import (
4	"time"
5
6	"github.com/shurcooL/githubv4"
7)
8
9type Query struct {
10	Repository struct {
11		IssueConnection IssueConnection `graphql:"issues(first: $count, after: $issueCursor, filterBy: $filterBy)"`
12	} `graphql:"repository(owner: $owner, name: $name)"`
13}
14
15type QueryWithMilestone struct {
16	Repository struct {
17		Milestone struct {
18			IssueConnection IssueConnection `graphql:"issues(first: $count, after: $issueCursor, filterBy: $filterBy)"`
19		} `graphql:"milestone(number: $milestone)"`
20	} `graphql:"repository(owner: $owner, name: $name)"`
21}
22
23type IssueConnection struct {
24	Edges    []IssueEdge `graphql:"edges"`
25	PageInfo PageInfo    `graphql:"pageInfo"`
26}
27
28// PageInfo helps with the paging large query responses
29type PageInfo struct {
30	EndCursor   githubv4.String
31	HasNextPage bool
32}
33
34type IssueEdge struct {
35	Cursor string `graphql:"cursor"`
36	Node   Issue  `graphql:"node"`
37}
38
39type Issue struct {
40	ID        string    `graphql:"id"`
41	Number    int       `graphql:"number"`
42	Body      string    `graphql:"body"`
43	Title     string    `graphql:"title"`
44	Author    Author    `graphql:"author"`
45	Url       string    `graphql:"url"`
46	CreatedAt time.Time `graphql:"createdAt"`
47	Milestone Milestone `graphql:"milestone"`
48	State     string    `graphql:"state"`
49	Closed    bool      `graphql:"closed"`
50	ClosedAt  time.Time `graphql:"closedAt"`
51}
52
53type Author struct {
54	Name string `graphql:"login"`
55}
56
57type MilestoneQuery struct {
58	Repository struct {
59		Milestones MilestoneConnection `graphql:"milestones(first: 100, query: $query)"`
60	} `graphql:"repository(owner: $owner, name: $name)"`
61}
62
63type MilestoneConnection struct {
64	Edges    []MilestoneEdge `graphql:"edges"`
65	PageInfo PageInfo        `graphql:"pageInfo"`
66}
67
68type MilestoneEdge struct {
69	Cursor string    `graphql:"cursor"`
70	Node   Milestone `graphql:"node"`
71}
72
73type Milestone struct {
74	Description string
75	Number      int
76	Title       string
77}
78