diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/operations/delete.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/operations/delete.ts index f547d8e1c42..69cf6a428e3 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/operations/delete.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/operations/delete.ts @@ -1,21 +1,29 @@ -import {isLiveEditEnabled} from '../utils/isLiveEditEnabled' import {type OperationImpl} from './types' export const del: OperationImpl<[], 'NOTHING_TO_DELETE'> = { disabled: ({snapshots}) => (snapshots.draft || snapshots.published ? false : 'NOTHING_TO_DELETE'), - execute: ({client, schema, idPair, typeName}) => { - const tx = client.observable.transaction().delete(idPair.publishedId) + execute: ({client: globalClient, schema, idPair, typeName}) => { + const vXClient = globalClient.withConfig({apiVersion: 'X'}) - if (isLiveEditEnabled(schema, typeName)) { - return tx.commit({tag: 'document.delete'}) - } + const {dataset} = globalClient.config() - return tx.delete(idPair.draftId).commit({ + return vXClient.observable.request({ + url: `/data/actions/${dataset}`, + method: 'post', tag: 'document.delete', // this disables referential integrity for cross-dataset references. we // have this set because we warn against deletes in the `ConfirmDeleteDialog` // UI. This operation is run when "delete anyway" is clicked - skipCrossDatasetReferenceValidation: true, + query: {skipCrossDatasetReferenceValidation: 'true'}, + body: { + actions: [ + { + actionType: 'sanity.action.document.delete', + draftId: idPair.draftId, + publishedId: idPair.publishedId, + }, + ], + }, }) }, }