[Bug] Not possible to empty a non-empty selection-based collection via API

In the Admin GraphQL API version 2026-07, it is impossible to remove all product selections from a collection, in the absence of other kinds of sources and inclusions. Here are the steps I went through:

  1. I create a collection with collectionCreate and don’t specify any sources, proving it is possible to have a collection with no sources.

  2. Then I create a source via the collectionUpdate’s collection.sourcesToCreate field, specifying one product in inclusion.selections. Resultant state:

  3. Now I want to remove that product from the collection.

    1. I make a collectionUpdate request and specify the product in sourcesToUpdate.condition.inclusion.selectionsToRemove, but get the error “A condition based source must have at least one product selection or condition”.

    2. I make a collectionUpdate request and try to delete the whole source by specifying its ID in collection.sourcesToDelete, bug get the same error: “A condition based source must have at least one product selection or condition”. That message doesn’t make sense in this context.

  4. I wonder if it’s the fact that I’m deleting the last source on the collection, so I add another source in the same way as the first. At that point I am able to delete the first source. But I’m back where I started.

  5. There is no other way that I’m aware of to delete a source from a collection via the API, and I shouldn’t have to delete the whole collection, so I try removing the product selection from the collection in the Shopify Admin UI. It works. I query the collection in GraphQL and there is still one source on it, but with no selections.

So I think there are two bugs or at least one bug and one strange inconsistency:

  1. Either the Admin GraphQL API should allow the last remaining source on a collection to be deleted, or the message returned by collectionUpdate when trying to do so should say something like “After a source has been added to it, a collection must always have at least one source” instead of “A condition based source must have at least one product selection or condition”.
  2. Either deleting the last remaining product selection from a collection in the Admin UI should delete the associated source (assuming no condition-based inclusions exist on it), or the Admin GraphQL API should allow the last remaining selection on such a source to be deleted via selectionsToRemove.

Am I missing something? I don’t want to have to use exclusions or add a junk condition.

Hi @gmdev - thanks for the detailed write up, you’ve diagnosed this accurately and I’ve been able to reproduce both cases on a test store on 2026-07. You’re also right that the message on sourcesToDelete doesn’t fit a delete operation. I’ve raised this with the team to confirm whether the rejection is intended and to take a closer look at that delete case, and I’ll update you here once I hear back.

In the meantime, you can empty the collection using the collectionRemoveProducts mutation. It removes the manual selection and leaves the collection with zero products, keeping one empty source behind, which matches the end state you saw in the admin.

mutation RemoveFromCollection($id: ID!, $productIds: [ID!]!) {
  collectionRemoveProducts(id: $id, productIds: $productIds) {
    job { id done }
    userErrors { field message }
  }
}

{
  "id": "gid://shopify/Collection/278964764752",
  "productIds": ["gid://shopify/Product/6854802341968"]
}

One caveat, collectionRemoveProducts is deprecated in 2026-07, so treat it as a stopgap while I get confirmation on the intended path. I’ll follow up as soon as I have more, thanks again for raising this here!