Its very interesting.
I tried to change this in the admin UI i. e. https://admin.shopify.com/store/xxx/products/yyy
Then we have this request:
{
"operationName": "ProductSaveVariantsUpdate",
"variables": {
"productId": "gid://shopify/Product/xxxx",
"variantsToBulkUpdate": [
{
"id": "gid://shopify/ProductVariant/xxxx",
"showUnitPrice": true,
"unitPriceMeasurement": {
"quantityValue": 500,
"quantityUnit": "ML",
"referenceValue": 1,
"referenceUnit": "L"
}
}
]
},
"query": "mutation ProductSaveVariantsUpdate($productId: ID!, $variantsToBulkUpdate: [ProductVariantsBulkInput!]!) {\n productVariantsBulkUpdate(\n productId: $productId\n variants: $variantsToBulkUpdate\n ) {\n userErrors {\n field\n message\n __typename\n }\n __typename\n }\n}\n"
}
Well, yea, looks as easy as possible.
⌠But âŚ
Simple Node Shopify GraphQLâŚ
const shopify = shopifyApi({
apiKey,
apiSecretKey,
adminApiAccessToken,
apiVersion,
isEmbeddedApp: false,
scopes: ['read_products', 'write_products', 'write_inventory'],
hostName: shop,
future: {
lineItemBilling: true
}
});
await this.client.request(`mutation(
$productId: ID!,
$input: ProductVariantsBulkInput!) {
productVariantsBulkUpdate(productId: $productId, variants: [$input]) {
userErrors {
field
message
}
}
}`,
{
variables: {
productId: xxxx,
inventoryItemId: yyyy,
input: {
showUnitPrice: true,
unitPriceMeasurement: {
quantityValue: 500,
quantityUnit: "ML",
referenceValue: 1,
referenceUnit: "L"
}
}
}
});
I mean it also looks very simple.
But executed it results in âŚ
{
"errors": {
"networkStatusCode": 200,
"message": "GraphQL Client: An error occurred while fetching from the API. Review 'graphQLErrors' for details.",
"graphQLErrors": [
{
"message": "Variable $input of type ProductVariantsBulkInput! was provided invalid value for showUnitPrice (Field is not defined on ProductVariantsBulkInput), unitPriceMeasurement (Field is not defined on ProductVariantsBulkInput)",
"locations": [
{
"line": 3,
"column": 15
}
],
"extensions": {
"value": {
"id": "gid://shopify/ProductVariant/xxxx",
"sku": "xxxx",
"price": "44.95",
"compareAtPrice": "35.71",
"weight": 0.17293,
"weightUnit": "KILOGRAMS",
"barcode": "xxxx",
"inventoryItem": {
"cost": 35.71,
"requiresShipping": true,
"tracked": true,
"measurement": {
"weight": {
"unit": "KILOGRAMS",
"value": 0.17293
}
},
"harmonizedSystemCode": "123123"
},
"inventoryPolicy": "DENY",
"showUnitPrice": true,
"unitPriceMeasurement": {
"quantityValue": 500,
"quantityUnit": "ML",
"referenceValue": 1,
"referenceUnit": "L"
}
},
"problems": [
{
"path": [
"showUnitPrice"
],
"explanation": "Field is not defined on ProductVariantsBulkInput"
},
{
"path": [
"unitPriceMeasurement"
],
"explanation": "Field is not defined on ProductVariantsBulkInput"
}
]
}
}
],
"response": {
"size": 0,
"timeout": 0
}
}
}
So the only way to solve that is via browser automation. Very sad & bad but ⌠Shopify 