Metafields/metaobjects definitions with reserved namespace left after app uninstall

We are using metafields/metaobjects with definitions to store app data used by theme extensions. All definitions are using reserved namespace (eg $app:some-namespace) and give full read-write access to merchants (access.admin = PUBLIC_READ_WRITE). This access gives merchants only ability to manage metafields, not the definition itself which is great for our use case.

However, when the app uninstalled our metafields/metaobjects with definitions are still left in the store. Nor us nor merchants can’t delete definitions anymore. Even if we manage to get collaborator access to the store we can’t do anything cause definition under reserved namespace can only be controlled by the app that created it. The only workaround here is to re-install the app and trigger deletion via API.

With metafields/metaobjects becoming more widespread, there should be a way to automatically delete definitions together with app uninstall, at least for reserved namespaces.

1 Like

assuming you are using graphql, there are two endpoints that allow you to delete metafields entries and data. Same for metaobjects. Hope this helps

mutation DeleteMetafield {
  metafieldDelete(input: { id: "gid://shopify/Metafield/123456789" }) {
    deletedId
    userErrors {
      field
      message
    }
  }
}

@Octavian no, it’s not helpful. How we suppose to call these methods after app uninstall?

@Kirill_Platonov I suppose you do the cleanup before the actual uninstall.
When uninstall is initiated, you create a cleanup process then uninstall the app

On a separate note, I appreciate what you are trying to solve here as most of the apps don;t clean after uninstall so this is quite refreshing to see. I wish more app devs would think about this :raised_hands:

There isn’t any way to know before though, we only know if an app is uninstalled from the app/uninstall webhook.

I don’t want to Hijack this thread but I cannot seems to post a new one.
A related question would be: what happens to metafield data if an app is uninstalled and meta fields removed? From the original question it seems the data stays put, even if the app in uninstalled. Re-installation provides access to the app, but removing the metafield definitions would imply all previous metadata will be lost.

“definition under reserved namespace can only be controlled by the app that created it”

Our situation we are trying to re-create the same app, due to original supplier holding Access Token. The custom app has metadata. My concern is how to access the meta data once the app is uninstalled and our app replaces it, effectively duplicating the meta field names.

Is there a work around to this?