Merge pull request #102 from Oloodi/101-backend-define-and-deploy-message-schema

new message entity
This commit is contained in:
José Salazar
2025-11-26 13:27:41 -05:00
committed by GitHub
3 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
mutation CreateMessage(
$conversationId: UUID!,
$senderName: String!,
$content: String!,
$readBy: String
) @auth(level: USER) {
message_insert(
data: {
conversationId: $conversationId
senderName: $senderName
content: $content
readBy: $readBy
}
)
}
mutation UpdateMessage(
$id: UUID!,
$conversationId: UUID,
$senderName: String,
$content: String,
$readBy: String
) @auth(level: USER) {
message_update(
id: $id,
data: {
conversationId: $conversationId
senderName: $senderName
content: $content
readBy: $readBy
}
)
}
mutation DeleteMessage(
$id: UUID!
) @auth(level: USER) {
message_delete(id: $id)
}

View File

@@ -0,0 +1,39 @@
query listMessage @auth(level: USER) {
messages {
id
conversationId
senderName
content
readBy
}
}
query getMessageById(
$id: UUID!
) @auth(level: USER) {
message(id: $id) {
id
conversationId
senderName
content
readBy
}
}
query filterMessage(
$conversationId: UUID,
$senderName: String
) @auth(level: USER) {
messages(
where: {
conversationId: { eq: $conversationId }
senderName: { eq: $senderName }
}
) {
id
conversationId
senderName
content
readBy
}
}

View File

@@ -0,0 +1,10 @@
type Message @table(name: "messages") {
id: UUID! @default(expr: "uuidV4()")
conversationId: UUID! # conversation_id (FK lógica a Conversation.id)
senderName: String!
content: String!
readBy: String # read_by (jsonb -> String, array de user IDs)
createdDate: Timestamp @default(expr: "request.time")
updatedDate: Timestamp @default(expr: "request.time")
createdBy: String @default(expr: "auth.uid")
}