Disconnect Metafields via Graphql API

Topic summary

Main issue: Replicate the Shopify Admin UI action “Disconnect” for a product metafield (e.g., Colour) via the Admin GraphQL API so that variants and option values remain, but the metafield link is removed.

Context: The UI warns that disconnecting converts the metafield-backed option into a manual option while keeping variants/option values. An image of the UI dialog is central to understanding the desired behavior.

Attempts tried:

  • Update product options by clearing linkedMetafieldValues.
  • Delete MetaObjects referenced by product.optionValues.linkedMetafieldValues.
  • Delete Product.metafields entries.
  • Various combinations of the above.

Outcome: None of these approaches successfully remove the metafield linkage; the connection persists.

Notes: Metafield = custom metadata attached to resources; MetaObject = structured record that can be linked to option values via linkedMetafieldValues.

Status: Unresolved. No working GraphQL method or mutation identified yet; the author is seeking a way to mirror the UI “Disconnect” behavior programmatically.

Summarized with AI on January 12. AI used: gpt-5.

The request is pretty simple, but so far every possible solution has failed.

I would like to replicate the behaviour of the Metafield “Disconnect” button on a product via the Admin Graphql API.

After clicking it asks “Disconnecting the metafield “Colour” will convert this into a manual option. Variants and option values will be kept.” and results in everything remaining the same (Variants / Options) just that the connection is removed.

So far I have tried:

 1. Updating Product Options by clearing linkedMetaFieldValues
  1. Deleting all MetaObjects that are attached to the product.optionValues[].linkedMetafieldValues
  2. Deleting the MetaFields within Product.metafields

Along with a few combinations of both but nothing clears the metafield links.

This is driving me nuts :clown_face:

1 Like

@Josh_digital just to let you know this is what i’ve already done and it does not work, any attempts to remove the product metafield does nothing, or returns “An Unexpected Error has occured”

@Josephtech this is super annoying to hear, I am only down this path because working with metafields is already not working as expected, now I can’t even programatically clear the metafields :clown_face:

I’ve already taken on the Hybrid approach you suggested but it’s obviously such an annoyance for customers using the app.

Hi @TheFlyingCoder :waving_hand: please report unsolicited private messages on development posts like this to moderators.
Butlerian Jihad :raised_fist:


tl;dr linkedMetafield field/property is NOT a normal metafield it’s more of a relationship connection (in the technical compiler jock sense but also not really /sigh :face_exhaling:) , as linked"Metafield" they can go through shopify’s taxonomy and ~metaobjects. In typical shopify fashion they’ve just poorly named yet another thing causing confusion about what things are and how they work or where to work with them /ugh.
Deleting the metafield NOT working may seem weird and unexpected for metafieldsDelete[1].
Yet linkedMetafield is in EARLY access https://shopify.dev/docs/api/admin-graphql/latest/input-objects/LinkedMetafieldUpdateInput
https://shopify.dev/docs/api/admin/migrate/new-product-model/metafield-linked

Make sure to follow through on the dev forums to address this behavior early before it cements for GA(general access)
:clipboard: Also obligatory: with stuff like this also try to rule out any cache issues, or incorrect references/ids.

A kludge in some situations is to just clone the product; but this is not a viable solution in most uses case because of things like relying on product-ids being the same, or possibly having to make redirects, inventory apps etc etc etc ad nauseum.

[1] assuming your deleting metafields using something like this:

DisconnectProductMetafieldDontWork Mutation sample
mutation DisconnectProductMetafieldDontWork(
  $productId: ID!
  $namespace: String!
  $key: String!
) {
  metafieldsDelete(
    metafields: [
      {
        ownerId: $productId
        namespace: $namespace
        key: $key
      }
    ]
  ) {
    deletedMetafields {
      key
      namespace
      ownerId
    }
    userErrors {
      field
      message
    }
  }
}

vars

{
  "productId": "gid://shopify/Product/1234567890",
  "namespace": "product_details",
  "key": "color"
}

Use the developer forums for actual development issues and feedback, actual chances of engagement from actual shopify-internal devs.
And substantially less bot responses regurgitating your own words back at you (notice how verbose and officious they are but zero docs links, nothing you couldn’t have gotten from asking the dev assistant on the dev docs)

1 Like

@PaulNewton I have got a few messages to give out store links and collaborator codes but there is no way in hell I’d do that :clown_face: This question isn’t even related to any particular store, it’s for a custom app workflow.

I have had endless issues working with metafields through the Admin API - Even with the Shopify docs directly failing to work when dropped in.

Moving to the Dev forums is a good idea

1 Like