Skip to main content

Backend: Add deleteJobSeekerInvitation Mutation

Date: 2026-04-21

Problem

The frontend calls deleteJobSeekerInvitation but the backend doesn't have this mutation yet. The error returned is:

Cannot query field "deleteJobSeekerInvitation" on type "Mutation".
Did you mean "declineJobSeekerInvitation", "resendJobSeekerInvitation",
"acceptJobSeekerInvitation", "sendJobSeekerInvitation", or "cancelJobSeekerInvitation"?

What the Frontend Expects

GraphQL Signature

type Mutation {
deleteJobSeekerInvitation(invitationId: String!): JobSeekerInvitation
}

Return Fields

{
id
status
}

When It's Called

The frontend uses this mutation to permanently delete invitations that are already in a terminal state:

  • CANCELLED
  • DECLINED
  • EXPIRED

This is different from cancelJobSeekerInvitation, which transitions an active/accepted invitation to cancelled status (used for disconnecting a partner).

Flow

  1. Job seeker views their sent invitations on /jobseeker/connections/collaboratingpartner
  2. For invitations in a terminal state, the UI shows a delete/remove action
  3. Clicking it calls deleteJobSeekerInvitation to clean up the record
  4. Bulk delete also uses this — iterates over selected IDs calling the same mutation

Implementation Notes

  • Authorization: Only the job seeker who sent the invitation should be able to delete it. Verify invitation.jobSeekerId === currentUser.id.
  • Status guard: Only allow deletion when status is CANCELLED, DECLINED, or EXPIRED. Return an error if the invitation is still PENDING or ACCEPTED (those should use cancelJobSeekerInvitation instead).
  • Action: Hard-delete the record from the database (or soft-delete if that's the existing pattern for other entities).
  • Return: The deleted invitation's id and status so the frontend can confirm success.

Existing Mutations for Reference

MutationPurposeCalled by
sendJobSeekerInvitationCreate new invitationJob seeker
cancelJobSeekerInvitationCancel active/accepted invitation (disconnect)Job seeker
resendJobSeekerInvitationResend a pending invitationJob seeker
deleteJobSeekerInvitationRemove terminal invitation (NEW)Job seeker
acceptJobSeekerInvitationAccept an invitationEmployer
declineJobSeekerInvitationDecline an invitationEmployer