Why does GraphQL does not return all products by title, but the Admin API does?

Highlighted
Tourist
9 0 1

So, I'm trying to do a fairly simple thing: I want to do a query which returns all the products by title.

When I do it with Admin API like this: /admin/api/2019-07/products.json?title=<title> it returns what it should, all the products that have that title.

But when I try it with GraphQL, which is like this:

{
  products(first: 40, query: "${title}" ) {
    edges {
      node {
        id
        title
       }
    }
  }
}

It doesn't return all the products. Sometimes it returns less than it should, sometimes none at all.


Am I doing something wrong in the query?
0 Likes
Highlighted
Shopify Expert
4266 32 434

Try updating your API calls to 2020. We are now at 2020-10 for stable work, and your 2019-07 from last summer is certainly different. It can make a difference as a lot of the the schema options you see in the documentation are not actually implemented yet, for sure not in that old API. Once you establish the newer one, post a result too, especially as you are limiting your call to 40 results with no options for paging. So clearly if you had 89 titles the same, you'd only ever get 40 with your call. Title is problably supported OK, but who knows for sure whether it is or not. Only testing will tell you.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
Tourist
9 0 1

Hi HunkyBill and first thank you for your answer!

The problem is not on Admin API. Yes, I updated it to 2020-10 and the results are the same and correct. My problem is with GraphQL results.

Also, this is not a problem with limitation either. I only expect max 8 results.

Here's an example:

When I try to search for the product with title: ''PLD D419".

This request: admin/api/2020-10/products.json?title=PLD%20D419 returns me this: https://prnt.sc/v9o4o1. We're ok here.

But the GraphQL request that I pasted above returns this: https://prnt.sc/v9o5ei

0 Likes
Highlighted
Shopify Expert
4266 32 434

You should first off dump your query out to see if you are getting is set properly, because while it seems obvious, sometimes that gets screwed up. When you run that in Insomnia or GraphiQL you are getting crap too? Has it ever worked for you?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
Tourist
9 0 1

Yeah, tried it on Insomnia and got the same results.

0 Likes
Highlighted
Shopify Expert
4266 32 434

What is your actual query? Without that, no one can help you much.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
Tourist
9 0 1

The one that I pasted on the main question.

This:

{
  products(first: 40, query: "${title}" ) {
    edges {
      node {
        id
        title
       }
    }
  }
}
0 Likes
Highlighted
Shopify Expert
4266 32 434

My test store has plenty of products with the word "plant" in the title. So you'd think a simple query:"title:plant" would return them, but it does not. I get one and one only. In fact, through messing around a lot, the only query that sort of works for me, for no reason I can figure is query: "title:plant*"  which returns to me a healthy list of my plant products, whereas title:*plant does not. So I guess it remains a * or something for you to use.

Maybe try fiddling there. Who knows. We cannot see what is going on under the hood and the docs are skinny on helping there.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes
Highlighted
Tourist
9 0 1

I tried that also because it was mentioned in another post here, but still, the results are the same.

Anyway, thanks for your time!

0 Likes
Highlighted
Shopify Expert
4266 32 434

"{$title}" could be anything. That is not what I was looking for. If you don't provide ACTUAL what the computer is processing data, of course you'll have sketch results. I am not dumb, I saw your code, and that is why I asked. If your variable is wrong, GARBAGE IN GARBAGE OUT...

 

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes