Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Definition not found with CreateMetafieldStorefrontVisibility

Definition not found with CreateMetafieldStorefrontVisibility

straatrakker
Shopify Partner
1 0 0

I have a nextJS project using shopify headless.

 

I have created an extra metafield for my products (ingredients). I tried following this tutorial: https://shopify.dev/docs/custom-storefronts/building-with-the-storefront-api/products-collections/me.... I already created the metafield in shopify (see the screenshot below).

 

Scherm­afbeelding 2024-03-01 om 16.10.08.png

 

The tutorial wants me to expose my metafield. I have tried this using curl. See my command below:

 

 

curl -X POST \

https://{my-store}.myshopify.com/admin/api/2024-01/graphql.json \

-H 'Content-Type: application/json' \

-H 'X-Shopify-Access-Token: {my-token}' \

-d '{

"query": "mutation CreateMetafieldStorefrontVisibility($input: MetafieldStorefrontVisibilityInput!) { metafieldStorefrontVisibilityCreate(input: $input) { metafieldStorefrontVisibility { namespace key } userErrors { field message } } }",

"variables": {

    "input": {

      "namespace": "custom.ingredients",

      "key": "custom.ingredients",

      "ownerType": "PRODUCT"

    }

  }

}'

 

 

When running this command I get the following error:Scherm­afbeelding 2024-03-01 om 16.13.19.png

 

Does anyone know how to resolve this issue?

 

Reply 1 (1)

kjchabra
Shopify Partner
26 1 7

@straatrakker sorry this might be a bit late but your namespace value should be set to custom and key value should be ingredients