Bulk Update Products through Admin GraphQL

Solved
majidzulfiqar
Shopify Partner
8 0 0

Hi,

I am looking a way by which i can update bulk update products using your Admin GraphQL.

I have explored Admin GraphQL, but at the moment i only found productUpdate mutation which will update only a single product or I am missing something here. Is there a way to bulk update products in one call.

Looking forward to your response.

Thanks in Advance!

0 Likes
KarlOffenberger
Shopify Partner
1867 182 791

This is an accepted solution.

There is no mutation for bulk creating or updating product resources or any other resource. Same goes for the REST API. The only exception is the ability to bulk update inventory levels at a location via inventoryBulkAdjustQuantityAtLocation.

 

That said, you can have multiple mutations in one request which will be executed in series - so essentially it is a question of testing and confirming whether this approach yields better performance or not for your use case).

 

mutation {
  Product1: productCreate(input: {
    title: "Test Item 1", 
    publishOn: "2019-01-31T00:00:00-12:00"
  }) {
    product {
      id
    }
  }
  
  Product2: productCreate(input: {
    title: "Test Item 2", 
    publishOn: "2019-01-31T00:00:00-12:00"
  }) {
    product {
      id
    }
  }
}

Best wishes!

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
majidzulfiqar
Shopify Partner
8 0 0

I got your point on updating products by having multiple mutations in one request, So what will be the cost of this request. I have tested this multiple mutations query and it is showing me query cost: 20 and when i add three mutations it show me 30. Does it mean that for one update mutation request it cost me 10 and it multiplies by number of mutations?

 

Also you have mentioned about bulk update inventory levels at a location via inventoryBulkAdjustQuantityAtLocation, this will only update/adjust inventory availableDelta for given inventoryItemId's at one location, or it can update multiple locations as well in same mutation ? 

0 Likes
KarlOffenberger
Shopify Partner
1867 182 791

I don't know the exact query costs and how it grows per additional mutation - that's up to you to add up and decide on the benefits / disadvantages.

 

No, the inventoryBulkAdjustQuantityAtLocation is per location. You would also need to be careful that it expects deltas, not absolute inventory levels.

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
majidzulfiqar
Shopify Partner
8 0 0

Thanks for information :)

0 Likes
gnurpreet
New Member
1 0 0

Another example where prices of multiple variants:

 

mutation{
  ProductVariant1: productVariantUpdate(input: {
    id: "gid://shopify/ProductVariant/27868413755001",
    price: 34.97
  }){
    productVariant{ id, price }
  }
  
  ProductVariant2: productVariantUpdate(input: {
    id: "gid://shopify/ProductVariant/27868413788000",
    price: 34.97
  }){
    productVariant{ id, price }
  }
}

The cost of the query is 20 since 2 are being updated

0 Likes
sandip001
Shopify Partner
5 0 5

1. why there is no mutation to set inventory levels directly using the GraphQL Admin API ?

2. Any idea about in future shopify allow to set inventory levels directly using the GraphQL Admin API ?

aveshopstech
Excursionist
18 0 6

Its 2021 here! Same need still exists. @Shopify, any chance we can get an inventoryBulkSetQuantityAtLocation mutation? Bulk adjust is good in some scenarios, but very frequently forcing the inventory levels to a specific quantity is the only solution. Right now, and in the absence of this mutation, I'm calling a bunch of REST endpoints in a huge loop. That's far from efficient for either of us. Thanks for considering.

0 Likes