-
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
Showing
4 changed files
with
22 additions
and
3 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,13 +1,16 @@ | ||
import { IsNotEmpty } from 'class-validator'; | ||
import { InputType, Field } from '@nestjs/graphql'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
@InputType() | ||
export class CreatePostInput { | ||
@Field() | ||
@Field() // GraphQL 데코레이터 | ||
@ApiProperty({ description: 'The content of the post' }) // Swagger 데코레이터 | ||
@IsNotEmpty() | ||
content: string; | ||
|
||
@Field() | ||
@Field() // GraphQL 데코레이터 | ||
@ApiProperty({ description: 'The title of the post' }) // Swagger 데코레이터 | ||
@IsNotEmpty() | ||
title: string; | ||
} |
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 |
---|---|---|
@@ -1,18 +1,27 @@ | ||
import { Field, ObjectType } from '@nestjs/graphql'; | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { User } from '../../users/models/user.model'; | ||
import { BaseModel } from '../../common/models/base.model'; | ||
|
||
@ObjectType() | ||
export class Post extends BaseModel { | ||
@Field() | ||
@ApiProperty({ description: 'The title of the post' }) | ||
title: string; | ||
|
||
@Field(() => String, { nullable: true }) | ||
@ApiProperty({ description: 'The content of the post', nullable: true }) | ||
content?: string | null; | ||
|
||
@Field(() => Boolean) | ||
@ApiProperty({ description: 'Whether the post is published or not' }) | ||
published: boolean; | ||
|
||
@Field(() => User, { nullable: true }) | ||
@ApiProperty({ | ||
description: 'The author of the post', | ||
nullable: true, | ||
type: () => User, | ||
}) | ||
author?: User | null; | ||
} |
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,8 +1,10 @@ | ||
import { PostsController } from './posts.controller'; | ||
import { Module } from '@nestjs/common'; | ||
import { PostsResolver } from './posts.resolver'; | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [PostsController], | ||
providers: [PostsResolver], | ||
}) | ||
export class PostsModule {} |