Access denied for access field on metafieldDefinition

Topic summary

Developers are encountering an “Access denied” error when querying the access field on metafieldDefinition via Shopify’s GraphQL Admin API, despite having all required access scopes enabled. The deprecated visibleToStorefrontApi field works, but the recommended access field remains inaccessible.

Root Cause Identified:

  • The issue relates to metafield definition namespace
  • Metafield definitions created through Shopify’s admin interface cannot have their access field queried via GraphiQL app
  • Definitions created via GraphQL mutation with app-specific namespaces (e.g., $app:somename) are accessible

Workaround & Limitation:

  • Create metafield definitions programmatically using mutations with app namespaces (results in format like app--2315872--somename)
  • Trade-off: Definitions created this way lose editability through Shopify’s admin interface

Status: Confirmed behavior by multiple users, but appears to be an unintended limitation rather than a resolved issue.

Summarized with AI on October 27. AI used: claude-sonnet-4-5-20250929.

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 !

3 Likes

Hey there! I am having the exact same issue, if you have any update, please let me know
that would be very helpful.

thanks!

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.

3 Likes

Thank you SorenSkyum for your detailed answer! After testing I can confirm (and regret) the current behaviour.

1 Like

I managed to remove hanging Unstructured product metafields (was left after I removed it form Metafields) by removing the value for each product first.