You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Product Variant price cannot be queried when using the unoptimized UMD and graphQLClient.
I need to fetch a list of products, along with the following properties:
title
price
available for sale
inventory
tags
The optimized script does not provide inventory or tags, so I must use the unoptimized version.
However, when I try to add the Variant price field to my query, it causes the query to return zero results.
To Reproduce
Steps to reproduce the behaviour:
Include the unoptimized UMD script
Enable Headless on Shopify & grant appropriate permissions
Define the client (w/ public token)
Run the following code:
Code sample
try {
const productsQuery = client.graphQLClient.query((root) => {
root.addConnection('products', {args: {first: 10}}, (product) => {
console.log('product def', product);
product.add('id');
product.add('title');
product.add('availableForSale');
product.add('totalInventory');
product.add('tags');
product.addConnection('variants', { args: { first: 5 } }, (variant) => {
console.log('variant def', variant);
variant.add('id');
variant.add('title');
variant.add('availableForSale');
variant.add('quantityAvailable');
// NOTE: Breaks when this line is added.
variant.add('price');
});
});
});
// Call the send method with the custom products query
client.graphQLClient.send(productsQuery).then(({model, data}) => {
// NOTE: These both return `undefined`.
console.log('model', model);
console.log('data', data);
});
} catch (err) {
console.log('err', err);
}
If I remove the following line, then the call returns the expected results.
variant.add('price');
Expected behavior
A clear and concise description of what you expected to happen.
The list of Products should be returned with the Variant prices included.
Environment (please complete the following information):
OS: MacOS
Browser: Chrome
SDK Version: v2.22.0
Additional context
I don't actually need Variants on my Products, but Shopify's API seems to always define price under Product Variant. I have tried adding a single variant as a workaround but it did not resolve this issue.
Bug details
Describe the bug
The Product Variant price cannot be queried when using the unoptimized UMD and graphQLClient.
I need to fetch a list of products, along with the following properties:
The optimized script does not provide inventory or tags, so I must use the unoptimized version.
However, when I try to add the Variant
price
field to my query, it causes the query to return zero results.To Reproduce
Steps to reproduce the behaviour:
client
(w/ public token)Code sample
If I remove the following line, then the call returns the expected results.
Expected behavior
A clear and concise description of what you expected to happen.
The list of Products should be returned with the Variant prices included.
Environment (please complete the following information):
v2.22.0
Additional context
I don't actually need Variants on my Products, but Shopify's API seems to always define
price
under Product Variant. I have tried adding a single variant as a workaround but it did not resolve this issue.Bug Report Checklist
The text was updated successfully, but these errors were encountered: