繁体   English   中英

我可以将 args 的类型从 graphql 的解析器更改为 id 吗?

[英]Can I change the type of args from graphql's resolver to id?

我想从查询中的 graphql 的 ID 类型更改类型。 是否可以?

id:数字 ==> id:ID

@Resolver()
export class LocationResolver {
    constructor(private readonly locationService: LocationService) {}

    @Query(() => Location_Group)
    async locationGroup(@Args('id') id: number): Promise<Location_Group> {
        return await this.locationService.getLocationGroup(id);
    }
}

这是我的回答:

@Query(() => Location)
async location(
    @Args('id', { type: () => ID }) id: number
): Promise<Location> {
    return await this.locationService.findLocation(id);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM