new message entity
This commit is contained in:
39
dataconnect/connector/message/mutations.gql
Normal file
39
dataconnect/connector/message/mutations.gql
Normal 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)
|
||||||
|
}
|
||||||
39
dataconnect/connector/message/queries.gql
Normal file
39
dataconnect/connector/message/queries.gql
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
10
dataconnect/schema/message.gql
Normal file
10
dataconnect/schema/message.gql
Normal 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")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user