Skip to content

Delete Product Review

About

The deleteProductReview mutation permanently removes a review. Use it to:

  • Let a shopper withdraw a review they submitted
  • Remove a review a shopper asked to have taken down
  • Clear reviews created while testing an integration

Deletion is immediate and cannot be undone — the row is removed rather than flagged, so the review disappears from every query at once.

A review can only be deleted by the customer who wrote it. Send that customer's Bearer token — an unauthenticated request, a different customer's token, or a review submitted by a guest is refused.

Arguments

ArgumentTypeRequiredDescription
idID!✅ YesIdentifies the review. Accepts the IRI form (/api/shop/reviews/93) or a plain numeric ID.
clientMutationIdString❌ NoArbitrary string echoed back in the payload, useful for correlating a response with its request.

Possible Returns

FieldTypeDescription
productReviewProductReviewThe review that was removed. Only id is populated — the record is already gone, so its other fields are not available to select meaningfully.
productReview.idID!IRI of the deleted review, returned as confirmation.
clientMutationIdStringThe clientMutationId sent with the request, echoed back.

A successful delete looks like this:

json
{
  "data": {
    "deleteProductReview": {
      "productReview": {
        "id": "/api/shop/reviews/76"
      },
      "clientMutationId": "review-cleanup-76"
    }
  }
}

Use Cases

1. Withdrawing a shopper's own review

Read the review ID back from the list the shopper is looking at, then delete it and drop the row from the rendered list on success.

graphql
mutation removeReview($input: deleteProductReviewInput!) {
  deleteProductReview(input: $input) {
    productReview {
      id
    }
    clientMutationId
  }
}
json
{
  "input": {
    "id": "/api/shop/reviews/76",
    "clientMutationId": "review-cleanup-76"
  }
}

2. Cleaning up integration test data

A review created while testing stays in the catalog and counts toward a product's review total. Delete it with the _id returned by the create mutation.

3. Confirming the review is gone

Re-run Get Product Reviews for the same product_id. The deleted review is absent and totalCount has dropped by one.

Best Practices

  1. Prefer an admin status change to a deletion — marking a review disapproved hides it from the storefront while keeping the record; deleting destroys it with no way back
  2. Confirm with the shopper first — there is no soft delete and no recovery path short of a database restore
  3. Only offer the action on the shopper's own reviews — the API refuses a review written by anyone else, and a guest review can never be removed through the storefront
  4. Delete by the ID you were handed — take it from the review list or the create response rather than assembling the IRI by hand
  5. Treat a repeat delete as already-done — a second call for the same ID fails because the review no longer exists, which is a successful outcome from the shopper's point of view
  6. Refresh the product's review counts afterwardstotalCount and any cached rating breakdown are stale the moment a review is removed

Error Scenarios

ScenarioCause
Missing IDThe id field was omitted from input. GraphQL rejects the document before the mutation runs.
Review not foundThe ID resolves to a review that does not exist, including one already deleted.
Not signed inNo customer Bearer token was sent, so ownership cannot be established.
Not your reviewThe review belongs to another customer, or was submitted by a guest and has no owner.

Released under the MIT License.