GraphQL operations productDelete and productVariantDelete which is the right JSON format

Topic summary

Clarifying the JSON/GraphQL variable format for Shopify Admin mutations to delete products and variants; initial attempts using arrays of IDs were rejected.

Key findings:

  • productDelete accepts only a single product ID per call; no bulk product delete is available in the referenced API.
  • productVariantDelete also expects a single ID. For multiple variants, use productVariantsBulkDelete.

Usage notes:

  • Variables must match the mutation’s declared parameters (named fields), not arrays of objects.
  • productVariantsBulkDelete takes productId (ID) and variantsIds ([ID!]).

Outcome:

  • The issue was resolved by performing single product deletes and using the bulk variant deletion mutation for variants.
  • A request remains for a product bulk delete capability; no solution was identified.

Context:

  • Code snippets are central to understanding the discussion; no images or other attachments were used.

Status:

  • Resolved for variants (via bulk mutation). Open for products (no bulk delete).
Summarized with AI on February 14. AI used: gpt-5.

Hey,

Please help me to correct the format for the JSONs used in the GraphQL operations productDelete and productVariantDelete.

JSONS are valid and look to me like I have the correct setup for this mutation but somehow the format is not accepted. It seems a different array is expected. Did not find an example.

Please have a look it is much appreciated.
Also it will help the next person struggling with this :slightly_smiling_face:

/*

{"query":"mutation productDelete($input: ProductDeleteInput!) { productDelete(input: $input) {userErrors { field message} }}","variables":{"input":[{"id":"gid://shopify/Product/6881165607118"},{"id":"gid://shopify/Product/6947754475726"}]}

*/

https://shopify.dev/api/admin-graphql/2021-10/mutations/productVariantDelete

/*

{"query":"mutation productVariantDelete($id: ID!) { productVariantDelete(id: $id) {userErrors {  field  message}  }}","variables":[{"id":409364442318386},{"id":409364442318386},{"id":409364442318386}]}
	
*/

I tried again but I do not find the right format.. unfortunately with graphql you cannot send a get request and find what is needed like in Rest. :disappointed_face:
It has to be a quite simple solution though.

Still struggling with this. I would really like to give graphql a go here.
Can someone have a heart and provide an example please.

Ok, I have the solution.

These functions do not allow multiple product ids. That’s it.

There seems to be no replacement for https://shopify.dev/api/admin-graphql/2021-10/mutations/productDelete

But for the variants there is a bulk version of https://shopify.dev/api/admin-graphql/2021-10/mutations/productDelete , it is this one:
https://shopify.dev/api/admin-graphql/2021-10/mutations/productVariantsBulkDelete

This is how it is fed with data:

{“query”:"

mutation productVariantsBulkDelete($productId: ID!, $variantsIds: [ID!]!) {
productVariantsBulkDelete(productId: $productId, variantsIds: $variantsIds) {
product {

Product fields

}
userErrors {
field
message
}
}
}

",“variables”:{“input”:{“id”:“gid://shopify/Product/6881165607118”},[{“id”:“gid://shopify/Product/6947754475721”},{“id”:“gid://shopify/Product/69477544757262”},{“id”:“gid://shopify/Product/6947754475723”}]}

I hope Shopify will also add productBulkDelete, or someone finds a solution here.