Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi, I am new to Shopify App development, and am using APPBRIDGE to build my embedded app based on THIS tutorial.
My app has a requirement to store some global app settings in the shop's Metafields. I had been planning to use GraphQL for the whole app, but discovered that this functionality is only available via the REST interface:
POST /admin/metafields.json
Can someone share how I can make these REST calls given the above technology stack?
Thanks!
Mike
I'll skip your question for the moment and ask you another. What data do you need to store in a shop metafield? Metafields are not a protected resource so if you're storing critical settings in there keep in mind another app/tool could alter or delete them. If that's a problem then metafields are not the right place for that data.
Hi Jason,
We will store global settings that are used internally by our app that are specific to the shop.
We are not worried about another app maliciously manipulating data within our namespace.
That being said, is this a problem faced by other app developers?
Thanks!
Mike
There certainly could be some app devs out there that don't want to store app specific data on their own servers. I hope none do as it's a poor/risky approach given how quick it is to spin up some form of db app side. It also creates garbage in the shops metafield data come uninstallation time. Your app may be removed but the metafield will still remain.
In the REST API docs there's an example for creating a shop metafield.
https://help.shopify.com/en/api/reference/metafield#create
Where did you get stuck?
I need a code example. I am very new to this technology stack, and am completely lost as to how to make a rest call using APPBRIDGE.
Hi Jason,
I looked at the link you provided. I get that this is the endpoint for writing an admin metafield.
The problem I am having is that I do not know how to use APPBRIDGE to do a post?
Can you point me to an example of how to accomplish this with APPBRIDGE?
Thanks!
Mike