Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: When using GraphQL to update products, inventory is getting reset to 0

When using GraphQL to update products, inventory is getting reset to 0

mokozuki
Shopify Partner
3 0 3

Hi.

New to shopify, trying to connect it to a custom middleware. I need to update products on a daily basis and update stock every 15 minutes. at the moment i have set up the product sync, but every time it is run, the stock of each product is reset to 0. is this because I don't specify the id of the variant?

This is the first time i am working with GraphQL, I am old and this just seems so much more convoluted than the good ole REST way. But there is no good bulk update in the REST api, so I have no choice but to learn new things. Below is the query i use:

 

$query = 'mutation productUpdate($input: ProductInput!) {
   productUpdate(input: $input) {
      product {
         descriptionHtml
         id
         status
         tags
         title
         variants(first:1) {
            edges {
               node {
                  barcode
                  price
                  sku
                  weight
                  weightUnit
               }
            }
          }
          vendor
       }
       userErrors {
          field
          message
       }
    }
 }';

 

any help or nudges in the right direction is appreciated

 

Replies 2 (2)

lizk
Shopify Staff
246 58 79

Hi there 👋

Could you also share the input variables that you are passing to the mutation?

To learn more visit the Shopify Help Center or the Community Blog.

mokozuki
Shopify Partner
3 0 3

problem was solved by adding the variant ID to the query and variables