Hi,
I am trying to create a custom meta field that references a meta object.
Mutation
mutation metafieldDefinitionCreate($definition: MetafieldDefinitionInput!) {
metafieldDefinitionCreate(definition: $definition) {
createdDefinition {
id
name
namespace
validations {
name
value
}
type {
name
}
}
userErrors {
field
message
}
}
}
Variables
{
"definition": {
"description": "Test",
"key": "product_bundle2",
"name": "product_bundle2",
"namespace": "custom",
"ownerType": "PAGE",
"pin": true,
"type": "metaobject_reference",
"useAsCollectionCondition": false,
"visibleToStorefrontApi": true,
"validations": {
"name": "metaobject_definition_id",
"value": "gid://shopify/Metaobject/13335560507"
}
}
}
Error
A validation for setting the metaobject definition a reference must point to.
Example use case:
A product refers to a “Designer” metaobject.
"userErrors": [
{
"field": [
"definition",
"validations"
],
"message": "Validations require that you select a metaobject."
}
]
The documentation for validation https://shopify.dev/docs/apps/custom-data/metafields/definitions/validation says that:
A validation for setting the metaobject definition a reference must point to. Example use case: A product refers to a “Designer” metaobject. |
<br>validations: <br> name: metaobject_definition_id,<br> value: "gid://shopify/MetaobjectDefinition/123"<br> |
---|
I am confused because I am referencing the object in the validation, the object exists. What field is supposed to be passed to reference the metaObject.