Is it possible to add and sync app-owned metafields with the default app namespace?
Following the docs at https://docs.gadget.dev/guides/plugins/shopify/advanced-topics/metafields-metaobjects#storing-metafield-data-in-gadget I was figuring out, if I can use the default namespace.
The Shopify GraphQL API allows to leave the
namespace
parameter empty and will default to app--
+ the app ID, which is automatically inferred.
A metafield could look something like this:
Currently, the Gadget form to add a synced metafield to the schema of a model doesn't allow to leave the namespace
field empty.
I was wondering, if there was a reason for that restriction or workarounds to leaving the field empty, but not using the UI editor?4 Replies
I think to use app-owned metafields, you should set the
$app:
prefix as the namespace.
You can also define the namespace as such in shopify (might be a bit cleaner than just leaving it empty):
And then I believe you just use exactly that namespace in gadget.
I checked the docs on it again: https://shopify.dev/docs/apps/build/custom-data/ownership#create-metafield-definitions-with-reserved-namespaces
In the example it shows, that the APIs default to setting the namespace too
$app
, if left empty.
Of course, if you want to add an optional namespace, you would need to transmit $app:optional-namespace
.
But from reading it, it seems like I can just add "$app" as the namespace in the Gadget web UI for the metafield, and it should work, as the Shopify APIs expand that variable.
While it would be nice to have the option to leave it empty, this is a low-effort "workaround". I'll test it as soon as I can.Shopify
Ownership
Take ownership of your metafields and metaobjects by managing them with reserved namespaces.
I'm making a ticket internally to change this behavior
Thank you. It's definitively not urgent, as I can just filly the field with
$app
. I just needed to figure that out.