Shopify buy sdk Expand queries

I’m trying to get products by tags. The query is:

let query = {
query: "tag:'backpack_large' OR tag:'backpack' OR tag:'glass'"
}

client.products.fetchQuery(query).then((products) => {
console.log(products)
})

Everything is ok, the product data is coming in. But the product variants don’t have the necessary quantityAvailable field.
I read that quantityAvailable is disabled by default in the query to optimize query time.

I also read about Expanding the SDK. There’s an example of adding a field, but to query all the unfiltered 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);
});

I don’t quite understand how to do this in my case, to query not all products, but by key tags.
Thanks in advance)

I figured it out. Below is the working code for the query with additional fields.

const productsQuery = client.graphQLClient.query((root) => {
                root.addConnection('products', {args: {first: 10, query: "tag:'backpack_large' OR tag:'backpack' OR tag:'glass'"}}, (product) => {
                    product.add('title');
                    product.add('availableForSale');
                    product.add('tags');
                    product.addConnection('variants', {args: {first: 10}}, (variant) => {
                        variant.add('quantityAvailable');
                        variant.add('sku');
                        variant.add('price');
                        variant.add('compareAtPrice');
                        variant.add('title');
                        variant.addField('compareAtPriceV2', {}, (compareAtPriceV2) => {
                            compareAtPriceV2.add('amount')
                            compareAtPriceV2.add('currencyCode')
                        })
                        variant.addField('priceV2', {}, (priceV2) => {
                            priceV2.add('amount')
                            priceV2.add('currencyCode')
                        })
                    })
                })
            })

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