Update weight on product over GraphQL API

Hi

I’m creating or updating the products on my store over the GraphQL API. I use the productSet mutation for that. We don’t have variants. After more research I found out, that it’s not possible to update the weight on the variant, even though it belongs there. I read, that I have to use productVariantsBulkCreate but still I cannot find out how to use it. Can someone help me here? - Thanks a lot

I was trying like the following:

{
    "synchronous": true,
    "productSet": {
        "id": "gid://shopify/Product/15061780726095",
        "title": "GraphQL Marzipan 3",
        "descriptionHtml": "

Leckeres Marzipan aus der GraphQL-Welt

",
        ],
        "productOptions": [
            {
                "name": "Title",
                "values": [
                    {
                        "name": "Default Title"
                    }
                ]
            }
        ],
        "variants": [
            {
                "sku": "MARZIPAN100",
                "price": "11.99",
                "barcode": "1234567890123",
                "weight": {
                    "value": 0.5,
                    "unit": "KILOGRAMS"
                },
                "optionValues": [
                    {
                        "optionName": "Title",
                        "name": "Default Title"
                    }
                ]
            }
        ]
    }
}

try this

{
    "synchronous": true,
    "productSet": {
        "id": "gid://shopify/Product/15061780726095",
        "title": "GraphQL Marzipan 3",
        "descriptionHtml": "

Leckeres Marzipan aus der GraphQL-Welt

",
        ],
        "productOptions": [
            {
                "name": "Title",
                "values": [
                    {
                        "name": "Default Title"
                    }
                ]
            }
        ],
        "variants": [
            {
                "sku": "MARZIPAN100",
                "price": "11.99",
                "barcode": "1234567890123",
				"inventoryItem":{
					"measurement":{
						"weight": {
							"value": 0.5,
							"unit": "KILOGRAMS"
						}
					}
				},
                "optionValues": [
                    {
                        "optionName": "Title",
                        "name": "Default Title"
                    }
                ]
            }
        ]
    }
}

You just saved my live. How did you know this? I couldn’t find a reference. Thank you so much :folded_hands:

Google drives you here https://shopify.dev/docs/api/admin-graphql/2025-01/objects/Weight and then you follow the Map on the right up to InventoryItemMeasurement then up to InventoryItem then up to ProductVariant which is what you want to update :wink:

Genius. Learned again. Thanks for the explanation. :folded_hands: