Hi,
I’m working on updating from REST API to GraphQL. I’ve been able to do everything so far based on the CURL examples given in the docs.
I need to delete one variant from a product that has many other variants. I was able to do this successfully with productVariantDelete, however that is shown as deprecated, and so I want to do this instead with productVariantsBulkDelete.
However, for productVariantsBulkDelete, there is no CURL example and I’m a little lost. I’ve tried the 3 variations of the data in the request listed below and all of them produce errors. Can someone help me format this request so it works?
REQUEST DATA:
{
"query": "mutation productVariantsBulkDelete($productId: ID!, $variantsIds: [ID!]!) { productVariantsBulkDelete(productId: $productId, variantsIds: $variantsIds) { product { id } userErrors { field message }}}",
"variables": {
"input": {
"productId": "gid://shopify/Product/7489728872509",
"variantIds": [
"gid://shopify/ProductVariant/41701389959229"
]
}
}
}
RESPONSE:
{"errors":[{"message":"Variable $productId of type ID! was provided invalid value","locations":[{"line":1,"column":36}],"extensions":{"value":null,"problems":[{"path":[],"explanation":"Expected value to not be null"}]}},{"message":"Variable $variantsIds of type [ID!]! was provided invalid value","locations":[{"line":1,"column":53}],"extensions":{"value":null,"problems":[{"path":[],"explanation":"Expected value to not be null"}]}}]}
REQUEST DATA:
{
"query": "mutation productVariantsBulkDelete($productId: ID!, $variantsIds: [ID!]!) { productVariantsBulkDelete(productId: $productId, variantsIds: $variantsIds) { product { id } userErrors { field message }}}",
"variables": {
"productId": "gid://shopify/Product/7489728872509",
"variantIds": [
"gid://shopify/ProductVariant/41701389959229"
]
}
}
RESPONSE:
{"errors":[{"message":"Variable $variantsIds of type [ID!]! was provided invalid value","locations":[{"line":1,"column":53}],"extensions":{"value":null,"problems":[{"path":[],"explanation":"Expected value to not be null"}]}}]}
REQUEST DATA:
{
"query": "mutation productVariantsBulkDelete($productId: ID!, $variantsIds: [ID!]!) { productVariantsBulkDelete(productId: $productId, variantsIds: $variantsIds) { product { id } userErrors { field message }}}",
"input": {
"productId": "gid://shopify/Product/7489728872509",
"variantIds": [
"gid://shopify/ProductVariant/41701389959229"
]
}
}
RESPONSE:
{"errors":[{"message":"Variable $productId of type ID! was provided invalid value","locations":[{"line":1,"column":36}],"extensions":{"value":null,"problems":[{"path":[],"explanation":"Expected value to not be null"}]}},{"message":"Variable $variantsIds of type [ID!]! was provided invalid value","locations":[{"line":1,"column":53}],"extensions":{"value":null,"problems":[{"path":[],"explanation":"Expected value to not be null"}]}}]}