Hi All,
I have what I think is a pretty straightforward GraphQL query for duplicating a product:
mutation {
productDuplicate(productId: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzQ1NzA1MTEwODE1NzQ", newTitle: "New Product") {
newProduct {
id
}
userErrors {
field
message
}
}
}
However, when I run this query, instead of a new product, I get back an error message with no details about why it failed:
{
"data": {
"productDuplicate": {
"newProduct": null,
"userErrors": [
{
"field": [
"productId"
],
"message": "Failed to duplicate product"
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 990,
"restoreRate": 50
}
}
}
}
The weird thing is that it ONLY happens with that product ID. I can duplicate others no problem. When I use the ID above though, I get the error. I can duplicate it just fine using the regular Shopify Admin so I'm really stumped on this one.
Any thoughts from anyone?
Thanks!
Kris
Solved! Go to the solution
This is an accepted solution.
Hey @Kris_Doyle
It looks like this specific product was throwing a specific validation error: "Errors: Variants compare at price Compare at price needs to be higher than Price.".
Kevin_A | Developer Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Brilliant, thanks @Kevin_A !
Would be good to get that in the error description but otherwise, good stuff.
User | Count |
---|---|
14 | |
12 | |
10 | |
8 | |
7 |