productVariants with updated_at:>= query returns invalid results

Dear Shopify Product Manager,

I’m probably doing something wrong, but I get an invalid set of results when I query for a set of variants with updated_at >= an ISO-8601 timestamp. Interestingly, the issue seems to resolve itself once we start a new day in UTC time.

Here’s the important part of the GQL query:

query {
  productVariants(first: 250, query: "updated_at:>=#{updated_after}", after: #{cursor}) { 
  ...
  }
}

If updated_after = "2024-11-26T23:59:11Z" I get a set of 3 variants with the following timestamps:

"2024-11-26T20:33:06Z"
"2024-11-26T20:33:03Z"
"2024-11-26T21:14:55Z"

It seems to me that none of those variants would be returned since none of them have updated_at timestamps >= "2024-11-26T23:59:11Z"

However, querying with updated_after = "2024-11-27T00:00:11Z", the API correctly returns 0 results.

I’d like to add that I’m using 2024-10.

I get the exact same problem. The problem is that : is a separator character for queries. So it treats the time part of the timestamp as another query (because it contains colons).
This “additional query” is invalid, but almost silently ignored. If you have another issue in your query, it will appear in the error output (but as a simple warning I guess).
Anyway, this is really problematic for sync purposes, so I hope that we can get a quick response from support!

1 Like

I think I figured it out. In their range query example, they are wrapping the timestamp in single quotes:

{
  products(first: 5, query: "created_at:>'2020-10-21T23:39:20Z'" ) {
    edges {
      node {
        id
        title
        createdAt
      }
    }
  }
}

That seems to fix the issue for me.

Very nice! If anyone at Shopify is listening, this should be made clearer in the doc.