Search code examples
graphqlnestjstypeorm

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);
    }
}

Solution

  • It is my answer:

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