Solved

Storefront API - Order by ID

wcw-matt
Shopify Partner
3 1 0

How would you access an order by its ID using the GraphQL Storefront API? 

I've got this, however it will only work for the standard API.

query {
node(id: "gid://shopify/Order/56765457676") {
id
... on Order {
id
}
}
}

 

As it's not a root node, would I need to access it only through, say, a query on the customer? If so, how would I specify the specific order by ID, instead of just return the first x number of orders.

  query getCustomer(\$token: String!) {
customer(customerAccessToken: \$token) {
email
orders(first: 5) {
edges {
node {
orderNumber
processedAt
totalPriceV2 {
amount
}
}
}
}
}
}
Accepted Solution (1)

wcw-matt
Shopify Partner
3 1 0

This is an accepted solution.

Looks like I could use the first option, the ID I was passing was actually the order number. 

View solution in original post

Replies 5 (5)

wcw-matt
Shopify Partner
3 1 0

This is an accepted solution.

Looks like I could use the first option, the ID I was passing was actually the order number. 

rohantaneja-dh
Tourist
3 0 1

Hi @wcw-matt , just for clarification, you were able to query an order's details using the storefront graphql API? Can you please elaborate on what query/mutation did you use exactly?

wcw-matt
Shopify Partner
3 1 0

I was, details in my previous messages.

dsolano
Tourist
7 0 7

Hey @wcw-matt . Glad you were able to resolve. Can you please expound on how you resolved this? I didn't see any "details in your previous message" that pointed out what you actually did to resolve it.

 

I assume the order ID you have in your original post is not correct, so what ID did work for you?

 

Thanks!

raRaRa
Visitor
3 0 0

You can also use the query to fetch order by order id (the ID you get after base64 decoding it), e.g.:

 

 

      query {
        customer(customerAccessToken: "${customerAccessToken}") {
          orders(first: 1, query:"id:4458007855294") {
            edges {
              cursor
              node {
                id
                name
...