new shift entity

This commit is contained in:
José Salazar
2025-11-26 15:52:31 -05:00
parent 3ac7605965
commit 4c24e83622
3 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
mutation CreateShift(
$shiftName: String!,
$startDate: Timestamp!,
$endDate: Timestamp,
$assignedStaff: String
) @auth(level: USER) {
shift_insert(
data: {
shiftName: $shiftName
startDate: $startDate
endDate: $endDate
assignedStaff: $assignedStaff
}
)
}
mutation UpdateShift(
$id: UUID!,
$shiftName: String,
$startDate: Timestamp,
$endDate: Timestamp,
$assignedStaff: String
) @auth(level: USER) {
shift_update(
id: $id,
data: {
shiftName: $shiftName
startDate: $startDate
endDate: $endDate
assignedStaff: $assignedStaff
}
)
}
mutation DeleteShift(
$id: UUID!
) @auth(level: USER) {
shift_delete(id: $id)
}

View File

@@ -0,0 +1,44 @@
query listShift @auth(level: USER) {
shifts {
id
shiftName
startDate
endDate
assignedStaff
}
}
query getShiftById(
$id: UUID!
) @auth(level: USER) {
shift(id: $id) {
id
shiftName
startDate
endDate
assignedStaff
createdDate
updatedDate
createdBy
}
}
query filterShift(
$shiftName: String,
$startDate: Timestamp,
$endDate: Timestamp
) @auth(level: USER) {
shifts(
where: {
shiftName: { eq: $shiftName }
startDate: { eq: $startDate }
endDate: { eq: $endDate }
}
) {
id
shiftName
startDate
endDate
assignedStaff
}
}

View File

@@ -0,0 +1,10 @@
type Shift @table(name: "shifts") {
id: UUID! @default(expr: "uuidV4()")
shiftName: String!
startDate: Timestamp!
endDate: Timestamp
assignedStaff: String # assigned_staff (jsonb -> String, array de objects)
createdDate: Timestamp @default(expr: "request.time")
updatedDate: Timestamp @default(expr: "request.time")
createdBy: String @default(expr: "auth.uid")
}