Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
How can I get product tags by making a query for products in a specific collection? The error I get here: No field of name "tags" found on type "Product" in schema
const query = shopifyClient.graphQLClient.query((root) => {
root.add(
"collectionByHandle",
{ args: { handle: "collection-handle" }, alias: "collection" },
(Collection) => {
Collection.add("id");
Collection.addConnection(
"products",
{
args: {
first: 25,
},
},
(Product) => {
Product.add("title");
Product.add("handle");
Product.add("tags"); /* Couldn't get tags?! */
Product.addConnection(
"variants",
{ args: { first: 25 } },
(Variant) => {
Variant.add("price");
}
);
Product.addConnection(
"images",
{ args: { first: 1 } },
(Image) => {
Image.add("src");
}
);
}
);
}
);
});
shopifyClient.graphQLClient
.send(query)
.then(({ model }) => {
// Some logic
})
.catch((err) => {
console.log("err", err);
});
Any suggestions here? Thanks in advance.
Must be a quirk in the client library you are using. If you refer to a post that I replied to just today, you'll see that the GraphQL query in its raw form successfully retrieves the product tags. Tested it out before I hit the Post button!
Hello,
can you please share the URl where you are requesting. if its a link for collection like
"/admin/api/2020-07/collections/841564295.json"
then error is good because there is no tag in it. and if you are using
"/admin/api/2020-07/collections/{collection_id}/products.json"
then this error should not come.