-
-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathitems.js
212 lines (200 loc) · 3.28 KB
/
items.js
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
import { gql } from '@apollo/client'
import { COMMENTS } from './comments'
// we can't import from users because of circular dependency
const STREAK_FIELDS = gql`
fragment StreakFields on User {
optional {
streak
gunStreak
horseStreak
}
}
`
export const ITEM_FIELDS = gql`
${STREAK_FIELDS}
fragment ItemFields on Item {
id
parentId
createdAt
invoicePaidAt
deletedAt
title
url
user {
id
name
meMute
...StreakFields
}
sub {
name
userId
moderated
meMuteSub
meSubscription
nsfw
baseCost
replyCost
}
otsHash
position
sats
credits
meAnonSats @client
boost
bounty
bountyPaidTo
noteId
path
upvotes
meSats
meCredits
meDontLikeSats
meBookmark
meSubscription
meForward
outlawed
freebie
bio
ncomments
nDirectComments
commentSats
commentCredits
lastCommentAt
isJob
status
company
location
remote
subName
pollCost
pollExpiresAt
uploadId
mine
imgproxyUrls
rel
apiKey
invoice {
id
actionState
confirmedAt
}
cost
}`
export const ITEM_FULL_FIELDS = gql`
${ITEM_FIELDS}
${STREAK_FIELDS}
fragment ItemFullFields on Item {
...ItemFields
text
root {
id
title
bounty
bountyPaidTo
subName
mine
ncomments
user {
id
name
...StreakFields
}
sub {
name
userId
moderated
meMuteSub
meSubscription
}
}
forwards {
userId
pct
user {
name
}
}
}`
export const ITEM_OTS_FIELDS = gql`
fragment ItemOtsFields on Item {
id
title
text
url
parentOtsHash
otsHash
deletedAt
}`
export const ITEM_OTS = gql`
${ITEM_OTS_FIELDS}
query Item($id: ID!) {
item(id: $id) {
...ItemOtsFields
}
}`
export const POLL_FIELDS = gql`
fragment PollFields on Item {
poll {
meVoted
meInvoiceId
meInvoiceActionState
count
options {
id
option
count
}
}
}`
export const ITEM = gql`
${ITEM_FULL_FIELDS}
${POLL_FIELDS}
query Item($id: ID!) {
item(id: $id) {
...ItemFullFields
...PollFields
}
}`
export const ITEM_FULL = gql`
${ITEM_FULL_FIELDS}
${POLL_FIELDS}
${COMMENTS}
query Item($id: ID!, $sort: String, $cursor: String) {
item(id: $id) {
...ItemFullFields
prior
...PollFields
comments(sort: $sort, cursor: $cursor) {
cursor
comments {
...CommentsRecursive
}
}
}
}`
export const RELATED_ITEMS = gql`
${ITEM_FIELDS}
query Related($title: String, $id: ID, $cursor: String, $limit: Limit) {
related(title: $title, id: $id, cursor: $cursor, limit: $limit) {
cursor
items {
...ItemFields
}
}
}
`
export const RELATED_ITEMS_WITH_ITEM = gql`
${ITEM_FIELDS}
query Related($title: String, $id: ID!, $cursor: String, $limit: Limit) {
item(id: $id) {
...ItemFields
}
related(title: $title, id: $id, cursor: $cursor, limit: $limit) {
cursor
items {
...ItemFields
}
}
}
`