Hi team,
Please can you help me with the query to access all metafields data of collections. We are planning to use the graphql query to build mobile apps.
Hi team,
Please can you help me with the query to access all metafields data of collections. We are planning to use the graphql query to build mobile apps.
Hi @pgupta
A basic query you can use to access collection metafields would be something like the following:
{
collections(first: 10) {
edges {
node {
id
title
metafields(first: 10) {
edges {
node {
type
definition {
key
name
namespace
}
}
}
}
}
}
}
}
Hope this helps!
Hi,
Thanks for the reply.
But i am receiving the following error message :
“message”: “Field ‘definition’ doesn’t exist on type ‘Metafield’”,
FYI, I am want to use storefront API to access the collection metafields.
Hi @pgupta
My apologies, I was assuming you were asking about the Admin API. For the Storefront API, please have a look at this resource: https://shopify.dev/api/storefront/reference/products/collection
Regards,
query { collection(id: “gid://shopify/Collection/”) {
id
title
handle
metafields (first: 5) {
edges {
node {
id
key
value
}
}
}
}
}