Getting "access denied" when querying with "published_status:published" (collections -> products)

Kris_Doyle
Shopify Partner
87 0 19

Hi All,

 

I'm currently using the Shopify GraphiQL App to test some GraphQL calls and I'm running into a strange issue. By the way, the GraphiQL App has all possible access scopes so I don't believe this is a permission issue.

 

In any case, this query works:

 

{
  collection(id: "gid://shopify/Collection/404960718") {
    products(first: 10) {
      edges {
        node {
          id
        }
      }
    }
  }
}

but this query (only difference is the addition of "query") returns "access denied" as an error in the response (although the actual response code is 200):

 

 

{
  collection(id: "gid://shopify/Collection/404960718") {
    products(first: 10, query: "published_status:published") {
      edges {
        node {
          id
        }
      }
    }
  }
}

however, this query works:

 

{
  products(first: 10, query: "published_status:published") {
    edges {
      node {
        id
      }
    }
  }
}

So obviously the scopes are OK (I think). It seems it only fails when it's a child of collection. Is this because this query option isn't available yet on the Collection > Product path? It's shown in the documentation as available so I'm not sure why I'm getting access denied.

 

Secondly, if it's not available yet, hence the access denied, is there another way to query published products in a specific collection? I normally use the REST Admin API but unfortunately it doesn't return products in their manually sorted order.

 

Thanks!

Alex
Shopify Staff
Shopify Staff
1555 81 294

This certainly appears to be a bug. I've reported this to our internal dev teams for investigation and will follow up here with any notable updates.

 

Cheers.

Kris_Doyle
Shopify Partner
87 0 19
Awesome, this would be a huge help so thanks!
0 Likes
Kris_Doyle
Shopify Partner
87 0 19

Hey Alex,

 

Just curious if you have any updates by chance? I have several users who are frustrated at the moment that I'm unable to provide this capability.

 

Thanks very much!

0 Likes
Alex
Shopify Staff
Shopify Staff
1555 81 294

Hey @Kris_Doyle, sorry for the delay.

 

So, interesting outcome. We initially thought this was a bug. However, after discussing it further and bringing more parties into the conversation, it appears to actually be intended. Not intended in the sense that this is how we want it to work as long as Shopify exists, but intended in the sense that we do not currently logically support the filtration of products within a collection context (we can do it for search only). The schema description itself was incorrect, so we're going to fix that first of all.

0 Likes
Kris_Doyle
Shopify Partner
87 0 19

Hi Alex,

 

Sorry, I don't mean to belabor this issue but I'm wondering what you mean by "we do not currently logically support the filtration of products within a collection context (we can do it for search only)". When you say you can do it for search only, which search are you referring to? Do you mean a query on the products GraphQL QueryRoot?

 

This would actually be alright but it looks like I can't include a "collection_id={collection_id}" as part of that query (according to the products docs anyways). Is that true? That seems to suggest that there's no way to tell which products in a particular collection aren't published. Am I right on that or is there a way?

0 Likes
Kris_Doyle
Shopify Partner
87 0 19

Hey @Alex,

 

Just following up on this one. Can you confirm something for me please?

 

Is it true that there's no way, using GraphQL, to retrieve only published products for a specific collection? This is available for the REST Admin API but the products aren't sorted so I can't use that. I see I can grab published products using the Products QueryRoot, but I can't say query:"collection_id:{some_id}" so although I can get only published products, I can't query by a specific collection. Is there a reason for that limitation?

 

Essentially, I need to be able to get only published products (sorted by their manual sort value), for a specific collection. Is there a way to do this? If not, will it ever be possible?

 

I was really hoping to use the Collection/Products approach, but on that one, I can't query only published products (access denied). Sorry, just stumped on this one.

Alex
Shopify Staff
Shopify Staff
1555 81 294

Hey @Kris_Doyle.

 

Sorry for the large delay. My team's been pretty occupied leading up to Unite but now I'm free to catch up on any ongoing stuff I had before, including this.

 

To clarify:

 

We pretty much don't support filtering products in GraphQL from a collection node, as represented by your initial example of the issue. Our search engine which is a different mechanism (elastic search) can handle that kind of functionality, but this isn't enabled for any stores yet through GraphQL.

 

To answer your latest question directly: There is no way when using GraphQL to retrieve only published products given a specific collection at this time. I did try and see if I could find any work-arounds but didn't have any luck unfortunately.

 

That said, I don't think this will never be possible with GraphQL. The fact that you can do it in REST (and that it's supported) means that it's something we're going to want to add. One of the major goals of the Admin GraphQL API is parity with the REST API.

 

While the current behaviour is expected in this moment, I'll make sure I raise it as a future consideration for improvement to the API.

 

If I missed any dimensions of your question let me know and I'll answer as best I can.

 

Cheers.

0 Likes
MagaliWD
Tourist
6 0 1

Hy,

Nothing new since about filtering products into collectionByHandle query in frontstore Api ??? It will be great !!! Thanks

0 Likes
janoschpelzer
New Member
1 0 2

Hello Alex, it's been almost 1.5 years and this problem still prevails.

Can you give us any update on how to solve this?

This is very basic functionality which is crucial for the search feature in our store to work.

Thanks.