Error while trying to sort products via sor

ViaCustomers
Visitor
1 0 0

Hello we are trying to use Shopify graphql (graphql-js-client) in our angular app to get sorted products for our app, but when we use sortKey argument we get "Argument 'sortKey' on Field 'products' has an invalid value".

Could someone please help us with this? thanks

const query = client.query((root) => {
            root.add('shop', (shop) => {
                shop.addConnection('products', {args: {first: 10, query: searchQuery, sortKey: 'TITLE'}}, (products) => {
                    products.add('id');
                    products.add('title');
                    products.addConnection('images', {args: {first: 1}}, (images) => {
                        images.add('src');
                    });
                    products.addConnection('variants', {args: {first: 1}}, (variant) => {
                        variant.add('id');
                        variant.add('availableForSale');
                        variant.add('title');
                        variant.add('price');
                        variant.add('compareAtPrice');
                        variant.add('image', (image) => {
                            image.add('src');
                        });
                    });
                });
            });
        });

  Screenshot_2.png

Reply 1 (1)

_JB
Shopify Staff
836 100 222

Hey @ViaCustomers,

I tried your query on my end and while I wasn't able to replicate the error, I did get a warning about a deprecated connection.

In your query, the shop connection isn't necessary since the products field is available directly on the QueryRoot. Removing the shop connection from your query should fix it up, if it doesn't please let me know and we can continue investigating.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog