Using Shopify’s GraphQL Admin API.
I’m trying to query all variants for a store. first I tried doing:
query variants($cursor: String) {
productVariants(first: 250, after: $cursor, query: "product_status:active") {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
id
product {
id
}
}
}
}
}
Iterating over the pages until I got hasNextPage: false returned 474,250 variants.
Then I tried a bulk opeartion:
mutation variants($query: String!) {
bulkOperationRunQuery(query: $query) {
bulkOperation {
id
status
}
userErrors {
code
field
message
}
}
}
And used it with the query:
productVariants(query: "product_status:active") {
edges {
node {
id
product {
id
}
}
}
}
This returned a total of 730,560 variants.
Does anyone know what could explain this difference of 256,310 variants?
For reference this other query:
query variantsCount {
productVariantsCount(limit: null) {
count
}
}
Returns a total of 743,108 variants for this store (including variants for non-active products).
Hey @Ferares, thanks for reporting this. Have you resolved this at all yet?
I attempted to replicate, thinking there may be some nuance with the filters, but on my own test store, both paginated queries and bulk operations return the same number of variants.
Would you be able to test again, and log the x-request-id of the final paginated query that returns hasNextPage: false. Also if you can share the bulk operation ID that returned the higher number, I may be able to find out more on what’s happening here.
Ultimately we may need to have you reach out to our support teams in the help center to be able to look deeper in to your integration, but I can see if I can find out anything generally first.
Hey @KyleG-Shopify thanks for the response.
I haven’t been able to figure this out yet, but I’ve re-run all the queries and I’m not getting any discrepancies now so I guess I was doing something wrong in my original pagination logic 
Here’s the requested info just for completion:
- Bulk operation ID:
gid://shopify/BulkOperation/7515783397602
- x-request-id header for the last “paginated query”: 815ff041-7917-458d-b0fd-c7bdd627b3bd-1779736510
I’ll mark the question as solved. Thanks for taking the time to respond.
Thanks for sharing that it’s working now. If you do notice this re-occur, let us know with those details from it’s reemergence and we’ll take a look