A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm receiving a "LINKED_METAFIELD_DEFINITION_NOT_FOUND" error when trying to link product options to a metafield with a `productOptionsCreate` query. I've verified both the product I'm trying to create options for and the metafield in question exist.
Following along with the example seen here: https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/productOptionsCreate?example=Create+a+p...
With the following query, I've verified the Product metafield exists:
query { metafieldDefinitions(first: 250, ownerType: PRODUCT) { edges { node { name namespace key type { name } } } } }
Which returns:
{ "data": { "metafieldDefinitions": { "edges": [ { "node": { "name": "Colors", "namespace": "mynamespace", "key": "colors", "type": { "name": "list.metaobject_reference" } } } // TRUNCATED // ] } } }
However, when using the same metafield namespace/key combination of mynamespace.colors, I get the "LINKED_METAFIELD_DEFINITION_NOT_FOUND" error.
mutation createOptions($productId: ID!, $options: [OptionCreateInput!]!) { productOptionsCreate(productId: $productId, options: $options) { userErrors { field message code } product { options { name linkedMetafield { namespace key } optionValues { name linkedMetafieldValue } } } } } // Variables: { "productId": "gid://shopify/Product/########", "options": [ { "name": "Colors", "linkedMetafield": { "namespace": "mynamespace", "key": "colors" } } ] }
Returns:
{ "data": { "productOptionsCreate": { "userErrors": [ { "field": [ "options" ], "message": "No valid metafield definition found at 'mynamespace.colors' for linked option", "code": "LINKED_METAFIELD_DEFINITION_NOT_FOUND" } ], "product": { "options": [ { "name": "Title", "linkedMetafield": null, "optionValues": [ { "name": "Default Title", "linkedMetafieldValue": null } ] } ] } } } }