A developer encountered an error when trying to use sortKey=PRICE in a Shopify Storefront API query for products in a post-checkout extension. The API returned an invalid value error, stating it expected type ‘ProductSortKeys’.
Initial Suggestion:
Change sortKey to ProductSortKey (though this appears to be a misunderstanding)
Test queries using Shopify’s GraphiQL explorer
Working Solution Provided:
The helper shared a corrected GraphQL query that successfully includes sortKey: PRICE in the products query. Key changes in the example:
Proper syntax: sortKey: PRICE within the products query parameters
Updated field names (e.g., priceRange instead of priceRangeV2, priceV2 for variants)
quantityAvailable instead of inventoryQuantity
Recommendation:
Use Shopify’s GraphiQL Storefront explorer to build and test queries interactively with sample data before implementing in code.
Summarized with AI on October 29.
AI used: claude-sonnet-4-5-20250929.
Hi, I saw the documentation and according to it it is possible to pass a parameter sortKey= PRICE, but it gives me the error pasted below, for him this parameter does not exist can you help me?
I call the function in a route, to get the products and use them in the extension
i used pricerange instead of pricerangev2, only to test it in graphql explorer
u realy should test the graphql explorer: https://shopify.dev/graphiql/storefront-graphiql
click on explorer and u can build the request u need. u may even test the request on sample data