I have successfully created a app owned Metafield and am able to access it in the liquid file.
currently the value of {{ app.metafields.call_to_action_dummy.background_color }} is “#fff123” I want to retrieve the this value in my backend.
I have gone through this: https://shopify.dev/docs/apps/custom-data/metafields/manage-metafields#step-2-retrieve-a-metafield. (Retrieving metafield for Product but how to do it for app owned metafields).
I have Done the following but itsnt working:
const RETRIEVE_METAFIELD = query GetAppOwnedMetafields($ownerId: ID!, $namespace: String!, $key: String!) { metafields(ownerId: $ownerId, namespace: $namespace, key: $key) { edges { node { id value createdAt updatedAt } } } };
and
data: {
query: RETRIEVE_METAFIELD,
variables: {
namespace: “call_to_action_dummy”,
key: “background_color”,
ownerId: “gid://shopify/AppInstallation/------------”
},
},
Please give me example for it. Thanks
(I know how to create and edit App owned metafield)
(Is it possible to retrieve all the App Owned metafields that has been created?)