GraphQL - Find order by "name"

Billy_Griffiths
Shopify Partner
17 0 6

I'm currenlty trying to get to grips with GraphQL and wanting to query "Orders" to find an order by "name" (ie: #1003). This filter parameter does not seem to be supported by GraphQL. Can additional filter parameters be requested, or is this a fixed list? 

If I am not able to do this using GraphQL, is there a reliable way using the REST API? 

 

 

Web development using (primarily) CakePHP. Trying my hand at Shopify Apps.
KarlOffenberger
Shopify Partner
1867 182 777

Hi Billy G

Is there a reliable way using the REST API?

Neither unreliable or reliable - there's no way in REST Admin API either - in fact, it haseven less possibilities to filter IIRC.

I guess your only solution is to request @Shopify that the name field be added to the list of possible query filter parameters.

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
Billy_Griffiths
Shopify Partner
17 0 6

Hi Carl, 

It is not documented, but I've found the following REST API request to return a `name` filtered result, for example: 

https://<storename>.myshopify.com/admin/orders.json?name=%231002

This request returns a 267-line JSON response, which I find slightly inefficient seeing as, when using GraphQL, I could select the exact nodes I need. I have also not played around with it enough to establish the reliability of this method. 

How do I go about requesting this filter be added to GraphQL by @Shopify?

 

Web development using (primarily) CakePHP. Trying my hand at Shopify Apps.
KarlOffenberger
Shopify Partner
1867 182 777

Ooo... good to know. I trued that in the past and it didn't work. I tried again now that you mentioned it and I was thinking

nah man, how on earth did he do that?

and it didn't work!

So unlike regular GET order by ID endpoint i.e. /admin/orders/{order_id}.json when you use the name filter (possibly others too) on a fulfilled order (thus, archived) it won't work.

Unfulfilled orders work like a charm using name filtering.

Cool,nice catch Billy G and thanks!

p.s. As for how to request @Shopify for a feature - no idea, try contacting support via chat to check, or ask here and pray nobody offers you an app that does "feature requests for Shopify partners" @ 20 bucks a month ;-)

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
Billy_Griffiths
Shopify Partner
17 0 6

So unlike regular GET order by ID endpoint i.e. /admin/orders/{order_id}.json when you use the name filter (possibly others too) on a fulfilled order (thus, archived) it won't work.

Unfulfilled orders work like a charm using name filtering.

If you are dealing with a fulfilled order, add `&status=any`. Voila! :) How reliable this undocumented method is, is questionable. 

/admin/orders.json?name=%231002&status=any

As for how to request @Shopify for a feature - no idea, try contacting support via chat to check, or ask here and pray nobody offers you an app that does "feature requests for Shopify partners" @ 20 bucks a month ;-)

LOL! Will do just that, thanks! 

Web development using (primarily) CakePHP. Trying my hand at Shopify Apps.
Billy_Griffiths
Shopify Partner
17 0 6

So there is a problem with this method...

/admin/orders.json?name=%231002&status=any

Under certain conditions (order older than 60-days?) it seems to be doing a "like" instead of an exact match, so searches for '1002' will return results for '10021', '10022', '10023' etc. etc.

This is not ideal. I still think being able to filter by 'name' via GraphQL (properly) would be great. 

Web development using (primarily) CakePHP. Trying my hand at Shopify Apps.
Yu727
Excursionist
38 0 5

Hi @Billy_Griffiths 

To get all orders(older than 60 days), you have to require access to read all orders for your app.

0 Likes
HunkyBill
Shopify Expert
4369 36 463

Is this still a thing? I am given the order name, ie) #65478 and I need that order. In the Shopify admin it comes up no trouble, but with RestAPI one could never search using the name attribute, and it seems GraphQL also is kneecapped this way. Why? Do I have to resort to calling the search endpoint for the shop to deal with this? That seems silly.

 

What is the scoop on this? Why would we not be able to search given the name? Interestingly if I search for a reference or source_identifier value, I get my record, simply by setting the query. ie)

 

{
query: "113-7672643-1234-5567"
}

Returns me order #65478 when the query matches the reference or source_identifier, but in the case where all I have is the actual Shopify order name, #65478 I do not get anything useful back. So this is a huge cosmic black hole of nothing good unless I am incorrect in all my tests. What does one do?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
fabz
Shopify Partner
2 0 1

This leaves me scratching my head in disbelieve. The order name is usually the first thing people search for, why is this still not supported?

ritsybitsy
Tourist
5 0 8

I too am flabbergasted by the sheer stupidity of

a) not having it by order_name

b) not clearly differentiating between order_name and order_id - most people assume the order_id is the order_name

 

SO stupid.