So I am working on migrate rest api to graphql api… for products…
A few years ago when I worked on the rest api, I felt that the api was created by the developers who will never use the api to do anything… a few years later, still the same, unless I missed something.
The inventoryItemId, productId etc these are all Shopify’s internal ids, 90% of the users do NOT care about this. In rest api, if I have a SKU and I want to update the quantity for that SKU, I had to call a few apis to do that:
- Get the product id
- Get the inventory id
- Get current quantity in shopify’s system
- update the inventory with the delta quantity…
so 4 calls. just to update the inventory quantity of a sku.
In graphql… same but actually getting worse.
I still have SKU and quantity… so I had to
- sku to product id (gid)
- product id to inventory item id
- get current available quantity on shopify / or getLocation id
- update inventory…(inventorySetQuantities)
in step 4, if I want to update the quantity I had to pass in inventoryItemId and LocationId… I have no idea where the locationId is for my sku, so, I had to either call locations api or getInventoryItem (which will return locationid) to get the locationId… but, I am stuck here… I am unable to retrieve the locationId because it requires the read_locations
scope. This wasn’t a requirement for rest api.
I have hundreds people who already authorized, and now I will have to force them to re-authorize in order to get this scope I am in the testing mode… I have no idea if read_locations
is the only new scope I need for the new gaphql api.
Shopify - why cannot you just have a simple api, I pass in you sku and quantity and you just update it for me?
Anyway… so can anyone please confirm that read_locations
is indeed need? I have no other ways to obtain the locationId of an item without the read_locations
scope?
Thanks