Fetching updated products using filter by updated_at using graphql not working

Solved
Ananthesh
New Member
2 0 0

To synchronize the updated products from shopify to our plugin, We are using graphql API to fetch the updated products at regular interval. 

For the following request, it is expected to return products for which updated_at field greater than 15:39 GMT.

 

{
    "query": "{ products(first:10, query:\"updated_at:>2021-10-05T15:39:01Z\") { edges { node { id title updatedAt } } } }"
}​

 

But in the API response we are seeing products which has updated_at before 15:39, Here is the screenshot:

Screenshot 2021-10-05 at 9.47.54 PM.png

 

This looks like the issue from API, How can i get the resolution for this? 

Accepted Solution (1)

Accepted Solutions
awwdam
Shopify Staff
172 32 17

This is an accepted solution.

Hey @Ananthesh,

After some testing on my end, I found no issues with query arguments using multiple parameters from the list available in GraphQL for Products queries. This worked when using updated_at and other arguments like created_at, each returning expected results, including several requests to navigate additional timeframes, as well as using the : > 'greater-than' and other comparators in the query argument string.  

I would suggest working through some more testing, reviewing our detailed documentation on API search syntax here and consider using the most recent API version as a starting point moving forward.

- Cheers!

Here is an example of a successful request made in Postman, API Version 2021-10, and the GraphQL body type:

 

 

 

 

POST {shop}.myshopify.com/admin/api/2021-10/graphql.json

{
  products(first: 5, query:"updated_at:>2021-10-13T19:17:05Z"){   // replace updated_at with specific time
    edges {
      node {
        id
        updatedAt
        title
      }
    }
  }
}

 

 

 

 

 

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 2 (2)
Ananthesh
New Member
2 0 0

I have noticed one more thing, The products updated at certain time of the hour will be available with filtering of updated_at field upto the next hour. 

Here, Product got pulled up with filter greater than 15:59

Screenshot 2021-10-06 at 9.57.15 AM.png

 

But these 2 products stopped coming when the filter is greater than 16:00

Screenshot 2021-10-06 at 9.57.29 AM.png

 

awwdam
Shopify Staff
172 32 17

This is an accepted solution.

Hey @Ananthesh,

After some testing on my end, I found no issues with query arguments using multiple parameters from the list available in GraphQL for Products queries. This worked when using updated_at and other arguments like created_at, each returning expected results, including several requests to navigate additional timeframes, as well as using the : > 'greater-than' and other comparators in the query argument string.  

I would suggest working through some more testing, reviewing our detailed documentation on API search syntax here and consider using the most recent API version as a starting point moving forward.

- Cheers!

Here is an example of a successful request made in Postman, API Version 2021-10, and the GraphQL body type:

 

 

 

 

POST {shop}.myshopify.com/admin/api/2021-10/graphql.json

{
  products(first: 5, query:"updated_at:>2021-10-13T19:17:05Z"){   // replace updated_at with specific time
    edges {
      node {
        id
        updatedAt
        title
      }
    }
  }
}

 

 

 

 

 

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post