client.product.fetch(productId) not returning product's Tags

Solved
Highlighted
Shopify Partner
6 1 3

Using JS Buy SDK I'm trying to get all fields from a product using the following code (from here).

client.product.fetch(productId).then((product) => {
  // Do something with the product
  console.log(product);
});

It seems to return everything else, but not product Tags. Is there something I'm overlooking, or should I be trying to retrieve the product another way?

0 Likes
Highlighted
Shopify Partner
6 1 3

This is an accepted solution.

Finally worked out an alternative, albeit longwinded, way.

 

 

const productsQuery = shopClient.graphQLClient.query((root) => {
  root.addConnection('products', { args: { first: 1, query: 'id:{{the_product_id}}'}}, (product) => {
    product.add('title');
    product.add('tags');
    product.add('availableForSale');
    product.add('createdAt');
    product.add('updatedAt');
    product.add('descriptionHtml');
product.add('handle'); product.add('productType'); product.add('vendor'); product.add('publishedAt'); product.add('onlineStoreUrl'); product.addConnection('images', { args: { first: 250 } }, (images) => { images.add('src'); images.add('id'); images.add('altText'); }) product.addConnection('variants', { args: { first: 250 } }, (variants) => { variants.add('id'); variants.add('product'); variants.add('title'); variants.add('price'); variants.add('image', (image) => { image.add('src'); image.add('id'); image.add('altText'); }) variants.add('selectedOptions', (opts) => { opts.add('name') opts.add('value') }) }) }) }); shopClient.graphQLClient.send(productsQuery).then(({product, data}) => { console.log(JSON.stringify(product, null, 4)); });

 

 

0 Likes
Highlighted
New Member
1 0 0

I'm looking for a way to return the product tags for the line items in a cart. How can I query for just those products' tags? Thanks!

0 Likes