Trying to update the category which is a documented field (and is available in the GraphiQL Shopify app), but the API complains that it's not valid:
{'message': 'Variable $input of type ProductInput! was provided invalid value for category (Field is not defined on ProductInput)', 'locations': [{'line': 1, 'column': 24}], 'extensions': {'value': {'id': 'gid://shopify/Product/9819449721123', 'title': "Dustin's Men's Fake Jacket for Testing 2", 'category': 'gid://shopify/TaxonomyCategory/aa-1-10-2'}, 'problems': [{'path': ['category'], 'explanation': 'Field is not defined on ProductInput'}]}}
The request is:
mutation ProductUpdate($input: ProductInput!) {
productUpdate(input: $input) {
product {
id
title
category {
id
}
}
userErrors {
field
message
}
}
}
The variables are:
{
"input": {
"id": "gid://shopify/Product/9819449721123",
"category": "gid://shopify/TaxonomyCategory/aa-1-10-2",
}
}
Should the selector be category { id }
instead of category
in the request, or should I be putting something like "category": { "id": "..." }"
in the variables?
Make sure the API version matches the documentation that you're looking at.
The product category update works fine:
# Request
q = """\
mutation ProductUpdate($input: ProductInput!) {
productUpdate(input: $input) {
product {
id
}
userErrors {
field
message
}
}
}
"""
# Variables
v = {
"input": {
"id": "gid://shopify/Product/9819449721123",
"category": "gid://shopify/TaxonomyCategory/aa-1-10-2",
}
}
# Response
{
"data":
{
"productUpdate":
{
"userErrors":
[]
}
},
"extensions":
{
"cost":
{
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus":
{
"maximumAvailable": 20000.0,
"currentlyAvailable": 19990,
"restoreRate": 1000.0
}
}
}
}