A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm currently working on querying Shopify collections using the GraphQL Storefront API. I'm trying to retrieve collections where a specific metafield (filtering_category) has a value of 'Theme'.
Here's the GraphQL query I'm using:
{ collections( first: 250 query: "metafield: { key: 'filtering_category', value: 'Theme' }" ) { pageInfo { startCursor hasNextPage } edges { node { id title } } } }
However, despite having collections with filtering_category set to 'Theme', the query is not returning any results. Could you please advise if there's anything specific I should check or adjust in my query to ensure it correctly filters based on metafields?
Thank you for your assistance.
On the query line can you try:
query: "metafields.namespace_key:'namespace.filtering_category' AND metafields.value:'Theme'"
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi folks 👋 - just following up here. You are correct @Eric-HAN - at the moment, we don't support query filtering for metafields on the Storefront API's collection object. My understanding is that at the moment, the only way to query those values directly on collections themselves is through Liquid: https://community.shopify.com/c/shopify-scripts/get-collections-by-meta-fields-i-want-to-filter-vend... .
Definitely understand that this isn't the most ideal though, so I'm going to put through a note up to our developers to consider adding metafield query filtering on collections as a possible feature in a future release.
I can't guarantee anything on my end, but did just want to confirm that I'll send that feature request up to our developers right away here.
Thanks for the clarification there - really appreciated!
- Al
Shopify Developer Support
Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi Al 👋,
Thanks for the quick follow-up and for confirming that you'll send the feature request to the developers—much appreciated!
In addition to the request for metafield query filtering on collections, it would be incredibly useful if we could also have a way to filter collections based on specific metafields or similar criteria. This functionality would greatly enhance our ability to create more dynamic and tailored storefront experiences.
Thanks again for your support and for considering this additional request!
Best regards,
Andi
Hi, there
Based on the doc . Storefront api only supports 3 fields in query param not covering metafield.