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

Schema Stitching扩展Mutation传递参数报错求助

Schema Stitching扩展Mutation参数传递错误解决

问题代码

extend type Mutation {
  space(value: SpaceInput): Int! @delegate(schema: "matterport", path: "space(value: $arguments:value)")
}

错误信息

{
  "errors": [
    {
      "message": "The variable `__arguments_value` is not compatible with the type of the current location.",
      "locations": [
        {
          "line": 2,
          "column": 5
        }
      ],
      "path": [
        "space"
      ],
      "extensions": {
        "variable": "__arguments_value",
        "variableType": "SpaceInput",
        "locationType": "SpaceInput!",
        "specifiedBy": "http://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed",
        "remote": {
          "message": "The variable `__arguments_value` is not compatible with the type of the current location.",
          "path": [
            "space"
          ],
          "extensions": {
            "variable": "__arguments_value",
            "variableType": "SpaceInput",
            "locationType": "SpaceInput!",
            "specifiedBy": "http://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed"
          }
        },
        "schemaName": "matterport"
      }
    }
  ]
}

问题根源

  1. 参数必填性不匹配:远程matterport schema中,space mutation的value参数是必填类型SpaceInput!,但本地扩展的Mutation里定义的value是可选类型SpaceInput,导致传递的变量可能为null,不符合远程的非空要求。
  2. @delegate变量引用语法错误:路径中的变量引用应该用$arguments.value而非$arguments:value,冒号是错误语法,会导致变量映射异常。

修复后的代码

extend type Mutation {
  space(value: SpaceInput!): Int! @delegate(schema: "matterport", path: "space(value: $arguments.value)")
}

验证要点

  • 确保本地定义的参数类型(包括必填性)和远程schema完全一致
  • 检查@delegate指令的path参数中,变量引用的语法符合你使用的Schema Stitching工具规范(比如GraphQL Tools中使用$arguments.参数名引用当前字段的参数)

内容的提问来源于stack exchange,提问作者Patrik Urban

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 19:22:54