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

Apollo Federation中"_Any"类型值不符合预期的问题排查

解决GraphiQL变量报错:expected value of type "_Any"

以下是针对该错误的具体修复步骤:

  • 替换所有占位符X为实际有效值
    变量中的X是占位符,必须替换成符合类型要求的真实值:

    • classId、count、brandCatalogId、storeId如果是数字类型(对应GraphQL的Int),要写具体数字,不能保留X;
    • templateId要替换成实际的字符串ID。
  • 修复market字段的格式
    当前market字段是字符串化的JSON,若GraphQL schema中market定义为对象类型,不能传字符串,需直接传入JSON对象,去掉外层引号和转义:
    原错误写法:

    "market": "{\"brandCatalogId\":X,\"storeId\":X,\"brand\":null,\"channel\":null,\"country\":null,\"locale\":\"en_US\",\"location\":null,\"segment\":null}"
    

    修正后:

    "market": {
      "brandCatalogId": 123,
      "storeId": 456,
      "brand": null,
      "channel": null,
      "country": null,
      "locale": "en_US",
      "location": null,
      "segment": null
    }
    
  • 统一__typename的大小写
    GraphQL类型名称大小写敏感,你当前变量中__typename有dummy和Dummy两种写法,需严格匹配schema中定义的类型名称,统一成正确的大小写形式。

  • 验证变量结构与schema匹配
    确认representations数组中的对象完全符合_Any类型对应的输入结构,检查是否缺少必填字段、字段类型是否匹配(比如数字不能写成字符串,对象不能写成字符串)。

修正后的变量示例

{
  "representations": [
    {
      "__typename": "Dummy",
      "templateId": "TM-001",
      "strategy": "dummy",
      "listingVariant": {
        "__typename": "Dummy",
        "internalSku": "SKU-DUMMY",
        "market": {
          "brandCatalogId": 1001,
          "storeId": 2002,
          "brand": null,
          "channel": null,
          "country": null,
          "locale": "en_US",
          "location": null,
          "segment": null
        },
        "selections": [],
        "listing": {
          "__typename": "Dummy",
          "primaryClass": {
            "classId": 3003
          }
        }
      }
    }
  ],
  "subStrategyId": "Dummy",
  "preferredShipToLocation": {
    "postalCode": "90210"
  },
  "count": 20
}

内容的提问来源于stack exchange,提问作者Harsh Agarwal

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 16:12:41