问题描述
我正在尝试使用官方文档中提到的使用 graphql 查询的自定义属性过滤从后端 magento2 检索到的产品:[https://devdocs.magento.com/guides/v2.4/graphql/custom-filters。 htm] 使用 attribute_code: "color" 作为自定义属性存在,但在邮递员中给了我以下错误:"字段 "color" 不是由 ProductAttributeFilterInput 类型定义的。"
这是我的查询:`{ 产品(过滤器:{
color: { eq: "4677" } }) {
total_count
items {
name
sku
price
}
} }`
我使用的是 magento 2.3.4
如果有人能帮助我,我将不胜感激
解决方法
就错误消息而言,我可以理解在 ProductAttributeFilterInput 中未声明颜色字段。请再次检查 schema.graphqls 文件并确保正确声明了您想要的字段