Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hey folks!
I have looked everywhere, and cannot find a solution to using sortKey in client.graphQLClient.send(). If someone can help me figure this one out, you'll be a lifesaver.
Where do I put the "sortKey" argument? Where on earth is the documentation for this, or am I just missing the mark big time?
My client needs to be able to sort Alphabetically, By Price, and Best Selling.
Thanks in advance!
Code:
Query
let productsQuery = client.graphQLClient.query((root) => {
root.addConnection('products', {args: { first: 10}}, (product) => {
product.add('title');
product.add('descriptionHtml');
product.add('totalInventory');
product.add('tags');
product.addConnection('variants', { args: { first: 10 } }, (variants) => {
variants.add('product');
variants.add('title');
variants.add('price');
});
product.addConnection('images', {args: {first: 10}}, (images) => {
images.add('src');
})
});
});
.send() function
client.graphQLClient.send(productsQuery).then(({model, data}) => {
this.setState({
products: model.products
});
}).catch(err => console.log(err));