Since according to the documentation, we cannot access reserved-namespace metafields from a Checkout UI extension and we can not use a namespace that’s not owned by the app in the Customer Account extension (since we can’t change its customerAccountaccess propery), as far as I can tell there is no way to use one metafield in both types of extensions. Is there any way to do this? Or if not, what is the reason behind this design decision?
Hi, the lack of support for app-reserved namespaces via Checkout UI extensions is a known issue and is currently being worked on.
In the meantime, the only way to access metafields on both surfaces is to create them outside of the app-reserved namespace (e.g. not prefixed with $app) and ensuring that both surfaces have the proper permissions to access them.
I’m able to retrieve access reserved-namespace shop metafields from the customer account ui extension by using the customer account API
Yes, using the Customer Account API, I’m also able to access reserved-namespace metafields, however not, using the Storefront API. I am trying to get the Customer resource metafields, so the code you showed won’t work (using the Storefront API we need to specify the customerAccessToken for the customer query, which as far as I know is not possible to get from a Checkout extension).
Also, why cannot you change the customerAccount access property? You have to change it from the metafield definition
When I try to change the access property of a regular (not reserved-namespace) metafield, I get the error described in this post (Setting access controls on a definition under this namespace is not permitted) and I’m not sure how to resolve that.
In the meantime, the only way to access metafields on both surfaces is to create them outside of the app-reserved namespace (e.g. not prefixed with $app ) and ensuring that both surfaces have the proper permissions to access them.
Does that mean that I can change the access of a metafield that have a namespace not starting with $app? When I tried that I got the error described in this post (Setting access controls on a definition under this namespace is not permitted). Can you advise me on what I’m doing wrong?
I’m not sure how to do that since when I’m trying to specify the access in the metafieldDefinitionCreate or metafieldDefinitionUpdate, then I get the error I mentioned. This is my full mutation:
Thank you for your reply. However, this is not a suitable solution for us, since we cannot require every merchant to change the access permissions after they installed the app. Is there no way to do this via the Admin API?
We have the same problem. Our current solution (and I think it is the only one) is to force the merchant to put the customer account access to Read and write
As you said, it is not possible to set these properties using the GraphQL admin API unless the metafield definition namespace is the app reserved one $app:<some namespace>
I spent a bit of time looking into this and it looks like changing those access controls on a metafield in the custom namespace is not possible for 3rd party clients. I believe this was done intentionally to push apps towards using app-reserved namespaces.
Unfortunately, as you pointed out, this is a problem since checkout extensions don’t presently have access to the app-reserved namespaces.
I know that this is something that is being actively worked on, but unfortunately for the time being, the only workaround is for the merchant to update access controls via Admin.
+1 This is the only way we’ve found to be able to change the access settings for non app reserved metafields. We can detect if metafields being used in the app don’t have the correct access and display a warning for the merchant to update, but the app cannot do so automatically.