diff --git a/backend/dataconnect/connector/staffDocument/mutations.gql b/backend/dataconnect/connector/staffDocument/mutations.gql index 8877dd02..ebec5fba 100644 --- a/backend/dataconnect/connector/staffDocument/mutations.gql +++ b/backend/dataconnect/connector/staffDocument/mutations.gql @@ -31,10 +31,46 @@ mutation updateStaffDocument( data: { status: $status documentUrl: $documentUrl + expiryDate: $expiryDate } ) } +# ------------------------------------------------------------ +# UPSERT STAFF DOCUMENT +# Creates the document record if it does not exist, or updates +# it if it already exists (matched by staffId + documentId key). +# Use this when uploading a document for the first time or +# re-uploading/updating an existing one. +# +# To update multiple documents in a single network call, use +# aliased mutations in one GraphQL request from the client: +# +# mutation { +# doc1: upsertStaffDocument(staffId: $id, staffName: $name, documentId: $d1, ...) +# doc2: upsertStaffDocument(staffId: $id, staffName: $name, documentId: $d2, ...) +# } +# ------------------------------------------------------------ +mutation upsertStaffDocument( + $staffId: UUID! + $staffName: String! + $documentId: UUID! + $status: DocumentStatus! + $documentUrl: String + $expiryDate: Timestamp +) @auth(level: USER) { + staffDocument_upsert( + data: { + staffId: $staffId + staffName: $staffName + documentId: $documentId + status: $status + documentUrl: $documentUrl + expiryDate: $expiryDate + } + ) +} + mutation deleteStaffDocument( $staffId: UUID! $documentId: UUID!