From 4c24e83622371d30713c605551c16508692c7676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Salazar?= <73718835+joshrs23@users.noreply.github.com> Date: Wed, 26 Nov 2025 15:52:31 -0500 Subject: [PATCH] new shift entity --- dataconnect/connector/shift/mutations.gql | 39 ++++++++++++++++++++ dataconnect/connector/shift/queries.gql | 44 +++++++++++++++++++++++ dataconnect/schema/shift.gql | 10 ++++++ 3 files changed, 93 insertions(+) create mode 100644 dataconnect/connector/shift/mutations.gql create mode 100644 dataconnect/connector/shift/queries.gql create mode 100644 dataconnect/schema/shift.gql diff --git a/dataconnect/connector/shift/mutations.gql b/dataconnect/connector/shift/mutations.gql new file mode 100644 index 00000000..a98f7302 --- /dev/null +++ b/dataconnect/connector/shift/mutations.gql @@ -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) +} diff --git a/dataconnect/connector/shift/queries.gql b/dataconnect/connector/shift/queries.gql new file mode 100644 index 00000000..2e9811a5 --- /dev/null +++ b/dataconnect/connector/shift/queries.gql @@ -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 + } +} diff --git a/dataconnect/schema/shift.gql b/dataconnect/schema/shift.gql new file mode 100644 index 00000000..8affd9ca --- /dev/null +++ b/dataconnect/schema/shift.gql @@ -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") +}