[BUG] No way to identify the source we just created in sourcesToCreate

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 sources before 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

Hey @Soufiane_Ghzal, thanks for pointing out this gap.

For a partial workaround, the standalone mutation collectionConditionsSourceCreate returns the source id directly on the payload. You can then link it via sourcesToCreate: [{ shareableSource: { sourceId: <id> } }]. That only covers app-owned shareable sources though. For inline conditions or sub-collection sources, the before/after diff on collection.sources is still the only option today.

This is something we are tracking. I would like to pass on this feedback for you. To ensure I have full context, can you share what your app does with the source ID after creation?

Hi @KyleG-Shopify

Thank you for looking into it.

We need the ID to add more products to it, because we can only add 250 products at once on creation.