graphql query by "cancelled_at" not working

Highlighted
Shopify Partner
17 0 3

I need to fetch orders that were cancelled within a particular date range:

This is my graphql query:

 

query {
  orders(first: 1, query:"cancelled_at:>2020-09-10") {
    edges {
      	node {
          id
          name
          cancelledAt
          totalPriceSet {
            shopMoney {
              amount
            }
          }
        }
    }
  }
}

 

 

This is the data I'm getting back:

 

  "data": {
    "orders": {
      "edges": [
        {
          "node": {
            "id": "gid://shopify/Order/1480320003",
            "name": "1020",
            "cancelledAt": null,
            "totalPriceSet": {
              "shopMoney": {
                "amount": "49.0"
              }
            }
          }
        }
      ]
    }
  },

 

 

The returned order was never even cancelled.

Is this a bug or am I doing something wrong?

Thanks!

0 Likes
Highlighted
Shopify Partner
520 38 109

Are you sure you are even able to query against the cancelled_at value? Looking at the API docs I don't see this listed as a query option --> https://shopify.dev/docs/admin-api/graphql/reference/object/order

0 Likes
Highlighted
Shopify Staff
Shopify Staff
582 70 127

Hey @Joseph_Chan,

The order object doesn't support querying directly on the cancelled_at field, but you can use the status field to find cancelled orders and optionally add an additional filter for updated_at. Something like this should work:

 

 

{
  orders(first: 25, query: "status:cancelled updated_at:>'2020-09-10'") {
    edges {
      node {
        id
        name
        cancelledAt
        totalPriceSet {
          shopMoney {
            amount
          }
        }
      }
    }
  }
}

 

 

 

JB | Developer Support @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes