LoginSignup
1
0

More than 3 years have passed since last update.

Shopify JS Buy SDKでProductのtagsが取れない場合(Uncaught Error: No field of name "tags" found on type "Product)

Posted at

まずRead product tagsがONか確認

Shopify.png

サンプルコードを参考にする

Initializing the Client(リンクページの下の方)

// fetch the large, unoptimized version of the SDK
import Client from 'shopify-buy/index.unoptimized.umd';

const client = Client.buildClient({
  domain: 'your-shop-name.myshopify.com',
  storefrontAccessToken: 'your-storefront-access-token'
});

Fetching Products(リンクページの下の方)



// 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
  });
});

// Call the send method with the custom products query
client.graphQLClient.send(productsQuery).then(({model, data}) => {
  // Do something with the products
  console.log(model);
});

ここで注目しないといけないのはClientのimport

// import Client from 'shopify-buy'; ではだめ
import Client from 'shopify-buy/index.unoptimized.umd';

上のやり方だと、variantsとかどう取るの?

Re: fetchWithProducts() not returning tags

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0