I’m having trouble with a particular product. I’m fetching variants for a particular product in the GraphQL API, but getting far fewer results than with the REST API.
REST API gives me 12 variants. GraphQL gives me 2 (earlier today, only 1).
To begin answering this we would need a bit more info. Any of the following can help, what is the ID of the variant you are trying to get? The X-Request-ID header response from one of the GraphQL requests? Or the query variable values that you are passing.
Without more, best I can do is guess. And if I had to guess, you may only be asking for the first 2 in GraphQL.
I think you may be approaching it the wrong way, you are currently returning all variants and then searching them for the product_id. The correct way would be to query the product_id and then return all of it’s variants like so:
This will return the fields you wanted for the first 25 variants on that product. By querying ProductVariants you would be searching every variant on the shop for the string of your product_id, which as far as I know is not a supported query parameter.
Good to know about product_id. Played with it a bit but wasn’t able to replicate the behaviour you are seeing unfortunately. If you can provide a specific X-Request-ID header of a call that has this issue I could dig into it a bit more.