简体   繁体   中英

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

I would like to change the type from graphql's ID type in the query. Is it possible?

id: number ==> 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);
    }
}

It is my answer:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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