Maybe I'm doing it wrong but I actually just want the refund line items (lineItem id and restocked flag) but it seems that I can't get those with the orders. I can only get a list of refund ids extracted from the orders. So I want to just perform another bulk query to get those refunds.
Update: Bummer, seems that refunds can't be queried anyways so this appears to be double impossible.
I just did an indepth AUDIT for a merchant new to Shopify, whereby she needed to accurately assess her cost of good sold during the half year of 2020. Shopify cannot do this. So I did it, and along the way, I had to deal with orders and refunds. And stock. So I used this query, which was fine for these purposes.
NOTE: I AGREE 100%. The GraphQL and refunds is currently not consistent, and somewhat opaque, and only by lots of trial and error did I figure it out. I exposed my questions, and of course, NO ONE on these forums contributed one iota of help. Crickets do chirp.
mutation{
bulkOperationRunQuery(
query:"""
{
orders(query:"created_at>'2020-06-01,created_at<'2020-07-01") {
edges {
node {
id
refunds {
id
restocked
refundLineItems {
edges {
node {
restocked
lineItem {
quantity
sku
}
}
}
}
}
}
}
}
}
"""
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}
I appreciate your reply but that query does not seem to work for me. Maybe you have a higher plan under which it works?
I receive this error, also restocked does not seem to be a field of refund, only of refundLineItems:
'Queries that contain a connection field within a list field are not currently supported.'
Which appears to just be that you can't fetch refundLineItems, only refund fields since refunds is a list and not a connection.
Oh, man... ya.. my bad. I copied from Insomnia, thinking I left the query in working condition, but that was not true. It was borked, and likely due to my request I made here, in these forums, about what a mess refunds are.
From my App.. actual working code... sorry about that previous effort. You can maybe riff off this.
# get orders and use cursors. First call has a null cursor, result of the calls provide one
# note the query format: "created_at:>'2020-06-01',created_at:<'2020-07-01'"
GetOrdersWithCursor = QueryWrap.new(<<~GRAPHQL)
query($cursor: String, $foo: String) {
orders(first: 50, after: $cursor, query: $foo) {
pageInfo {
hasNextPage
}
edges {
cursor
node {
id
legacyResourceId
refunds {
refundLineItems(first: 5) {
edges {
node {
restockType
lineItem {
sku
quantity
}
}
}
}
}
}
}
}
}
GRAPHQL
That query would work but I was trying to use a bulk operation query to get the orders for a batch job and it seems you can't use list fields in a bulk operation. So that means I have to make single calls for returns and fulfillments to get the full story of an order. I think I just have to rethink my entire strategy. Maybe I'll start another thread about it.
User | Count |
---|---|
13 | |
12 | |
7 | |
4 | |
4 |