Create a new collection mutation like: collectionSetProducts that works like productSet for arrays

From productSet:

Any list field will be updated so that all included entries are either created or updated, and all existing entries not included will be deleted.

I want to do the same with the relationship in the collection->products entity. Currently, if I need to sync a change like “added 2 more products to a collection, and removed 3 products from it”, I have to do the following:

  1. use collection to get all associated products (this is not cool since the products is a relationship, and we have to paginate them instead of getting the entire array of ids in one shot )
  2. make a diff in our app
  3. send a collectionRemoveProducts request to delete the products that we want
  4. send a collectionAddProductsV2 request to add new products

This seems like a lot of work to do: pagination, pooling for both remove and add jobs, where as productSet makes everything so easy.

My app is the source of truth, and shopify should give me the tools to do updates in a straightforward manner.

2 Likes