chore(legacy): relocate v1 dataconnect source
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
|
||||
mutation createUserConversation(
|
||||
$conversationId: UUID!
|
||||
$userId: String!
|
||||
$unreadCount: Int
|
||||
$lastReadAt: Timestamp
|
||||
) @auth(level: USER) {
|
||||
userConversation_insert(
|
||||
data: {
|
||||
conversationId: $conversationId
|
||||
userId: $userId
|
||||
unreadCount: $unreadCount
|
||||
lastReadAt: $lastReadAt
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
mutation updateUserConversation(
|
||||
$conversationId: UUID!
|
||||
$userId: String!
|
||||
$unreadCount: Int
|
||||
$lastReadAt: Timestamp
|
||||
) @auth(level: USER) {
|
||||
userConversation_update(
|
||||
key: { conversationId: $conversationId, userId: $userId }
|
||||
data: {
|
||||
unreadCount: $unreadCount
|
||||
lastReadAt: $lastReadAt
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# MARK AS READ (sets unreadCount=0 + lastReadAt=now)
|
||||
# Note: request.time is valid in schema defaults; in mutations
|
||||
# you can pass Timestamp from client. If you want "now" server-side,
|
||||
# you'd typically pass null and have logic elsewhere.
|
||||
# ----------------------------------------------------------
|
||||
mutation markConversationAsRead(
|
||||
$conversationId: UUID!
|
||||
$userId: String!
|
||||
$lastReadAt: Timestamp
|
||||
) @auth(level: USER) {
|
||||
userConversation_update(
|
||||
key: { conversationId: $conversationId, userId: $userId }
|
||||
data: {
|
||||
unreadCount: 0
|
||||
lastReadAt: $lastReadAt
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# INCREMENT UNREAD (common after sending message)
|
||||
# ----------------------------------------------------------
|
||||
mutation incrementUnreadForUser(
|
||||
$conversationId: UUID!
|
||||
$userId: String!
|
||||
$unreadCount: Int!
|
||||
) @auth(level: USER) {
|
||||
userConversation_update(
|
||||
key: { conversationId: $conversationId, userId: $userId }
|
||||
data: { unreadCount: $unreadCount }
|
||||
)
|
||||
}
|
||||
|
||||
mutation deleteUserConversation(
|
||||
$conversationId: UUID!
|
||||
$userId: String!
|
||||
) @auth(level: USER) {
|
||||
userConversation_delete(
|
||||
key: { conversationId: $conversationId, userId: $userId }
|
||||
)
|
||||
}
|
||||
230
legacy/dataconnect-v1/connector/userConversation/queries.gql
Normal file
230
legacy/dataconnect-v1/connector/userConversation/queries.gql
Normal file
@@ -0,0 +1,230 @@
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# LIST ALL (admin/debug)
|
||||
# ----------------------------------------------------------
|
||||
query listUserConversations(
|
||||
$offset: Int
|
||||
$limit: Int
|
||||
) @auth(level: USER) {
|
||||
userConversations(offset: $offset, limit: $limit) {
|
||||
id
|
||||
conversationId
|
||||
userId
|
||||
unreadCount
|
||||
lastReadAt
|
||||
createdAt
|
||||
|
||||
conversation {
|
||||
id
|
||||
subject
|
||||
status
|
||||
conversationType
|
||||
isGroup
|
||||
groupName
|
||||
lastMessage
|
||||
lastMessageAt
|
||||
createdAt
|
||||
}
|
||||
|
||||
user {
|
||||
id
|
||||
fullName
|
||||
photoUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# GET BY KEY (conversationId + userId)
|
||||
# ----------------------------------------------------------
|
||||
query getUserConversationByKey(
|
||||
$conversationId: UUID!
|
||||
$userId: String!
|
||||
) @auth(level: USER) {
|
||||
userConversation(key: { conversationId: $conversationId, userId: $userId }) {
|
||||
id
|
||||
conversationId
|
||||
userId
|
||||
unreadCount
|
||||
lastReadAt
|
||||
createdAt
|
||||
|
||||
conversation {
|
||||
id
|
||||
subject
|
||||
status
|
||||
conversationType
|
||||
isGroup
|
||||
groupName
|
||||
lastMessage
|
||||
lastMessageAt
|
||||
createdAt
|
||||
}
|
||||
|
||||
user {
|
||||
id
|
||||
fullName
|
||||
photoUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# LIST BY USER (My inbox) ✅
|
||||
# Order by most recent activity (Conversation.lastMessageAt)
|
||||
# NOTE: If your DC version doesn't allow orderBy on nested fields,
|
||||
# just orderBy createdAt/updatedAt on user_conversations.
|
||||
# ----------------------------------------------------------
|
||||
query listUserConversationsByUserId(
|
||||
$userId: String!
|
||||
$offset: Int
|
||||
$limit: Int
|
||||
) @auth(level: USER) {
|
||||
userConversations(
|
||||
where: { userId: { eq: $userId } }
|
||||
offset: $offset
|
||||
limit: $limit
|
||||
# If supported:
|
||||
# orderBy: { conversation: { lastMessageAt: DESC } }
|
||||
orderBy: { updatedAt: DESC }
|
||||
) {
|
||||
id
|
||||
conversationId
|
||||
userId
|
||||
unreadCount
|
||||
lastReadAt
|
||||
createdAt
|
||||
updatedAt
|
||||
createdBy
|
||||
|
||||
conversation {
|
||||
id
|
||||
subject
|
||||
status
|
||||
conversationType
|
||||
isGroup
|
||||
groupName
|
||||
lastMessage
|
||||
lastMessageAt
|
||||
createdAt
|
||||
}
|
||||
|
||||
user {
|
||||
id
|
||||
fullName
|
||||
photoUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# LIST UNREAD BY USER (badge, notifications)
|
||||
# ----------------------------------------------------------
|
||||
query listUnreadUserConversationsByUserId(
|
||||
$userId: String!
|
||||
$offset: Int
|
||||
$limit: Int
|
||||
) @auth(level: USER) {
|
||||
userConversations(
|
||||
where: {
|
||||
userId: { eq: $userId }
|
||||
unreadCount: { gt: 0 }
|
||||
}
|
||||
offset: $offset
|
||||
limit: $limit
|
||||
orderBy: { updatedAt: DESC }
|
||||
) {
|
||||
id
|
||||
conversationId
|
||||
userId
|
||||
unreadCount
|
||||
lastReadAt
|
||||
createdAt
|
||||
|
||||
conversation {
|
||||
id
|
||||
subject
|
||||
status
|
||||
conversationType
|
||||
isGroup
|
||||
groupName
|
||||
lastMessage
|
||||
lastMessageAt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# LIST BY CONVERSATION (participants view)
|
||||
# ----------------------------------------------------------
|
||||
query listUserConversationsByConversationId(
|
||||
$conversationId: UUID!
|
||||
$offset: Int
|
||||
$limit: Int
|
||||
) @auth(level: USER) {
|
||||
userConversations(
|
||||
where: { conversationId: { eq: $conversationId } }
|
||||
offset: $offset
|
||||
limit: $limit
|
||||
orderBy: { createdAt: ASC }
|
||||
) {
|
||||
id
|
||||
conversationId
|
||||
userId
|
||||
unreadCount
|
||||
lastReadAt
|
||||
createdAt
|
||||
|
||||
user {
|
||||
id
|
||||
fullName
|
||||
photoUrl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# FILTER (dashboard/debug)
|
||||
# ----------------------------------------------------------
|
||||
query filterUserConversations(
|
||||
$userId: String
|
||||
$conversationId: UUID
|
||||
$unreadMin: Int
|
||||
$unreadMax: Int
|
||||
$lastReadAfter: Timestamp
|
||||
$lastReadBefore: Timestamp
|
||||
$offset: Int
|
||||
$limit: Int
|
||||
) @auth(level: USER) {
|
||||
userConversations(
|
||||
where: {
|
||||
userId: { eq: $userId }
|
||||
conversationId: { eq: $conversationId }
|
||||
unreadCount: { ge: $unreadMin, le: $unreadMax }
|
||||
lastReadAt: { ge: $lastReadAfter, le: $lastReadBefore }
|
||||
}
|
||||
offset: $offset
|
||||
limit: $limit
|
||||
orderBy: { updatedAt: DESC }
|
||||
) {
|
||||
id
|
||||
conversationId
|
||||
userId
|
||||
unreadCount
|
||||
lastReadAt
|
||||
createdAt
|
||||
|
||||
conversation {
|
||||
id
|
||||
subject
|
||||
status
|
||||
conversationType
|
||||
isGroup
|
||||
groupName
|
||||
lastMessage
|
||||
lastMessageAt
|
||||
createdAt
|
||||
}
|
||||
user { id fullName photoUrl }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user