IProductOrderDELETE Apex Interface

The IProductOrderDELETE Apex interface provides extensibility for DELETE operations through Apex-based validations, mutation-payload adjustments, and post-operation processing. The handler does not issue DELETE DML against Order. It performs a soft delete: a GraphQL OrderUpdate mutation whose Order input is intentionally empty. The Apex class must inject the deleted marker (for example Status = "Cancelled") via customiseMutationPayload. Without that injection, the mutation is structurally valid but semantically empty — nothing about the order visibly changes.

This interface supports the following hooks.

  • transformRequest
  • applyCustomValidations
  • customiseMutationPayload
  • handlePostOperation

These hooks are not used for Product Order DELETE.

  • configureDefaultValidations — getDefaultValidationSpec() returns {}. Apex is not called when the spec is empty.
  • customiseGraphQLQuery — required to compile; never invoked.

Availability. DELETE is interface-mandatory. If no Apex class implements IProductOrderDELETE, processRequest throws HTTP 400 before ID resolution, validation, or GraphQL. Exactly one implementor per org.

{id} is treated as an OrderNumber and resolved to Order.Id. After transformRequest, the handler honors any Apex-written id, then unconditionally re-resolves it as an OrderNumber. Write an OrderNumber into context["id"], not a Salesforce ID.

The HTTP response body is always null. handlePostOperation return is discarded.

The following table lists common use cases for the DELETE operation.

Use CaseHook(s)DescriptionExample ScenariosBenefit
Inject cancelled Status and audit fieldscustomiseMutationPayloadThis is the only hook that makes DELETE real. Target alias softDeleteProductOrder. Use addFields on the empty OrderUpdate.• Status = Cancelled
• Deleted_By__c, Deletion_Timestamp__c
Turns the empty mutation into a real soft-delete
Veto Activated, cascade, or permissionapplyCustomValidationsFail before mutation. Return top-level validationStatus / validationMessage / validationDetails. Nested result is ignored. Default HTTP 422; details can override (404, 403, 409).• Block Activated / InProgress
• Block if active OrderItems exist
• Custom permission Can_Delete_Product_Order
Database is never touched on fail
Stamp a correlation idtransformRequestExtra keys on the shared context are visible to later hooks and platform events.• auditTraceIdTraceability across cascade cancel and events
Seed an OrderNumber aliastransformRequestWrite OrderNumber into context["id"] before the handler lookup.• Partner order numberCorrect OrderNumber re-resolution
Cascade-cancel items and publish an eventhandlePostOperationRuns even on GraphQL errors. constructedTMFResponse is deleteResult (success, deletedId, errors). Check success before DML.• Cancel OrderItems
• Publish OrderDeleted__e
Side effects after a successful mutation

This hook transforms the request context before processing any operation. It is invoked early because an implementor is guaranteed on every DELETE that reaches GraphQL.

Map<String, Object> transformRequest(Map<String, Object> context)

This hook validates custom business logic before constructing the mutation. If validation fails, it rejects the request and returns an error response. The database is never touched on fail. After this hook, context["id"] is already the resolved Salesforce Order Id.

The handler processes return values as follows.

Success

  • Return a map with validationStatus set to any value other than "fail" (case-insensitive), or an empty map.

Failure

  • Return a top-level map with validationStatus set to "fail".
  • Nested "result" is silently ignored.
  • Default HTTP 422 UNPROCESSABLE_REQUEST; validationDetails.statusCode / errorCode can override.
  • Thrown Apex exceptions become generic HTTP 400.

Map<String, Object> applyCustomValidations(Map<String, Object> context)

This hook modifies the mutation payload before the GraphQL OrderUpdate is executed. The base mutation is Order{}. Return {"nodes":[{path, addFields, modifyInput, insertGraphQlSnippet, updateGraphQlSnippet}]}. Target alias softDeleteProductOrder.

mutationGraphQLPayload is {"query": "<mutation string>"}.

Map<String, Object> customiseMutationPayload(Map<String, Object> mutationGraphQLPayload, Map<String, Object> context)

This hook runs after the mutation, even if GraphQL returned errors. Use it only for side effects. Do not try to shape the HTTP body — it is always null.

Map<String, Object> handlePostOperation(Map<String, Object> graphQLQueryResultAsMap, Map<String, Object> constructedTMFResponse, Map<String, Object> context)

Implement all six methods. Combine correlation id, state/cascade/permission veto, Status injection, and cascade-cancel on success. Return an empty map from customiseGraphQLQuery.

Delete for Product Order is a soft OrderUpdate with an empty Order input. The primary extension mechanism is addFields (or modifyInput) on alias softDeleteProductOrder.

Transformation Instructions (JSON):

Without this node, the mutation succeeds structurally and the Order is unchanged.