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

Access denied for access field on metafieldDefinition

Solved

Access denied for access field on metafieldDefinition

DrMartinGonzo
Shopify Partner
2 0 3

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 !

Accepted Solution (1)

SorenSkyum
Shopify Partner
10 1 10

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.

View solution in original post

Replies 4 (4)

gabeDev
Shopify Partner
2 0 1

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

thanks!

SorenSkyum
Shopify Partner
10 1 10

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.

DrMartinGonzo
Shopify Partner
2 0 3

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

madfcat
Shopify Partner
7 0 2

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