【发布时间】:2021-11-17 18:48:11
【问题描述】:
我正在尝试访问以下输入中字段装饰器的名称值。
//myInput.ts
@InputType()
export class MyInput {
@Field(() => Int, { name: "price" })
priceValue: number;
}
//myResolver.ts
@Resolver()
export class MyResolver {
constructor(private readonly myService: MyService){}
@Query(() => boolean)
async prices(@Args('input') input: MyInput){
/*
So in typescript system the input field is named `priceValue` but in the
graphql side is named `price` (This is the string i want to access)
*/
}
}
我尝试了各种方法,例如使用 @Info() 装饰器和 TypeMetadaStorage,但我找不到重命名值。
有什么办法可以访问这个字段吗?
【问题讨论】:
标签: typescript graphql nestjs