fetchWithProducts() not returning tags

I found the answer. It seems like you can’t do that with fetchWithProducts(), but if you make a custom query you can. Here is the code I found

const query = client.graphQLClient.query((root) => {
   root.addConnection('products', {
      args: { first: 250, query: "collection_type:{{name of collection}}" }
   }, (Product) => {
      Product.add('title');
      Product.add('tags');// Add fields to be returned
      Product.addConnection('variants', { args: { first: 250 } }, (variants) => {
         variants.add('product');
	 variants.add('title');
	 variants.add('price');
	 variants.add('sku');
      });
   });
});

client.graphQLClient.send(query).then(({ model, data }) => {
   console.log(model);
});

Hope this helps anyone else.

1 Like