Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello everyone !
I'm trying to know if a metafieldDefinition is accessible via Storefront, using GraphQL Admin API. Here is the query :
query AccessBug { metafieldDefinition(id: "gid://shopify/MetafieldDefinition/4975853900") { id access { admin } } }
Whenever I try this, I get the error message "Access denied for access field.". I have enabled all Admin access scopes for my app and still getting this. I can still use the field 'visibleToStorefrontApi' but it's marked as deprecated and recommends using access... Any idea what I could be doing wrong ?
Thank you !
Solved! Go to the solution
This is an accepted solution.
Hi,
I have the same issue and discovered that it relates to the namespace of the metafield definition.
For some reason the GraphiQL app cannot access the "access" element of metafield definitions created through the Shopify admin interface.
If, however you create the metafield definition using a mutation in the GraphiQL app and set the namespace of the definition to something like $app:* (could be $app:somename), then the namespace ends up something like this: "namespace": "app--2315872--somename" (I guess the 2315872 is the ID of the GraphiQL app).
After doing this you can access the metafield definition access element through a query like the one in your question.
Doing this however, you cannot modify the definition through the Shopify admin interface any more ....
Seems kind of strange, but that is the current behaviour.
Hey there! I am having the exact same issue, if you have any update, please let me know
that would be very helpful.
thanks!
This is an accepted solution.
Hi,
I have the same issue and discovered that it relates to the namespace of the metafield definition.
For some reason the GraphiQL app cannot access the "access" element of metafield definitions created through the Shopify admin interface.
If, however you create the metafield definition using a mutation in the GraphiQL app and set the namespace of the definition to something like $app:* (could be $app:somename), then the namespace ends up something like this: "namespace": "app--2315872--somename" (I guess the 2315872 is the ID of the GraphiQL app).
After doing this you can access the metafield definition access element through a query like the one in your question.
Doing this however, you cannot modify the definition through the Shopify admin interface any more ....
Seems kind of strange, but that is the current behaviour.
Thank you SorenSkyum for your detailed answer! After testing I can confirm (and regret) the current behaviour.
I managed to remove hanging Unstructured product metafields (was left after I removed it form Metafields) by removing the value for each product first.