Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi everyone,
I create app based on shopify-app-remix. It creates definitions and meta objects that I would like to delete before uninstalling the app. I tried to use webhooks but unfortunately I don't have the option to delete them using GraphQL Admin API ( gets a 401 error).
Is there any way to remove app-created meta-objects and their definitions from the store?
Hey @Lucifer4
Unfortunately not. Right now cleanup includes deleting any registered webhooks, script tags, and Shopify admin links. Definitions and meta objects remain.
Scott | Developer Advocate @ Shopify
I understand, but in my case the meta-objects hold the application data and its settings. Is this the wrong approach?
Hey @Lucifer4
I guess it's all tradeoffs - depending on your use case, consider using private metafields or keeping settings in your database.
Scott | Developer Advocate @ Shopify
I ran into the same problem and I found out the solution. So let's try if anyone needs it. You can save the ID of the metaobject definition in a database or retrieve it by type and delete the metaobject Definition by ID. You can write the code in the file "webhook.tsx" in the topic case - "APP_UNINSTALLED".
Hi Ntlan63. I have also tried this, but the webhook behaves strangely and doesn't remove the metafield. It's not even retrieving the ID, even though the Query works in the GraphiQL playground. Can you show me your example code, please? Here is mine.
The delete mutation is below this query, but it's not necessary to post it here since the query is not working.
Sorry. It was my mistake to draw conclusions based on just 1-2 fortunate instances. I suspect that the access token expires right after the app is uninstalled, leaving insufficient time to execute a query.