Created
August 16, 2022 13:00
-
-
Save paramsinghvc/7b0c59821084c0c8df8b0c7af469b0bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Parent, Query, ResolveField, Resolver } from '@nestjs/graphql'; | |
import { AlbumService } from '@src/album/album.service'; | |
import { Album } from '@src/album/entities/album.entity'; | |
import { Photo } from '@src/photo/entities/photo.entity'; | |
import { PhotoService } from '@src/photo/photo.service'; | |
import { User } from './entities/user.entity'; | |
import { UserService } from './user.service'; | |
@Resolver(() => User) | |
export class UserResolver { | |
constructor( | |
private userService: UserService, | |
private albumService: AlbumService, | |
private photoService: PhotoService, | |
) {} | |
@Query(() => User) | |
me(@CurrentUser() user: User) { | |
return this.userService.findOne(user.id); | |
} | |
@ResolveField(() => [Album]) | |
albums(@Parent() user: User) { | |
return this.albumService.findByUserId(user.id); | |
} | |
@ResolveField(() => [Photo]) | |
photos(@Parent() user: User) { | |
return this.photoService.findByUserId(user.id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment