It says to use the GraphQL Admin API (which is: ‘Shopify’s own GraphiQL app’) to ‘Expose the metafields’
This now leads to my original post… I can read the data using the ‘GraphiQL app’ fine, but I get the auth error when following the ‘Expose metafields to the Storefront API’ documentation.
@Nesters Thanks dude!
Ok so. for reference I had all the permissions which had ‘GraphQL’ in the name enabled to ‘read and write’ and was still getting the issue.
So, I went ahead and just gave read/write to a bunch more and it worked for some reason. Once I find the exact ones I’ll post it here for anyone else with the same issue.
I had to use the Mac App ‘GraphiQL’ to do the query so I could include the token. the App int he Shopify Admin area kept giving me the access issue.
For anyone using the APP your GraphQL Endpoint should be:
https://.myshopify.com/admin/api/2019-07/graphql.json?access_token=
Thanks @SBD
Ok so now I have successfully ( I think ) managed to ‘Expose’ the Metafields do I have to do additional queries to retrieve them?
I have added the query vars for each field in the GraphiQL App (crazy you just can’t expose all keys for a certain namespace) and have the response gid for each like so: gid://shopify/MetafieldStorefrontVisibility/xxxxxxx
If I am doing a query in the BUY SDK like:
client.product.fetch(productId).then((product) => {
// Do something with the product
console.log(product);
});
Should the metafields be visible within ‘product’ ?
like product.metafields.{namespace}.{key}
@SBD YAAASSS!!! They are finally coming through. Thank you for that example. Now the only bad part about this is having to ‘add’ every field to that query again (unless there is a fast way other than doing like 50 add(‘availableForSale’), add(‘createdAt’) etc etc? ).
but hey… the fields are coming through so thats a start!
I had tried the direct query but I kept getting a Cross Domain issue.
I am facing the same issue right now with the only difference being the ownerType: “COLLECTION” and I’m getting the same error. Did you manage to solve it? If not, can someone help, please?
It seems ■■■■■■■■ and not very intuitive that we dont get product metafields back unless jumping through hoops. Why would we ever not want all product metafields.. exactly. I see people adding mutations and graphql queries to change visibility but how does this work with Hydrogen’s <Product.Metafield> component… realizing none of my custom metafields are pulling in.