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

TypeGraphQL类型推断报错:需为UpdateCoordinatesInput的list_of_coordinate_ids指定显式类型

问题解决方法

核心原因是TypeGraphQL无法通过TypeScript反射系统自动推断数组的元素类型,所有数组类型字段必须在@Field装饰器中显式声明GraphQL类型。你需要修改所有输入类中list_of_coordinate_ids对应的@Field装饰器声明:

1. 修改CreateCurrentRoutesInput类

将list_of_coordinate_ids的@Field装饰器显式指定为字符串数组类型:

import { InputType, Field } from "type-graphql";

@InputType()
export class CreateCurrentRoutesInput {
  @Field(() => [String])
  list_of_coordinate_ids:string[]

  @Field()
  carrier_id:number;
}

2. 修改UpdateCurrentRoutesInput类(及报错中提到的UpdateCoordinatesInput类)

如果是可选字段,显式指定类型的同时保留nullable配置:

import { InputType, Field } from "type-graphql";

@InputType()
export class UpdateCurrentRoutesInput {
  @Field(() => [String], {nullable:true})
  list_of_coordinate_ids?:string[]

  @Field({nullable:true})
  carrier_id?:number;
}

注意:你Resolver的updateCoordinates方法中用到的UpdateCoordinatesInput类如果也包含list_of_coordinate_ids字段,需要按同样规则修改该字段的@Field装饰器。

修改完成后重启服务即可解决该报错。


内容的提问来源于stack exchange,提问作者Ankit Sanghvi

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 15:24:02