A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi Team,
I am looking for the graphql equivalent of the following REST endpoint (retrieve all transactions of a given order)
GET /admin/api/2023-07/orders/450789469/transactions.json
https://shopify.dev/docs/api/admin-rest/2023-07/resources/transaction#get-orders-order-id-transactio...
please suggest what should be used here?
Solved! Go to the solution
This is an accepted solution.
Hi Kiruthiga,
To retrieve all transactions of a given order using GraphQL, you can follow the pattern below:
{
order(id: "gid://shopify/Order/450789469") {
transactions(first: 100) {
edges {
node {
id
kind
status
amountSet {
shopMoney {
amount
currencyCode
}
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
}
You'll need to replace the 450789469
in gid://shopify/Order/450789469
with your actual order ID. This query will return the first 100 transactions of the specified order, including the transaction id, kind, status, and amount.
Also, note that the order ID is a global ID in the format of gid://shopify/Order/450789469
, not just a number. You can get the global ID from the response of a previous API request, or convert an order's regular ID to a global ID by prepending it with gid://shopify/Order/
.
Hope this helps!
Liam | Developer Advocate @ 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
I believe the equivalent on GraphQL is to request the Order.transactions object from an order query.
This is an accepted solution.
Hi Kiruthiga,
To retrieve all transactions of a given order using GraphQL, you can follow the pattern below:
{
order(id: "gid://shopify/Order/450789469") {
transactions(first: 100) {
edges {
node {
id
kind
status
amountSet {
shopMoney {
amount
currencyCode
}
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
}
You'll need to replace the 450789469
in gid://shopify/Order/450789469
with your actual order ID. This query will return the first 100 transactions of the specified order, including the transaction id, kind, status, and amount.
Also, note that the order ID is a global ID in the format of gid://shopify/Order/450789469
, not just a number. You can get the global ID from the response of a previous API request, or convert an order's regular ID to a global ID by prepending it with gid://shopify/Order/
.
Hope this helps!
Liam | Developer Advocate @ 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