GraphQL admin API InventoryItem query gives outdated data(!)

Solved

GraphQL admin API InventoryItem query gives outdated data(!)

Jacco-V
Shopify Partner
12 1 6

A GraphQL call to the admin API `InventoryItem` query endpoint returns outdated data. We have been able to reproduce this issue across multiple development stores, on 2 consecutive days.

 

Scenario:

  • Through the Shopify admin web UI, we edit the `Country/Region of origin` field for a single `productVariant` on a product with 3 `productVariants` in total,
    • we change the value from Netherlands (NL) to United Kingdom (GB),
  • We query the GraphQL admin API `InventoryItem` endpoint (see query 'A' and response below),
  • We notice the change is _not_ listed; the `updatedAt` shows an old date,
  • We query the GraphQL admin API `productVariant` endpoint (see query 'B' and response below) with the `InventoryObject` node included,
  • We notice the change _is_ listed; the `updatedAt` shows the new date.

 

We are stumped by this behaviour, and are forced to conclude this is some sort of error?

 

Any help in getting this fixed would be most appreciated.

 

 

 

 

GraphQL query A:

{
  inventoryItem(id: "gid://shopify/InventoryItem/44087721754782") {
    id
    sku
    updatedAt
    variant {
      id
      sku
    }
    countryCodeOfOrigin
    provinceCodeOfOrigin
  }
}

 GraphQL query A response:

{
  "data": {
    "inventoryItem": {
      "id": "gid://shopify/InventoryItem/44087721754782",
      "sku": "SMSL-13847-OC-M",
      "updatedAt": "2022-09-05T19:33:31Z",
      "variant": {
        "id": "gid://shopify/ProductVariant/41989857607838",
        "sku": "SMSL-13847-OC-M"
      },
      "countryCodeOfOrigin": "NL",
      "provinceCodeOfOrigin": null
    }
  },
  "extensions": {
    (...)
  }
}

 

GraphQL query B:

{
  productVariant(id: "gid://shopify/ProductVariant/41989857607838") {
    id
    sku
    updatedAt
    inventoryItem {
      id
      sku
      updatedAt
      countryCodeOfOrigin
      provinceCodeOfOrigin
    }
  }
}

 GraphQL query B response:

{
  "data": {
    "productVariant": {
      "id": "gid://shopify/ProductVariant/41989857607838",
      "sku": "SMSL-13847-OC-M",
      "updatedAt": "2022-09-03T12:42:05Z",
      "inventoryItem": {
        "id": "gid://shopify/InventoryItem/44087721754782",
        "sku": "SMSL-13847-OC-M",
        "updatedAt": "2022-09-06T08:55:56Z",
        "countryCodeOfOrigin": "GB",
        "provinceCodeOfOrigin": null
      }
    }
  },
  "extensions": {
    (...)
  }
}

 

note: while the queries shown above have been run in the 'Shopify GraphiQL App', we get the same results when querying directly from our own server.

 

senior software architect
Accepted Solution (1)

KB77
Shopify Staff
59 6 11

This is an accepted solution.

Hi @Jacco-V . We have tested this on some test stores and the updates in Scenario A appear to be registering immediately in our tests. It might have been attributable to some jobs delayed in the database during the period you were testing. If you are still able to replicate you can fill out a bug report form where you can include the details above on how the app in question is interacting with the API such as the request body and headers, as well any response errors and response headers (x-request-id, cursor) from the error and any details of the specific stores so we can investigate them using authenticated secure tools.  You can submit this issue using the Report an Issue Form here https://help.shopify.com/en/questions/partners#/contact/report-an-issue it will help expedite the process as this will enable us to authenticate access where necessary. Thank you.  

KB77 | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)

KB77
Shopify Staff
59 6 11

This is an accepted solution.

Hi @Jacco-V . We have tested this on some test stores and the updates in Scenario A appear to be registering immediately in our tests. It might have been attributable to some jobs delayed in the database during the period you were testing. If you are still able to replicate you can fill out a bug report form where you can include the details above on how the app in question is interacting with the API such as the request body and headers, as well any response errors and response headers (x-request-id, cursor) from the error and any details of the specific stores so we can investigate them using authenticated secure tools.  You can submit this issue using the Report an Issue Form here https://help.shopify.com/en/questions/partners#/contact/report-an-issue it will help expedite the process as this will enable us to authenticate access where necessary. Thank you.  

KB77 | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog