forked from rinafcode/teachLink_web
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubscriptionQueries.ts
More file actions
280 lines (265 loc) · 4.81 KB
/
Copy pathsubscriptionQueries.ts
File metadata and controls
280 lines (265 loc) · 4.81 KB
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
/**
* Example GraphQL Subscriptions
* Common subscription queries for TeachLink real-time features
*/
import { gql } from '@apollo/client';
/**
* Subscribe to new posts in a topic
*/
export const NEW_POSTS_SUBSCRIPTION = gql`
subscription OnNewPosts($topicId: ID!) {
onNewPost(topicId: $topicId) {
id
title
content
author {
id
username
avatar
}
createdAt
likes
comments
}
}
`;
/**
* Subscribe to post comments
*/
export const POST_COMMENTS_SUBSCRIPTION = gql`
subscription OnPostComments($postId: ID!) {
onPostComment(postId: $postId) {
id
content
author {
id
username
avatar
}
createdAt
likes
replies {
id
content
author {
id
username
}
createdAt
}
}
}
`;
/**
* Subscribe to user notifications
*/
export const USER_NOTIFICATIONS_SUBSCRIPTION = gql`
subscription OnUserNotifications($userId: ID!) {
onNotification(userId: $userId) {
id
type
title
message
data {
postId
userId
commentId
}
read
createdAt
}
}
`;
/**
* Subscribe to tipping updates
*/
export const TIPPING_UPDATES_SUBSCRIPTION = gql`
subscription OnTippingUpdates($recipientId: ID!) {
onTip(recipientId: $recipientId) {
id
sender {
id
username
avatar
}
amount
currency
message
transactionHash
status
createdAt
}
}
`;
/**
* Subscribe to reputation updates
*/
export const REPUTATION_UPDATES_SUBSCRIPTION = gql`
subscription OnReputationUpdates($userId: ID!) {
onReputationChange(userId: $userId) {
currentReputation
previousReputation
change
reason
badge
timestamp
}
}
`;
/**
* Subscribe to live user activity
*/
export const USER_ACTIVITY_SUBSCRIPTION = gql`
subscription OnUserActivity($userId: ID!) {
onUserActivityUpdate(userId: $userId) {
userId
status
lastActiveAt
currentPostId
currentTopicId
}
}
`;
/**
* Subscribe to study group updates
*/
export const STUDY_GROUP_UPDATES_SUBSCRIPTION = gql`
subscription OnStudyGroupUpdates($groupId: ID!) {
onStudyGroupUpdate(groupId: $groupId) {
id
name
members {
id
username
avatar
status
}
messages {
id
author {
id
username
}
content
createdAt
}
updatedAt
}
}
`;
/**
* Subscribe to live quiz responses
*/
export const LIVE_QUIZ_RESPONSES_SUBSCRIPTION = gql`
subscription OnLiveQuizResponses($quizId: ID!) {
onQuizResponse(quizId: $quizId) {
id
userId
username
answer
correct
timeSpent
submittedAt
}
}
`;
/**
* Subscribe to real-time search results
*/
export const SEARCH_RESULTS_SUBSCRIPTION = gql`
subscription OnSearchResults($query: String!, $filters: SearchFilters) {
onSearchResults(query: $query, filters: $filters) {
id
title
type
relevanceScore
highlight
author {
id
username
}
}
}
`;
/**
* Subscribe to feed updates
*/
export const FEED_UPDATES_SUBSCRIPTION = gql`
subscription OnFeedUpdates($userId: ID!, $limit: Int = 20) {
onFeedUpdate(userId: $userId, limit: $limit) {
items {
id
type
content {
id
title
author {
id
username
avatar
}
likes
comments
createdAt
}
}
totalCount
hasMore
}
}
`;
/**
* Subscribe to typing indicators
*/
export const TYPING_INDICATOR_SUBSCRIPTION = gql`
subscription OnTypingIndicator($conversationId: ID!) {
onTyping(conversationId: $conversationId) {
userId
username
isTyping
}
}
`;
/**
* Subscribe to message delivery status
*/
export const MESSAGE_STATUS_SUBSCRIPTION = gql`
subscription OnMessageStatus($senderId: ID!) {
onMessageStatusUpdate(senderId: $senderId) {
messageId
status
deliveredAt
readAt
recipientId
}
}
`;
/**
* Subscribe to blockchain transaction updates
*/
export const BLOCKCHAIN_TRANSACTION_SUBSCRIPTION = gql`
subscription OnTransactionUpdate($transactionHash: String!) {
onTransactionStatusUpdate(transactionHash: $transactionHash) {
transactionHash
status
confirmations
blockNumber
gasUsed
timestamp
}
}
`;
/**
* Subscribe to presence updates (who's online)
*/
export const PRESENCE_SUBSCRIPTION = gql`
subscription OnPresenceUpdates {
onPresenceChange {
userId
username
status
lastSeen
location
}
}
`;