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.
@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
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.
When the app is uninstalled, the API access token is revoked. Even we have shop data in our database, it is useless since the API call will have 401 unauthorized error.
As far as I know, there’s no solution for that yet.
My current workaround when customer wants metafields clean up is asking them to re-install app and removing metafields via API call. After that they can uninstall again.
Yes this is a problem, I asked Shopify a few months ago. They told me it was to prevent store disruption. Even after app uninstall the merchant might still rely on the data that have been created, so if Shopify would remove the definition it would cause merchant frustration.
I think one simple solution would be to either hide the definitions of removed app (but keep the data somehow), or when an app is removed, allow the merchant to actually remove the definition (and block again the ability for merchant to do it if the app is reinstalled in the future).
But for merchants installing/uninstalling ton of apps, those accumulations of definitions is not a great experience.
Is there any update on Shopify’s end for this one?
Asking the merchant to reinstall the app, so we can manually delete metaobjects isn’t a merchant friendly experience. It’s definitely an area of friction that could create a 1 star review.