Skip to content

Commit

Permalink
refactor: get blog post by slug
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrdsilva committed May 30, 2024
1 parent 091b7de commit afdaee6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/providers/blog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class BlogService {
return await this.blogRepository.find({ order: { createdAt: 'DESC' } });
}

async findById(id: string) {
return await this.blogRepository.findOneBy({ id: id });
async findBySlug(slug: string) {
return await this.blogRepository.findOneBy({ slug: slug });
}
}
4 changes: 2 additions & 2 deletions src/resolvers/blog.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class BlogResolver {
}

@Query(() => Blog)
findBlogPost(@Args('id') id: string) {
return this.blogService.findById(id);
findBlogPost(@Args('slug') slug: string) {
return this.blogService.findBySlug(slug);
}
}

0 comments on commit afdaee6

Please sign in to comment.