Graphql query by "cancelled_at" not working

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!

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.

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
          }
        }
      }
    }
  }
}

I have got this to work but wonder why as status field is not available in graphql