Hey Simon,
The “worked yesterday, broke after restart” part is telling. It seems your caller function changed underneath you.
Try passing $app:my_metaobjectas the type instead of app--<id>--my_metaobject.
The $app: form resolves against whichever app is authenticated on the request, so it can’t go stale. The expanded form is a snapshot of an app id, and the moment that id changes you get what you’re seeing: definition sitting there in query results, but upsert says “no can do partner.”
You can check the mutation, just run this next to the failing upsert:
{
currentAppInstallation { app { id } }
metaobjectDefinitionByType(type: "$app:my_metaobject") { id type }
}
If app { id } doesn’t match the number in the app--...-- type on the definition you’re seeing, then you’re calling as an app without ownership. That’s fine for reading, but writing, not so much. That’s why the query looks healthy and the upsert doesn’t.
If none of this is helping, let us know your setup, but a common use is the GraphiQL app in the
admin, where $app: resolves to GraphiQL, not to you, so it fails there no matter how correct
your app is.
If you’re wondering whether a dev server restart can change which app you’re upserting to, it can. I got burned by this when my ‘shopify app dev’ rewrote my prod ‘application_url’ in the partner dash, leaving it a mess though my repo hadn’t changed. Since partner dashbaord state is mutable, local tooling can change it without any alert, and the TOML in your repo suddenly stops being source of truth.
While in the TOML check that you have write_metaobjects and not
only write_metaobject_definitions.
If all of that didn’t help, again just post back, happy to help with any new issues related to this. Some other threads ran into orphaned entries from a definition that got deleted and recreated, and only Shopify can see that side. They will ask you for the X-Request-ID off the failing response if that’s the case.
Happy bug hunting!