Shopify API from PHP: problem with linked metafields in a productCreate call

I’m trying to create a productCreate mutation which specifies the available colours for the product, but I’m getting the error ‘The ‘shopify.color-pattern’ metafield has no values and none were passed in for this linked option’.

I’m passing in variables as follows (closing brackets elided) which are then json-encoded.

[variables] => stdClass Object
(
[product] => stdClass Object
(
[title] => Herring Sittaford Chelsea boots
[productOptions] => Array
(
[0] => stdClass Object
(
[name] => Color
[position] => 1
[linkedMetafield] => stdClass Object
(
[key] => color-pattern
[namespace] => shopify
)

[values] => Array
(
[0] => stdClass Object
(
[linkedMetafieldValue] => gid://shopify/Metaobject/169330016585
[name] => Caramel Suede
)

[1] => stdClass Object
(
[linkedMetafieldValue] => gid://shopify/Metaobject/169330049353
[name] => Honey Suede
)

[2] => stdClass Object
(
[linkedMetafieldValue] => gid://shopify/Metaobject/169330114889
[name] => Ocean Suede
)

[3] => stdClass Object
(
[linkedMetafieldValue] => gid://shopify/Metaobject/169330606409
[name] => Olive Suede
)

[4] => stdClass Object
(
[linkedMetafieldValue] => gid://shopify/Metaobject/169330639177
[name] => Sand Suede
)

[5] => stdClass Object
(
[linkedMetafieldValue] => gid://shopify/Metaobject/169330671945
[name] => Wheat Nubuck
)

The shopify dox are not helpful on this. I’ve tried various tweaks on this and nothing helps. Pass in values as an array on the linkedMetafieldobject and I get ‘Cannot specify ‘values’ for an option linked to a metafield’.

This works if I don’t use linked metafields, but I want this to be nailed down to the defined colours we’ve set up programmatically, I don’t want duplicates.

Anyone got any suggestions?

Thanks in advance,

G