graphql - Magento PWA Studio + 将下拉属性值(产品)检索到前端
问题描述
我正在使用 mageto PWA studio 开发一个电子商务网站。
我已经从 magento 管理面板创建了“主题”产品下拉属性。
我的要求是:我必须在产品详细信息页面中显示主题值。
为此,我在现有产品页面 GraphQL 查询中添加了以下查询:
第一次我尝试了以下方式
export const ProductDetailsFragment = gql`
fragment ProductDetailsFragment on ProductInterface {
__typename
categories {
id
breadcrumbs {
category_id
}
}
description {
html
}
id
media_gallery_entries {
id
label
position
disabled
file
}
meta_description
name
price {
regularPrice {
amount {
currency
value
}
}
}
sku
small_image {
url
}
url_key
subject
}
`;
输出:而不是主题值,它给出了主题的选项ID。
第二我尝试了以下方式
export const ProductDetailsFragment = gql`
fragment ProductDetailsFragment on ProductInterface {
__typename
categories {
id
breadcrumbs {
category_id
}
}
description {
html
}
id
media_gallery_entries {
id
label
position
disabled
file
}
meta_description
name
price {
regularPrice {
amount {
currency
value
}
}
}
sku
small_image {
url
}
url_key
subject {
label
value
}
}
`;
输出:抛出控制台错误
我怎样才能摆脱这个问题..
解决方案
推荐阅读
- json - 如何使用 jq 选择包含其他元素值的元素作为子字符串
- spring-boot - 春季启动 2.0.3。REALESE 和 Thymeleaf 数据绑定
- python - 关于在 Python Keras 中正确实现迁移学习的问题
- c# - 从`BlazorInputFile.IFileStream`获取`byte []`的最简单方法是什么
- laravel - 如何将文件从子域文件夹上传到laravel中的根文件夹?
- networking - 将请求从一个应用程序重定向到另一个
- python - 我如何(以编程方式)获取 Snowflake 的保留字列表?
- chatbot - 使用 mochawesome 的 Botium-cli 对话流:未定义的按钮
- c# - 转换输出并拆分成更小的字符串
- nginx - 在本地开发中使 Nginx 帮助重定向