Re: Query 5 most recent orders via GraphQL Admin API

Solved

Query 5 most recent orders via GraphQL Admin API

buildpath
Shopify Partner
59 11 20

I've been unable to find the answer in documentation, SO or this community so far, so I have to ask:

 

How do I get the last 5 most recent orders via GraphQL Admin API?

My current query is below. I also tried using last:5  but it requires a before param and I don't understand why or how to use that. Also please correct my customAttributes query syntax if it's wrong.

{
        orders(first:5) {
          edges {
            node {
              id
              name
              customAttributes
              {
                key:value
              }
              
            }
          }
        }
      }

 

Ecom entrepreneur since 2004 | Shopify App developer since 2021 | Shopify merchant and theme developer since 2016
Accepted Solution (1)

buildpath
Shopify Partner
59 11 20

This is an accepted solution.

I finally found the answer (sorry, can't remember the source and don't have the link anymore). The solution is to use first: 5, and reverse: true to make it the last 5 most recent orders

 

orders(first: 5, reverse:true) 

 

Ecom entrepreneur since 2004 | Shopify App developer since 2021 | Shopify merchant and theme developer since 2016

View solution in original post

Reply 1 (1)

buildpath
Shopify Partner
59 11 20

This is an accepted solution.

I finally found the answer (sorry, can't remember the source and don't have the link anymore). The solution is to use first: 5, and reverse: true to make it the last 5 most recent orders

 

orders(first: 5, reverse:true) 

 

Ecom entrepreneur since 2004 | Shopify App developer since 2021 | Shopify merchant and theme developer since 2016