Steps to reproduce:
Given a collection exists and the collection has a source with 1 product already.
Perform the following mutation:
mutation CollectionUpdate($collection: CollectionUpdateInput!) {
collectionUpdate(collection: $collection) {
collection { id }
userErrors { field message }
}
}
With an input like this one:
{"collection":{"id":"gid://shopify/Collection/470782378215","sourcesToUpdate":[
{"condition":{"id":"gid://shopify/CollectionConditionsSource/25023971559",
"inclusion":{"selectionsToAdd":[
{"productId":"gid://shopify/Product/8868004724967"},
{"productId":"gid://shopify/Product/8868004757735"},
{"productId":"gid://shopify/Product/9999999999999"}
]}}}]}}
Where the product gid://shopify/Product/9999999999999 does not exist, while the other two products exist.
It will output:
{
"data": {
"collectionUpdate": {
"collection": null,
"userErrors": [
{
"field": [
"collection",
"sourcesToUpdate",
"0",
"condition",
"inclusion",
"selectionsToAdd",
"2",
"productId"
],
"message": "Product does not exist"
}
]
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1990,
"restoreRate": 100
}
}
}
}
Expected results:
collectionis populated
the existing products are added to the collection
userErrorsindicates that the product9999999999999does not exist
Actual result:
1st issue, the collection comes null:
"collection": null,
2nd issue:
- User error indicates that one product is in error - this is expected
- The other two products were NOT added to the collection
Why this is critical:
In the previous version with collectionAddProductsV2 non existing products where simply ignored
Races are very likely to occur if a product is deleted at the same time, especially when dealing with a large volume of products via a bulk operation.
It becomes extremely hard to work at scale with the new collection API and we have to rely on elaborated mechanisms to retry without the products in error.
Other cases
- The same problem exists with the mutations:
collectionCreatecollectionConditionsSourceCreatecollectionConditionsSourceUpdate
- While these mutation happily ignore the products that don’t exist:
collectionAddProductsV2