fix: Update staff's cerficate schema to create queries and mutations
This commit is contained in:
@@ -5,7 +5,7 @@ mutation CreateCertificate(
|
||||
$status: CertificateStatus!
|
||||
$fileUrl: String
|
||||
$icon: String
|
||||
$certificationType: ComplianceType
|
||||
$certificationType: ComplianceType!
|
||||
$issuer: String
|
||||
$staffId: UUID!
|
||||
$validationStatus: ValidationStatus
|
||||
@@ -63,3 +63,43 @@ mutation UpdateCertificate(
|
||||
mutation DeleteCertificate($id: UUID!) @auth(level: USER) {
|
||||
certificate_delete(id: $id)
|
||||
}
|
||||
|
||||
# UPSERT STAFF CERTIFICATE
|
||||
# Creates the certificate record if it does not exist, or updates
|
||||
# it if it already exists (matched by staffId + certificationType key).
|
||||
# Use this when uploading a certificate for the first time or
|
||||
# updating an existing one.
|
||||
#
|
||||
# To update multiple certificates in a single network call, use
|
||||
# aliased mutations in one GraphQL request from the client:
|
||||
#
|
||||
# mutation {
|
||||
# cert1: upsertStaffCertificate(staffId: $id, certificationType: BACKGROUND_CHECK, ...)
|
||||
# cert2: upsertStaffCertificate(staffId: $id, certificationType: FOOD_HANDLER, ...)
|
||||
# }
|
||||
# ------------------------------------------------------------
|
||||
mutation upsertStaffCertificate(
|
||||
$staffId: UUID!
|
||||
$certificationType: ComplianceType!
|
||||
$name: String!
|
||||
$status: CertificateStatus!
|
||||
$fileUrl: String
|
||||
$expiry: Timestamp
|
||||
$issuer: String
|
||||
$certificateNumber: String
|
||||
$validationStatus: ValidationStatus
|
||||
) @auth(level: USER) {
|
||||
certificate_upsert(
|
||||
data: {
|
||||
staffId: $staffId
|
||||
certificationType: $certificationType
|
||||
name: $name
|
||||
status: $status
|
||||
fileUrl: $fileUrl
|
||||
expiry: $expiry
|
||||
issuer: $issuer
|
||||
certificateNumber: $certificateNumber
|
||||
validationStatus: $validationStatus
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ enum ValidationStatus {
|
||||
}
|
||||
|
||||
|
||||
type Certificate @table(name: "certificates") {
|
||||
type Certificate @table(name: "certificates", key: ["staffId", "certificationType"]) {
|
||||
id: UUID! @default(expr: "uuidV4()")
|
||||
|
||||
name: String!
|
||||
@@ -39,7 +39,7 @@ type Certificate @table(name: "certificates") {
|
||||
status: CertificateStatus!
|
||||
fileUrl: String
|
||||
icon: String
|
||||
certificationType: ComplianceType
|
||||
certificationType: ComplianceType!
|
||||
issuer: String #Issuing Authority
|
||||
certificateNumber: String
|
||||
|
||||
|
||||
Reference in New Issue
Block a user