I’m trying to create an App-data metafield on my app.
const mutation = `
mutation CreateAppDataMetafield($metafieldsSetInput: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafieldsSetInput) {
metafields {
id
namespace
key
value
}
userErrors {
field
message
}
}
}
`;
const enterpriseMetafield = {
namespace: "app_subscription",
key: "enterprise_plan",
type: "boolean",
value: currentPlan === "Enterprise" ? "true" : "false",
ownerId : appInstallId
};
const variables = {
metafieldsSetInput: [enterpriseMetafield], // Update both metafields
};
const response = await client.query({
data: { query: mutation, variables },
});
All the fields are valid, but still getting the error -
ApiPermission metafields can only be created or updated by the app owner.
What do I have to do to resolve this issue? Do we need to add some extra permissions on the app or make changes in the code?