Merge pull request #104 from Oloodi/103-backend-define-and-deploy-activitylog-schema
new activityLog entity
This commit is contained in:
43
dataconnect/connector/activityLog/mutations.gql
Normal file
43
dataconnect/connector/activityLog/mutations.gql
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
mutation CreateActivityLog(
|
||||||
|
$title: String!,
|
||||||
|
$description: String!,
|
||||||
|
$activityType: ActivityType!,
|
||||||
|
$userId: UUID!,
|
||||||
|
$isRead: Boolean
|
||||||
|
) @auth(level: USER) {
|
||||||
|
activityLog_insert(
|
||||||
|
data: {
|
||||||
|
title: $title
|
||||||
|
description: $description
|
||||||
|
activityType: $activityType
|
||||||
|
userId: $userId
|
||||||
|
isRead: $isRead
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
mutation UpdateActivityLog(
|
||||||
|
$id: UUID!,
|
||||||
|
$title: String,
|
||||||
|
$description: String,
|
||||||
|
$activityType: ActivityType,
|
||||||
|
$userId: UUID,
|
||||||
|
$isRead: Boolean
|
||||||
|
) @auth(level: USER) {
|
||||||
|
activityLog_update(
|
||||||
|
id: $id,
|
||||||
|
data: {
|
||||||
|
title: $title
|
||||||
|
description: $description
|
||||||
|
activityType: $activityType
|
||||||
|
userId: $userId
|
||||||
|
isRead: $isRead
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
mutation DeleteActivityLog(
|
||||||
|
$id: UUID!
|
||||||
|
) @auth(level: USER) {
|
||||||
|
activityLog_delete(id: $id)
|
||||||
|
}
|
||||||
44
dataconnect/connector/activityLog/queries.gql
Normal file
44
dataconnect/connector/activityLog/queries.gql
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
query listActivityLog @auth(level: USER) {
|
||||||
|
activityLogs {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
description
|
||||||
|
activityType
|
||||||
|
userId
|
||||||
|
isRead
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query getActivityLogById(
|
||||||
|
$id: UUID!
|
||||||
|
) @auth(level: USER) {
|
||||||
|
activityLog(id: $id) {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
description
|
||||||
|
activityType
|
||||||
|
userId
|
||||||
|
isRead
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
query filterActivityLog(
|
||||||
|
$userId: UUID,
|
||||||
|
$activityType: ActivityType,
|
||||||
|
$isRead: Boolean
|
||||||
|
) @auth(level: USER) {
|
||||||
|
activityLogs(
|
||||||
|
where: {
|
||||||
|
userId: { eq: $userId }
|
||||||
|
activityType: { eq: $activityType }
|
||||||
|
isRead: { eq: $isRead }
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
title
|
||||||
|
description
|
||||||
|
activityType
|
||||||
|
userId
|
||||||
|
isRead
|
||||||
|
}
|
||||||
|
}
|
||||||
21
dataconnect/schema/activityLog.gql
Normal file
21
dataconnect/schema/activityLog.gql
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
enum ActivityType {
|
||||||
|
EVENT_CREATED
|
||||||
|
EVENT_UPDATED
|
||||||
|
STAFF_ASSIGNED
|
||||||
|
INVOICE_PAID
|
||||||
|
INVOICE_CREATED
|
||||||
|
VENDOR_APPROVED
|
||||||
|
MESSAGE_RECEIVED
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActivityLog @table(name: "activity_logs") {
|
||||||
|
id: UUID! @default(expr: "uuidV4()")
|
||||||
|
title: String!
|
||||||
|
description: String!
|
||||||
|
activityType: ActivityType!
|
||||||
|
userId: UUID! # user_id (FK lógica a User.id)
|
||||||
|
isRead: Boolean @default(expr: "false")
|
||||||
|
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