Hi,
Our wms uses webhooks to post new stock levels to our Shopify app.
Our Shopify app will try to find the product by Sku and will also fetch the inventoryItem using a GraphQl Query.
However it seems that when a product is less then a day old the information will not be fetched correctly the first time.
The response will remain empty and as a result we cannot update to stock information for our client.
We use the following query to fetch necessary data for creating a new inventory_level entry:
Query {
productVariants(first: 1, query: "sku:\"$sku\"") {
edges {
node {
inventoryItem {
legacyResourceId
inventoryLevels(first:5) {
edges {
node {
available
}
}
}
}
}
}
}
}
This GraphQL query results in a empty response for a product which is less then a day old.
Can anyone confirm this? Should we handle new product different then existing products?
Thanks in advance for any responses/answers.
If you need more information, please ask!
Thanks.
The query shown in the example is created in PHP. so its a variable passed into the string. the resulting query would look like this:
{
productVariants(first: 1, query: "sku:\"KS1782-rose-1m\"") {
edges {
node {
inventoryItem {
legacyResourceId
id
inventoryLevels(first: 5) {
edges {
node {
available
}
}
}
}
}
}
}
}
We are surrounding the sku with double quotes because we had issues retrieving products with spaces in it.
The query as shown is working for all products. except for products which are created within the last 24 hours or so.
Not sure I'm following you...the examples I provided worked based on what I saw. If you are looking to just fetch newly-created products there are ways you can fetch a set of them based on their "date in-stock", in addition to just pulling by specific SKU. Take a peek around the GraphQL API docs and you'll see there is nice functionality!
User | Count |
---|---|
14 | |
9 | |
8 | |
7 | |
5 |