Files
Krow-workspace/backend/dataconnect/connector/benefitsData/queries.gql

200 lines
3.8 KiB
GraphQL

# ----------------------------------------------------------
# GET WORKER BENEFIT BALANCES (M4)
# Returns all active benefit plans with balance data for a given worker.
# Supports: Sick Leave (40h), Holidays (24h), Vacation (40h)
# Extensible: any future VendorBenefitPlan will appear automatically.
#
# Fields:
# vendorBenefitPlan.title → benefit type name
# vendorBenefitPlan.total → total entitlement (hours)
# current → used hours
# remaining = total - current → computed client-side
# ----------------------------------------------------------
query getWorkerBenefitBalances(
$staffId: UUID!
) @auth(level: USER) {
benefitsDatas(
where: {
staffId: { eq: $staffId }
}
) {
vendorBenefitPlanId
current
vendorBenefitPlan {
id
title
description
requestLabel
total
isActive
}
}
}
# ----------------------------------------------------------
# LIST ALL (admin/debug)
# ----------------------------------------------------------
query listBenefitsData(
$offset: Int
$limit: Int
) @auth(level: USER) {
benefitsDatas(offset: $offset, limit: $limit) {
id
vendorBenefitPlanId
current
staffId
staff {
id
fullName
}
vendorBenefitPlan {
id
vendorId
title
description
requestLabel
total
isActive
}
}
}
# ----------------------------------------------------------
# GET BY KEY (staffId + vendorBenefitPlanId) ✅ (replaces getById in practice)
# ----------------------------------------------------------
query getBenefitsDataByKey(
$staffId: UUID!
$vendorBenefitPlanId: UUID!
) @auth(level: USER) {
benefitsData(key: { staffId: $staffId, vendorBenefitPlanId: $vendorBenefitPlanId }) {
id
vendorBenefitPlanId
current
staffId
staff {
id
fullName
}
vendorBenefitPlan {
id
vendorId
title
description
requestLabel
total
isActive
}
}
}
# ----------------------------------------------------------
# LIST BY STAFF
# ----------------------------------------------------------
query listBenefitsDataByStaffId(
$staffId: UUID!
$offset: Int
$limit: Int
) @auth(level: USER) {
benefitsDatas(
where: { staffId: { eq: $staffId } }
offset: $offset
limit: $limit
) {
id
vendorBenefitPlanId
current
staffId
staff {
id
fullName
}
vendorBenefitPlan {
id
vendorId
title
description
requestLabel
total
isActive
}
}
}
# ----------------------------------------------------------
# LIST BY VENDOR BENEFIT PLAN
# ----------------------------------------------------------
query listBenefitsDataByVendorBenefitPlanId(
$vendorBenefitPlanId: UUID!
$offset: Int
$limit: Int
) @auth(level: USER) {
benefitsDatas(
where: { vendorBenefitPlanId: { eq: $vendorBenefitPlanId } }
offset: $offset
limit: $limit
) {
id
vendorBenefitPlanId
current
staffId
staff {
id
fullName
}
vendorBenefitPlan {
id
vendorId
title
description
requestLabel
total
isActive
}
}
}
# ----------------------------------------------------------
# LIST BY VENDOR (2-step helper: planIds -> benefitsDatas IN)
# ----------------------------------------------------------
query listBenefitsDataByVendorBenefitPlanIds(
$vendorBenefitPlanIds: [UUID!]!
$offset: Int
$limit: Int
) @auth(level: USER) {
benefitsDatas(
where: { vendorBenefitPlanId: { in: $vendorBenefitPlanIds } }
offset: $offset
limit: $limit
) {
id
vendorBenefitPlanId
current
staffId
staff {
id
fullName
}
vendorBenefitPlan {
id
vendorId
title
description
requestLabel
total
isActive
}
}
}