Buy SDK Graphql not returning tags with documented example

rpk98c
Shopify Partner
1 0 0

Hi,

 

I'm using the unoptimised buy SDK to create a query to get the tags on product items. 

 

The docs here have a nice example:

 

https://shopify.github.io/js-buy-sdk/

// Build a custom products query using the unoptimized version of the SDK
const productsQuery = client.graphQLClient.query((root) => {
  root.addConnection('products', {args: {first: 10}}, (product) => {
    product.add('title');
    product.add('tags');// Add fields to be returned
  });
});

However, when I send this query I always get null returned. If I remove the tags then it works as expected. E.g this deos work:

// Build a custom products query using the unoptimized version of the SDK
const productsQuery = client.graphQLClient.query((root) => {
  root.addConnection('products', {args: {first: 10}}, (product) => {
    product.add('title');
    // tags removed and it works
  });
});

From testing I seem to be able to add any field, apart from the `tags`.

 

Any ideas how to get the `tags` returned?

 

Many thanks for any help in advance. 

0 Likes
KarlOffenberger
Shopify Partner
1867 182 776

Not sure how you have set this up, but when I give it a spin over at codepen, it works as advertised.

 

See for yourself (just add your storename and API token). Should work.

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
Spencer_Snyder
Shopify Partner
2 0 0

I was annoyed not having tags by default on the SDK and having to try to do all the custom stuff with "unoptimized" package. Everything else is exactly the same as the original SDK - https://www.npmjs.com/package/shopify-buy-with-tags

0 Likes