What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Fetching updated products using filter by updated_at using graphql not working

Solved

Fetching updated products using filter by updated_at using graphql not working

Ananthesh
Visitor
3 0 1

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)
awwdam
Shopify Staff
249 42 38

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 7 (7)

Ananthesh
Visitor
3 0 1

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
249 42 38

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

JesusLebt2
Tourist
12 0 0

Same problem here with the current graphql Api 2022-01:

{"query":"query {orders(first: 5, query: \"updated_at:>2022-02-01T23:00:00Z\") {edges{node{updatedAt}}}}"}

returns also orders, which was edited today but before 23:00:00 o clock:

(object) array(
   data => 
  (object) array(
     orders => 
    (object) array(
       edges => 
      array (
        0 => 
        (object) array(
           node => 
          (object) array(
             updatedAt => 2022-02-01T17:55:57Z,
          ),
        ),
        1 => 
        (object) array(
           node => 
          (object) array(
             updatedAt => 2022-02-01T11:38:25Z,
          ),
        ),
        2 => 
        (object) array(
           node => 
          (object) array(
             updatedAt => 2022-02-01T03:55:28Z,
          ),
        ),
      ),
    ),
  ),
   extensions => 
  (object) array(
     cost => 
    (object) array(
       requestedQueryCost => 7,
       actualQueryCost => 5,
       throttleStatus => 
      (object) array(
         maximumAvailable => 1000.0,
         currentlyAvailable => 995,
         restoreRate => 50.0,
      ),
    ),
  ),
)

I can not see what I'm doing wrong.

JesusLebt2
Tourist
12 0 0

The docs also does only provide an example with a date not with a date time, so it seems not to be implemented:

 

https://shopify.dev/api/admin-graphql/2022-01/queries/orders#examples-Get_the_first_10_orders_update...

Dep32
Shopify Partner
2 0 0

Hi, The issue is real. I tried the latest api also. Filter on the date is not working.

 

The below query is fetching dates that are less than the one specified in the filter

```

{

products(first:5,query:"updatedAt:>2023-10-14") {
edges {
node {
prodId:id
prodTitle:title
productType
vendor
handle
updatedAt

}
}
}
}

```


@awwdam wrote:

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 wrote:

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

 

 

 

 

 

 


 

Dep32
Shopify Partner
2 0 0

Just tried updated_at instead of updatedAt. It worked. 

Not sure though but this should be the issue.

RobFarmLink
Shopify Partner
43 2 44

Make sure to wrap your date string in single quotes like this:

 

query:"updated_at:>'2021-10-13T19:17:05Z'"