142 lines
2.4 KiB
GraphQL
142 lines
2.4 KiB
GraphQL
|
|
# ----------------------------------------------------------
|
|
# LIST ALL (admin/debug)
|
|
# ----------------------------------------------------------
|
|
query listStaffRoles(
|
|
$offset: Int
|
|
$limit: Int
|
|
) @auth(level: USER) {
|
|
staffRoles(offset: $offset, limit: $limit) {
|
|
id
|
|
staffId
|
|
roleId
|
|
createdAt
|
|
roleType
|
|
|
|
staff {
|
|
id
|
|
fullName
|
|
userId
|
|
email
|
|
phone
|
|
}
|
|
|
|
role {
|
|
id
|
|
name
|
|
costPerHour
|
|
}
|
|
}
|
|
}
|
|
|
|
# ----------------------------------------------------------
|
|
# GET BY COMPOSITE KEY (staffId + roleId)
|
|
# ----------------------------------------------------------
|
|
query getStaffRoleByKey(
|
|
$staffId: UUID!
|
|
$roleId: UUID!
|
|
) @auth(level: USER) {
|
|
staffRole(key: { staffId: $staffId, roleId: $roleId }) {
|
|
id
|
|
staffId
|
|
roleId
|
|
createdAt
|
|
roleType
|
|
|
|
staff {
|
|
id
|
|
fullName
|
|
userId
|
|
email
|
|
phone
|
|
}
|
|
|
|
role {
|
|
id
|
|
name
|
|
costPerHour
|
|
}
|
|
}
|
|
}
|
|
|
|
# ----------------------------------------------------------
|
|
# LIST BY STAFF (most common)
|
|
# ----------------------------------------------------------
|
|
query listStaffRolesByStaffId(
|
|
$staffId: UUID!
|
|
$offset: Int
|
|
$limit: Int
|
|
) @auth(level: USER) {
|
|
staffRoles(
|
|
where: { staffId: { eq: $staffId } }
|
|
offset: $offset
|
|
limit: $limit
|
|
) {
|
|
id
|
|
staffId
|
|
roleId
|
|
createdAt
|
|
roleType
|
|
|
|
role {
|
|
id
|
|
name
|
|
costPerHour
|
|
}
|
|
}
|
|
}
|
|
|
|
# ----------------------------------------------------------
|
|
# LIST BY ROLE (who has this skill)
|
|
# ----------------------------------------------------------
|
|
query listStaffRolesByRoleId(
|
|
$roleId: UUID!
|
|
$offset: Int
|
|
$limit: Int
|
|
) @auth(level: USER) {
|
|
staffRoles(
|
|
where: { roleId: { eq: $roleId } }
|
|
offset: $offset
|
|
limit: $limit
|
|
) {
|
|
id
|
|
staffId
|
|
roleId
|
|
createdAt
|
|
roleType
|
|
|
|
staff {
|
|
id
|
|
fullName
|
|
userId
|
|
email
|
|
phone
|
|
}
|
|
}
|
|
}
|
|
|
|
# ----------------------------------------------------------
|
|
# FILTER (optional)
|
|
# Useful when you want both conditions without using key lookup
|
|
# ----------------------------------------------------------
|
|
query filterStaffRoles(
|
|
$staffId: UUID
|
|
$roleId: UUID
|
|
$offset: Int
|
|
$limit: Int
|
|
) @auth(level: USER) {
|
|
staffRoles(
|
|
where: {
|
|
staffId: { eq: $staffId }
|
|
roleId: { eq: $roleId }
|
|
}
|
|
offset: $offset
|
|
limit: $limit
|
|
) {
|
|
id
|
|
staffId
|
|
roleId
|
|
createdAt
|
|
roleType
|
|
}
|
|
} |