Relate metaobject with Product using ProductSet mutation

Topic summary

A user successfully resolved how to relate a custom “Product Geometry” metaobject to products in Shopify.

Initial Challenge:

  • Created a metaobject definition (product_geometry) with a JSON field
  • Populated metaobject entries using bulkOperationRunMutation with metaobjectUpsert
  • Needed to associate each product with its corresponding metaobject entry in a single bulk operation

Solution:
To link metaobjects to products:

  1. Create a Product Metafield with type metaobject_reference
  2. Use the Metaobject’s ID value as the metafield’s value field

This approach enables bulk updating all products with their related metaobject data through the productSet mutation within a single API request.

Summarized with AI on November 8. AI used: claude-sonnet-4-5-20250929.

I have created a “Product Geometry” metaobject definition with type product_geometry and the definition field with type json.

I’m filling the available “Product Geometry” values using bulkOperationRunMutation metaobjectUpsert graphql admin api.

The metaobjectUpserts data is something like:

$metaobjects[] = [
    'handle' => [
        'type' => 'product_geometry',
        'handle' => str_slug($title),
    ],
    'input' => [
        'fields' => [
            [
                'key' => 'definition',
                'value' => json_encode($definition),
            ],
        ],
    ],
];

After that, I want to relate every product with one “Product Geometry” metaobject value, but I don’t know how.

I’m using bulkOperationRunMutation productSet to update all my products with only one api request.

How can I add the metaobject relation inside the productSet data?

Thanks!

Solved, to relate a Metaobject with a Product I need to create a Product Metafield with type Metaobject (metaobject_reference) and then use the Metaobject value ID as metafield value field.