metafieldDefinitionUpdate missing ability to update validations

metafieldDefinitionUpdate missing ability to update validations

VYNE
Shopify Partner
1 0 4

The Shopify FrontEnd uses this to update the metafield validations:

 

{
"operationName": "MetafieldDefinitionEditMutation",
"variables": {
"input": {
"visibleToStorefrontApi": true,
"pin": true,
"namespace": "custom",
"key": "primary_collection",
"validations": [
{
"name": "choices",
"value": "[\"Horse Shelters\",\"Sheds & Storage\",\"Livestock Shelters\",\"Chicken & Hen\",\"Kitset & Cabin\",\"Lifestyle\",\"Horse Paddock Shelters\",\"Equine Accessories\",\"Sheds & Storage\",\"Garden Sheds\",\"Small Sheds\",\"Wood Sheds\",\"Wood & Tool Shed Combos\",\"Green Houses\",\"Large Sheds\",\"Pump Sheds\",\"Potting Sheds\",\"Pole Sheds\",\"Workshop Sheds\",\"Outdoor Storage\",\"Farm Sheds\",\"Pig Stys & Shelters\",\"Livestock Paddock Shelters\",\"Bobby Calf Pens\",\"Chicken Coop\",\"Large Chicken Coops\",\"Small Chicken Coops\",\"Portable Chicken Coops\",\"Hen House Accessories\",\"Chicken Feeders\",\"Raising Chickens\",\"Kitset Cabins\",\"Playhouses\",\"Studios\",\"Pitched Roof\",\"Carports\",\"Boat Sheds\",\"Garage\",\"Bach Sheds\",\"Summer House\",\"Sleepout\",\"Kitset Garage\",\"Portable Cabin\",\"Pitched Roof Cabin\",\"Chicken Caravans\",\"Chicken Runs & Fencing\",\"Chicken Coop & Hen Houses\",\"Goat Shelter\",\"Alpaca Shed\",\"Shed Conversions\",\"Liveable Sheds\",\"She Sheds\",\"Lean To Sheds\",\"Tool Sheds\",\"Run In Sheds\",\"Loafing Sheds\",\"Settler Stables\",\"Hunter Stables\",\"Custom Horse Stables\",\"Shelter With Tackroom\",\"Upland Garden Sheds\"]"
}
],
"name": "Primary Collection",
"description": "",
"ownerType": "PRODUCT"
}
},
"query": "mutation MetafieldDefinitionEditMutation($input: MetafieldDefinitionUpdateInput!) {\n metafieldDefinitionUpdate(definition: $input) {\n updatedDefinition {\n id\n description\n name\n pinnedPosition\n validationStatus\n invalidMetafieldsCount: metafieldsCount(validationStatus: INVALID)\n validations {\n name\n type\n value\n __typename\n }\n __typename\n }\n job {\n id\n done\n __typename\n }\n userErrors {\n message\n field\n __typename\n }\n __typename\n }\n}\n"
}

However, the Admin API using the same mutation & input types throws an error when you include the validations field.

Also, outside of the definition:

https://shopify.dev/api/admin-graphql/2022-07/mutations/metafieldDefinitionUpdate

https://shopify.dev/api/admin-graphql/2022-10/mutations/metafieldDefinitionUpdate

https://shopify.dev/api/admin-graphql/unstable/mutations/metafieldDefinitionUpdate

 

Maybe we can get this added?

Replies 4 (4)

ndrtek
Shopify Partner
12 0 10

Just chiming in that the input schema of the Update mutation should pretty much match that of the Create mutation.

 

Our app needs to be able to add new options to the list of valid options for a list.single_line_text_field.

 

As it stands... I must delete all metafield definitions and start over.

 

If I've already added products, of course then I have to also remove the product data and reset that.

Avi303
Shopify Partner
6 0 5

I'm new to Shopify. But found your thread because i'm trying to find a way to remove validations using the Graph API. I had no problem using metafieldDefinitionUpdate to update a validations choice list. But I am unable to figure out how to remove the list completely.

Avi303
Shopify Partner
6 0 5

Looks like i figure out how to remove the validations. need to be set as an empty array

kampfgnu
Shopify Partner
2 0 2

+1

why isn't the

MetafieldDefinitionEditMutation

 accessible to developers?

i really need exactly this feature to update values of a metafield when user stores api keys for my 3rd party rest API.

any plans to make editing metafields public for us devs?