ProductVariantsCreate/ProductVariantsUpdate mutations missing fields

Hi all,

Migrating product variants creation from REST to GrpahQL, I encountered the fact that some fields in the mutation are missing.
ProductVariant REST API allows to specify product variant cost, weight, weight_unit and sku, but these are not present in ProductVariantsCreate/ProductVariantsUpdate mutations.

Example POST request:

{
    "product": {
        "title": "Sprite Stasis Ball 65 cm",
        "body_html": "",
        "vendor": "TEST",
        "product_type": "GEAR",
        "published_at": "2018-10-16T09:26:25",
        "published_scope": "global",
        "tags": [],
        "variants": [{
                "option1": "O/S",
                "option2": "Blue",
                "price": "27",
                "cost": 10.8,
                "inventory_management": "shopify",
                "weight": 900,
                "weight_unit": "g",
                "sku": "10004011",
                "barcode": ""
            }, {
                "option1": "O/S",
                "option2": "Pink",
                "price": "27",
                "cost": 10.8,
                "inventory_management": "shopify",
                "weight": 900,
                "weight_unit": "g",
                "sku": "10004035",
                "barcode": ""
            }
        ],
        "options": [{
                "name": "SIZE",
                "position": 1,
                "values": [
                    "O/S"
                ]
            }, {
                "name": "COLOUR",
                "position": 2,
                "values": [
                    "Blue", "Pink"
                ]
            }
        ],
        "status": "draft"
    }
}

I would be very grateful for an information on how to update the missing fields (cost, weight, weight_unit, sku) using GraphQL mutation.

Hey Maxim

Those fields are on the Inventory Item on a Variant :blush:
You can specify them on the inputs to those queries where you specify some variant fields and the an inventory item property with additional fields.

2 Likes

Thank you Jordan, inventoryItemUpdate mutation works!

Does anyone know if the variant ‘title’ is exposed for mutation anywhere?

A variants title is made up of the product options and is generated automatically from them, so you can’t manually update it.
For example if you have product options of Size and Colour. The variant title would be XL / Blue as an example.

1 Like

Thanks, that makes sense.
Just wondering now if someone from Shopify can comment on whether they are planning to make updating the variant title available through the GraphQL API again (on API version 2024-10 the productVariantsUpdate which has ‘title’, got deprecated in favor of productvariantsbulkupdate which doesn’t have ‘title’ available). On the web UI/dashboard it’s editable by a user, so I’m wondering if they will either make it available again on the API, or disable editing on the web.