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!