Have your say in Community Polls: What was/is your greatest motivation to start your own business?
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.

Cart Token in Order GraphQL object in Admin API

Cart Token in Order GraphQL object in Admin API

zarma
Shopify Partner
7 0 4

I have been digging deep into the Orders GraphQL object but I can't believe that cartToken is not a field in there - https://shopify.dev/api/admin-graphql/unstable/objects/Order#fields

 

For my purpose, I am looking up orders from cartTokens. Since I have a lot of cartTokens, I am sending a list of cartTokens as a query parameter as

orders(first: 20, query:"cartToken1 OR cartToken2 OR ...") {...}

And when I get back the response, I have no idea which cartToken is part of which order since not all cartTokens have converted to an order. If only the cartToken was part of the order object. It is sadly part of the REST API but I am unable to query by cartToken in there https://shopify.dev/api/admin-rest/2022-01/resources/order#resource-object

 

Does anyone have some suggestions? Thanks!

Reply 1 (1)

zarma
Shopify Partner
7 0 4

The solution I am thinking of is a little gross:

First fetch list of all order ids from the GraphQL endpoint, then concatenate all the id fields and send it to the REST api's GET /orders endpoint to retrieve the cart tokens.

I prefer this method over all the other terrible ideas I had since this approach at least prevents me from looping over all orders within a date range.