Hi,
One more gap in the rushed collection released (yes, still frustrated).
When creating a source via collectionUpdate, sourcesToCreate doesn’t return the id of the source it just created the mutation only returns collection.sources, the full list of all sources currently on the collection:
mutation CollectionAddProductSelectionSource($collection: CollectionUpdateInput!) {
collectionUpdate(collection: $collection) {
collection {
id
sources { __typename id title }
}
userErrors { field message }
}
}
{
"collection": {
"id": "gid://shopify/Collection/123",
"sourcesToCreate": [
{
"source": {
"title": "123",
"inclusion": { "selections": [{ "productId": "gid://shopify/Product/456" }] }
}
}
]
}
}
There’s no client-supplied identifier accepted on CollectionCreateSourceInput, and no id echoed back for the specific source that was just created. If the collection already has other sources, we have no reliable way to tell which entry in the returned sources array is the new one.
The only workarounds we’ve found are both bad:
- Match by
title: breaks the moment two sources share a title, or a retry re-creates the same named source after a dropped response. - Diff
sourcesbefore and after: costs an extra read call, and is vulnerable to races: any concurrent write to the same collection (another request, a merchant editing it in admin) between the read and the mutation can make the diff pick up the wrong source, or miss ours entirely.
Neither of these is safe.
The Ask:
Either return the id(s) of the source(s) just created by sourcesToCreate directly in the mutation payload, or accept a client-supplied correlation token on CollectionCreateSourceInput that gets echoed back on the created source.
Thank you