You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shopify GraphQL更新产品category字段报错:Field is not defined on ProductInput

问题解决:Shopify API更新产品分类报错

错误提示已经明确指出核心问题:category字段并未定义在ProductInput类型中,所以你提到的两种修改方式(调整请求selector、将category改为对象格式)都无法解决问题——因为这个字段本身就不是ProductInput的合法参数。

正确的更新方式

Shopify GraphQL API中,更新产品分类需要使用taxonomyCategoryId参数(而非category),直接传入分类的GID即可。

正确的Mutation请求

mutation ProductUpdate($input: ProductInput!) {                                 
  productUpdate(input: $input) {                                                
    product {                                                                   
      id                                                                         
      title                                                                      
      category {                                                                
        id                                                                      
      }                                                                          
    }                                                                            
    userErrors {                                                                
      field                                                                      
      message                                                                   
    }                                                                            
  }                                                                             
}

正确的变量内容

{                                                                   
  "input": {                                                                    
    "id": "gid://shopify/Product/9819449721123",                                
    "taxonomyCategoryId": "gid://shopify/TaxonomyCategory/aa-1-10-2"                     
  }                                                                             
}

补充说明

  • 请求中保留category { id }是正确的,这是用于查询更新后分类信息的返回字段,无需修改。
  • 变量仅需替换参数名:把category改为taxonomyCategoryId,值仍使用分类的GID字符串即可。

内容的提问来源于stack exchange,提问作者Dustin Oprea

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 01:50:03