-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0474d61
commit e10a70f
Showing
4 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,42 @@ | ||
import { Field, ID, Int, ObjectType } from '@nestjs/graphql'; | ||
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; | ||
|
||
@Entity() | ||
@ObjectType() | ||
export class Blog { | ||
@PrimaryGeneratedColumn('uuid') | ||
@Field(() => ID) | ||
id: string; | ||
|
||
@Column({ nullable: false }) | ||
@Field(() => String) | ||
title: string; | ||
|
||
@Column({ nullable: false }) | ||
@Field(() => String) | ||
description: string; | ||
|
||
@Column() | ||
@Field(() => String) | ||
filename: string; | ||
|
||
@Column({ type: 'json', nullable: false }) | ||
@Field(() => String) | ||
body: string; | ||
|
||
@Column({ default: 0 }) | ||
@Field(() => Int) | ||
views: number; | ||
|
||
@Column({ type: 'json' }) | ||
@Field(() => [String]) | ||
tags: string[]; | ||
|
||
@CreateDateColumn({ name: 'created_at' }) | ||
@Field(() => Date) | ||
createdAt: Date; | ||
|
||
@UpdateDateColumn({ name: 'updated_at' }) | ||
@Field(() => Date) | ||
updatedAt: Date; | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { UseGuards } from '@nestjs/common'; | ||
import { Query, Resolver } from '@nestjs/graphql'; | ||
import { JwtAuthGuard } from 'src/auth/auth.guard'; | ||
import { Blog } from 'src/entities/blog.entity'; | ||
import { BlogService } from 'src/providers/blog.service'; | ||
import { File } from '../entities/file.entity'; | ||
|
||
@Resolver(() => File) | ||
export class BlogResolver { | ||
constructor(private readonly blogService: BlogService) {} | ||
|
||
// @UseGuards(JwtAuthGuard) | ||
@Query(() => [Blog]) | ||
findBlogPosts() { | ||
return this.blogService.find(); | ||
} | ||
} |