A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
That's my code:
client = shopify.GraphQL()
mutation = """
mutation productVariantsBulkUpdate($variants: [ProductVariantsBulkInput!]!, $productId: ID!) {
productVariantsBulkUpdate(variants: $variants, productId: $productId) {
product {
id
}
productVariants {
id
}
userErrors {
field
message
}
}
}
"""
params = {
"variants": [
{
"id": "gid://shopify/ProductVariant/534676534632",
"price": "25.00"
},
{
"id": "gid://shopify/ProductVariant/0987654321",
"price": "25.00"
}
],
"productId": "gid://shopify/Product/123456789"
}
result = client.execute(mutation, params)
json_file = json.loads(result)
print(json_file)
I'm getting the following error:
{'errors': [{'message': "ProductVariantsBulkInput isn't a defined input type (on
$variants)", 'locations': [{'line': 2, 'column': 47}], 'path': ['mutation
productVariantsBulkUpdate'], 'extensions': {'code': 'variableRequiresValidType',
'typeName': 'ProductVariantsBulkInput', 'variableName': 'variants'}}, {'message':
"Field 'productVariantsBulkUpdate' doesn't exist on type 'Mutation'", 'locations':
[{'line': 3, 'column': 15}], 'path': ['mutation productVariantsBulkUpdate',
'productVariantsBulkUpdate'], 'extensions': {'code': 'undefinedField', 'typeName':
'Mutation', 'fieldName': 'productVariantsBulkUpdate'}}, {'message': 'Variable
$variants is declared by productVariantsBulkUpdate but not used', 'locations': [.
{'line': 2, 'column': 12}], 'path': ['mutation productVariantsBulkUpdate'],
'extensions': {'code': 'variableNotUsed', 'variableName': 'variants'}}, {'message':
'Variable $productId is declared by productVariantsBulkUpdate but not used',
'locations': [{'line': 2, 'column': 12}], 'path': ['mutation
productVariantsBulkUpdate'], 'extensions': {'code': 'variableNotUsed',
'variableName': 'productId'}}]}
Seems like Shopify doesn't know "ProductVariantsBulkInput" although it is a Shopify object.
What am I doing wrong?
Thank you in advance.
Hey Joant95 ,
I was just dealing with this issue. You might want to make sure that your version of the ShopifyAPI is up to date. Once you're on the right version, the query should work.
Good luck,
KPhan
Hey EmoryKPhan,
Thank you for your answer. Turned out that I had to use the unstable version.
So instead of passing the date of the current version you have to pass "unstable". Maybe it's also working with the current version of the API as well. I only tried it with an older version and it didn't.