GraphQL Collection - Product object - query filter (Doesn't work)

Highlighted
Shopify Partner
12 0 8

Hey guys, could use a quick hand.  The issue is simple: I'm trying to get Products From a Collection using the "query" filter.

So I am using the "Collections" object with a "Products" connection and a "query" filter on the products.
As documented, this Should Work: https://help.shopify.com/en/api/graphql-admin-api/reference/object/collection

(See "connections" -> "products" -> "query")

It works WITHOUT a "query" filter.  Even with a blank query filter (query="").  But when anything is put inside the "query" filter, it doesn't  work.  It returns an error "access denied".

Notes:

Made sure the Collection is a "smart" collection.

Made sure the query filter is formatted properly.
Tried querying without the "query" filter: (as mentioned, this works).
Trying another collection with the "query" filter: doesn't work.
Putting other things inside the "query" filter: doesn't work.
Made sure I have access (since obviously querying without the "query" filter works).
Checked docs

Examples:
Doesn't work:

 

{
  collection(id: "gid://shopify/Collection/21517762592") {
    products(query:"title:'test-title'", first: 10) {
      edges {
        node {
          id
} } } } }

 

 


Works:

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

Only difference:
The version that doesn't work has anything... Anything inside the "query" filter.


Any assistance would be hugely appreciated.
Thanks

Please let me know how to achieve this.

Thanks!

1 Like
Highlighted
Shopify Partner
12 0 8

It's not possible to get a collection's products and include a "query".

Can someone prove me wrong, please? :)

Thanks

0 Likes
Highlighted
Shopify Partner
69 0 15

I haven't been able to either. I don't believe querying in products within a collection is supported at the moment, which obviously begs the question: "How come it's shown as an option in the docs?"

1 Like
Highlighted
Shopify Partner
1 0 0

can anyone from Shopify Team provide any go to solution when it comes to filtering products from given collection? 

I've been going through some of the stores here: https://www.shopify.com/blog/shopify-stores
and clearly, other people didn't manage to succes with it either. 

 

Also, this code:

 

{
  products(first:5, query:"collection_type:t-shirt"){
    edges{
      node{
        id
      }
    }
  }
}

 

doesn't really work.  Whatever I put as a "collection_type" I always receive all products.

0 Likes
Highlighted
Shopify Staff
Shopify Staff
4 0 1

Hi, 


Thanks for letting us know. 

 

`Collection_type` receives either the value `smart` (to return `automatic` collections) or `custom` to return `manual` collections. 

{
  products(first:5, query:"collection_type:smart"){
    edges{
      node{
        id
      }
    }
  }
}

 

We will update the documentation. 

 

Thanks, 

Ignacio

1 Like
Highlighted
Shopify Partner
17 1 3

Could you add these values to the documentation, please? They're not mentioned in the schema since this field is just a string. Thanks!

0 Likes