Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

SortKey in custom query: Javascript StoreFront API

SortKey in custom query: Javascript StoreFront API

webprismdev
Visitor
1 0 0

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

 

Replies 0 (0)