I am trying to retrieve totalVariants of each collection.
mutation {
bulkOperationRunQuery(
query: """
query nodes {
nodes(ids: ["gid://shopify/Collection/123456", "gid://shopify/Collection/654321"]) {
...on Collection {
id
products(first: 250) {
edges {
node {
totalVariants
}
}
}
}
}
}
"""
) {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}
A normal query(not bulkOperationRunQuery) would have returned something similar:
{
"data": {
"nodes": [
{
"id": "gid://shopify/Collection/123456",
"products": {
"edges": [
{
"node": {
"totalVariants": 6
}
},
{
"node": {
"totalVariants": 6
}
}
]
}
},
{
"id": "gid://shopify/Collection/654321",
"products": {
"edges": [
{
"node": {
"totalVariants": 5
}
}
]
}
}
]
},
"extensions": {
"cost": {
"requestedQueryCost": 253,
"actualQueryCost": 8,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 992,
"restoreRate": 50
}
}
}
}
But since the number of products could exceed 250, I would probably need bulkOperationRunQuery. I just read that node and nodes arent’ allowed in bulkOperationRunQuery. I also understand collections can have unlimited products thus making the totalVariants per collection unlimited.
Is there a better way to get the totalVariants for a number of collections?