Metafields definition

Hi ,

I am trying to create some metafields for my shopify public app on behalf of store to to store some data in it , i would prefer to set access controls so that store admin cannot view metafiles or have read only access so that it cannot be modified accidentally or deleted

for that i tried to create metafield definition first but getting error

Error “message”: “Owner type is not included in the list” (when access node is not passed )

OR

“message”: “Setting this access control is not permitted. It must be one of ["public_read_write"].” (when access node is passed)

documentation link followed MetafieldOwnerType - GraphQL Admin

======== code part ========

mutation {
metafieldDefinitionCreate(definition: {
name: “Ingredients”,
namespace: “bakery”,
key: “ingredients”,
description: “A list of ingredients used to make the product.”,
type: “json”,
ownerType: API_PERMISSION,
access: {
admin: MERCHANT_READ,
customerAccount: NONE,
storefront: PUBLIC_READ
}
}) {
createdDefinition {
id
}
userErrors {
field
message
}
}
}

Hey,

I’ve got caught out on this before.
Its because you are using a merchant owned metafield. Because you are not using the $app prefix for example on your namespace.

Therefore admin has to be public write read as the merchant can read/write and so can any apps.

If you want more controls over this metafield you should make it app reserved namespace. Theres more information available here Access and permissions