Unable to edit a previously created metafield in shopify.app.toml

Hi there. I created a metafield in my app by placing it in the shopify.app.toml file.

[product.metafields.app.pim_product_id]
type = “single_line_text_field”
name = “PIM Product ID”
description = “Unique product identifier from the connected PIM system”
access.admin = “merchant_read_write”

Now, I want it to be:

[product.metafields.app.pim_product_id]
type = “id”
name = “PIM Product ID”
description = “Unique product identifier from the connected PIM system”
access.admin = “merchant_read_write”

Notice the change in type. However, my app isn’t letting me. When I try to deploy, this happens:

Version couldn’t be created. │
│ │
│ [product.metafields.app.pim_product_id] Cannot change type of existing │
│ metafield definition - type: single_line_text_field │

Same thing when trying to test the app via “shopify app dev”. I also can’t delete it via graphql, due the “api not having access”:

“message”: “Access denied for metafieldDefinitionDelete field. Required access: API client to have access to the resource type associated with the metafield definition.\n”,– yes I have product_write and product_read scopes.

I’m really lost.

@Adam_Heaney1 You can’t change the type on a metafield once it’s been created or once it’s got data within it. You basically have to delete it and then recreate it.

If you have data in your old metafield, you’ll have to:

  1. Create your new metafield by adding it alongside the existing one in your toml.
  2. Run a migration of that data from the old field into the new one.
  3. Then you can remove the old metafield from the toml.

Sounds like there’s some scopes missing somewhere in your app .re deleting the old metafield though. Are you running the delete mutation from your app and not just the graphiQL app or something?

Given it’s a merchant_read_write access level though, you should also be able to just remove that metafield from the admin I think too?

I honestly have no idea how it happened. I ended up just deleting the metafield via the admin api, and I still couldn’t recreate it in the TOML file. So i just ended up creating it again with the Admin API.

Weird that the TOML file still thinks that it exists. Honestly have no clue what I did lol