-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraphql_query_templates.py
144 lines (132 loc) · 2.39 KB
/
graphql_query_templates.py
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
from string import Template
# The following templates are used to generate the GraphQL queries.
add_comment_template = Template("""
addComment(input: { subjectId: "$issue_id", body: "$comment_body" }) {
commentEdge {
node {
id
body
}
}
}
""")
create_issue_template = Template("""
createIssue(input: { repositoryId: "$repo_id", title: "$title", body: "$body" }) {
issue {
id
number
}
}
""")
find_repo_id_template = Template("""
repository(owner: "$owner", name: "$repo") {
id
}
""")
main_query_template = Template("""
search(
first: 100
query: "repo:$repo is:issue updated:>=$timestamp"
type: ISSUE
after: $cursor
) {
pageInfo {
endCursor
hasNextPage
}
nodes {
... on Issue {
title
id
url
number
body
createdAt
author {
login
}
lastEditedAt
editor {
login
}
comments(first: 100) {
pageInfo {
endCursor
hasNextPage
}
nodes {
author {
login
}
url
createdAt
lastEditedAt
body
editor {
login
}
}
}
}
}
}
""")
read_comments_template = Template("""
resource(url: "$url") {
... on Issue {
comments(first:100, after: "$cursor") {
pageInfo {
endCursor
hasNextPage
}
nodes{
author {
login
}
url
createdAt
lastEditedAt
body
editor {
login
}
}
}
}
}
""")
read_last_comment_template = Template("""
node(id: "$issue_id") {
... on Issue {
comments(last: 1) {
nodes {
createdAt
}
}
}
}
""")
update_issue_template = Template("""
updateIssue(input: {id: "$issue_id", body: "$issue_body"}) {
issue {
id
}
}
""")
check_lock_state_template = Template("""
node(id: "$issue_id") {
... on Lockable {
locked
}
}
""")
lock_issue_template = Template("""
lockLockable(input: {lockableId: "$issue_id", lockReason: null, clientMutationId: null}) {
clientMutationId
}
""")
unlock_issue_template = Template("""
unlockLockable(input: {lockableId: "$issue_id", clientMutationId: null} ) {
clientMutationId
}
""")