Re: Metafields Not Showing In GraphQl API

Metafields Not Showing In GraphQl API

prashant124
Visitor
2 0 0

Here is my CODE

 

For Metafields I'm using the MetafieldsGuru App

 

When I'm doing post request to this it gives me products but with empty metafields

 

 

 

 

 

axios
.post(
'https://thirdwavecoffeeroasterscom.myshopify.com/api/2021-10/graphql.json',
{
query: `
query {
products(first:20, query:"tag:bean") {
edges {
node {
id
handle
title
images(first:1, maxWidth:360) {
edges {
node {
src
}
}
}
variants(first:1) {
edges {
node {
id
price
}
}
}
metafields(first: 250) {
edges {
node {
namespace
key
value
}
}
}
}
}
}
}
`
},
{
headers: {
'X-Shopify-Storefront-Access-Token':
'**********MY TOKEN*************',
'Content-Type': 'application/json'
}
}
)

 

 

 

 

 
 

ThankYou!

Replies 2 (2)

swalkinshaw
Shopify Staff
20 4 12

It looks like you're using the Storefront API (based on the `/api/2021-10/graphql.json` URL). Metafields aren't exposed in the Storefront API by default; they require an extra step to make them visible. If you haven't explicitly done this, then I'm guessing that's the issue.

 

You can read more at https://shopify.dev/custom-storefronts/products/metafields#expose-metafields

To learn more visit the Shopify Help Center or the Community Blog.

prashant124
Visitor
2 0 0

Swalkinshaw,

 

Thank you for your reply I'm new to graphQL so place can you share GraphQL query for Products with Metafields.

 

 

 

 

 

Thank you!