我正在尝试通过GraphQL在BigCommmerce上检索产品元字段。下面的代码抛出错误
query {
site {
product(entityId:639) {
sku
path
metafields(namespace: "App_Namespace", keys: "color_key") {
edges {
node {
id
value
}
}
}
}
}
}
元字段信息
Namespace App_Namespace
Key color_key
Description Colour
Value Blue | Grey | Yellow
将感谢您在以上任何帮助。谢谢
答案 0 :(得分:1)
“ keys”参数需要一个键数组。因此,即使您只想要一个密钥,也可以将其作为一个密钥数组提交:
query {
site {
product(entityId: 639) {
sku
path
metafields(namespace: "App_Namespace", keys: ["color_key"]) {
edges {
node {
id
value
}
}
}
}
}
}
查看此链接以获取更多示例: https://developer.bigcommerce.com/changelog#posts/graph-ql-storefront-api-updates-metafields-on-product-category-brand-variant
答案 1 :(得分:1)
您还需要确保满足这些要求, 否则,即使查询正确,您也无法获取查询中的元字段:
必须使用 read_and_sf_access 或 write_and_sf_access 的权限集标记元字段,以便向 API 公开。具有任何其他权限值的元字段将被隐藏。