A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I am trying to build a dashboard using the GraphQL API.
I have put together a query that gives me order id and name from a certain date range which then provides me lineItems, fulfillmentStatus, title, quantity on the order, sku, variantTitle, and any customAttributes found on the orders within the date range:
mutation { bulkOperationRunQuery( query:"""{ orders(query:"created_at:>2020-05-01-01T04:00:00Z created_at:<2020-07-30-01T04:23:59Z") { edges { node { id name createdAt lineItems(first: 15) { edges { node { fulfillmentStatus title quantity sku variantTitle customAttributes { value } } } } } } } } """ ) { bulkOperation { id status } userErrors { field message } } }
I poll the URL and get my JSONL file and then parse it within my BI program and I then massage the data.
The question I have regarding the query above is: Would it be possible to get the current on hand inventory as well so it appears next to each product listing?
I searched the documentation and it doesn't appear that there is a straightforward way to query the current inventory quantities based on products from the orders.
Solved! Go to the solution
This is an accepted solution.
Hey @ner,
This should work if you query the variant connection on lineItems
{
orders(query:"created_at:>2020-05-01-01T04:00:00Z created_at:<2020-07-30-01T04:23:59Z") {
edges {
node {
id
name
createdAt
lineItems(first: 15) {
edges {
node {
fulfillmentStatus
title
quantity
sku
variantTitle
customAttributes {
value
}
---------
variant {
inventoryQuantity
}
---------
}
}
}
}
}
}
}
JB | Solutions Engineer @ Shopify
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
This is an accepted solution.
Hey @ner,
This should work if you query the variant connection on lineItems
{
orders(query:"created_at:>2020-05-01-01T04:00:00Z created_at:<2020-07-30-01T04:23:59Z") {
edges {
node {
id
name
createdAt
lineItems(first: 15) {
edges {
node {
fulfillmentStatus
title
quantity
sku
variantTitle
customAttributes {
value
}
---------
variant {
inventoryQuantity
}
---------
}
}
}
}
}
}
}
JB | Solutions Engineer @ Shopify
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
That works when I port it over to my bulk query (with addition of a curly bracket to complete the statement for bulk queries).
Now I have to parse the inventoryQuantity field to make it discreet attribute of each line/SKU
Thanks!