However, the above api call only returns the first variant for each product. As an example, I’ll search for the term HMG. I have a product call HMG Basecoat that has 4 variants, as shown below:
Notice how only 1 variant is returned in the variants array, even though numVariants is correct with 4. This is happening with multiple products. How do I fix this to return all variants associated with a product?
Thanks @Alan_G, I look forward to hearing back from you. I’m really hoping it’s a bug and the expected behaviour isn’t to only return 1 variant… that would seem a little pointless.
Hey @21O - thank you for following up and apologies for the long wait. We’ve been working on this internally, but can’t seem to replicate the issue.
Would you be able to share a code snippet for your extension’s function so we can try to test on our end a bit further? I can set up a DM with you if that’s easier - just ping me here. We’ll get this looked it for sure.
So as I said in my original post, the ‘HMG’ prodcuct has 4 variants, which matches the numVariants property. However there is only 1 variants returned in the variants array. I need to return all of the variants for a product. Is this possible with this endpoint, or will I have to use a server side api call and return the data to the POS app?
@21O sorry just catching up here. You are correct that the product search itself only returns 1 variant because it’s actually only searching for products, not the variants themselves. You can use the product Id to look up all the variants in a subsequent query.
For context this API is designed to work with a search field, and is the same that we use internally. In our case, we list the products, then when a merchant selects that product we can navigate to the variant list (firing that second query I sent you). We didn’t design this for the purpose of listing a massive list of variants within a massive list of products as this would have obvious performance implications. Not only would we be having to paginate on the product level, but paginating the variants within each product (due to the large max num of variants allowed now) would be a large technical complexity. So we designed so that you can search for the product, find the one you want, and then find the variants.
@210 I will also add that we’ll be shipping Direct API in 2025-07, which means you’ll be able to fire a GraphQL query directly from your extension. Since GQL already supports pagination on those endpoints, you should be able to achieve what you want to do in 1 query