파크로그
article thumbnail
Node express 에 swagger 얹기
Backend/🚀 Node 2022. 7. 27. 16:59

Swagger? 프론트엔드-백엔드가 같이 프로젝트를 하면 API 명세를 통해 의사소통을 하게됩니다. 이 때 API 명세는 사람이 직접 적는 문서 형식으로 Notion, Github Wiki 등을 활용할 수는 있지만 몇가지 불편한 점이 있습니다. 1. 변경을 추적하기 어렵다는 점 2. 변경이 될 때마다 프론트엔드 에게 인지를 시켜줘야 한다는 점 3. 혹시 모를 오탈자로 고생할 일이 적어짐 세 가지 모두 프로젝트를 하면서 겪었던 문제였는데요, Swagger 를 통해 문서화를 자동화하면 이를 해결해볼 수 있습니다. 🚀 설치 npm install -D swagger-jsdoc swagger-ui-express - -D 옵션으로 devDependency 에 설치하였습니다. - swagger-ui-express 는..

[Nest] Cannot determine a GraphQL input type for the "...". Make sure your class is decorated with an appropriate decorator.
Backend/🐯 Nest 2021. 8. 26. 21:11

fakeDB [] 에서 sqlite 로 옮기던 와중, Many-To-One, One-To-Many 관계 설정을 하고 있었는데, 마지막 단계에서 아래와 같은 오류가 발생했다. Cannot determine a GraphQL input type for the "...". Make sure your class is decorated with an appropriate decorator. 아무리 눈을 씻고 찾아봐도 InputType 을 넣어주지 않은 클래스는 없었다. 혹시나 싶어 create input dto 를 뒤져보면서, OmitType 을 PickType 으로 로직을 바꾸어 사용해보니 위와 같은 에러가 사라졌다. // 에러난 로직 @InputType() export class CreateEpisodeInp..

article thumbnail
[Nest] Cannot find module 'class-transformer/storage' , Cannot find module 'ts-morph'
Backend/🐯 Nest 2021. 8. 25. 22:35

class-transformer 모듈 관련 오류였는데, @nestjs/graphql 버전이 8 버전으로 업그레이드 된 상황에서 강의상황에 맞춰가기 위해 7.9.4 버전으로 사용하고 있었음, 그 상황에서 발생한 오류라고 판단 https://github.com/typestack/class-transformer/issues/566 global 로 설치된 nestjs cli 를 버전 업 하고, nest js docs 에서 제시한 새로운 graphql 설치 방향으로 진행 // cli 업데이트 $ npm i -g @nestjs/cli // graphql 설치 $ npm i @nestjs/graphql graphql apollo-server-express@2.x.x https://docs.nestjs.kr/graph..

[Nest] Cannot determine a GraphQL output type for the "...". Make sure your class is decorated with an appropriate decorator.
Backend/🐯 Nest 2021. 8. 25. 22:35

Cannot determine a GraphQL output type for the "...". Make sure your class is decorated with an appropriate decorator.GraphQL 에서 Return Type을 통일시켜주기 위해 Output Dto 를 만들었으나, 해당 Output 을 적용하려고 하니 생긴 오류Output 에도 데코레이터를 적용시켜줘야함.GraphQL 에게 타입을 알려주는 Field 도 깜빡하지 말고 넣자.import { ObjectType } from '@nestjs/graphql'; import { CommonOutput } from 'src/common/dtos/output.dto'; import { Podcast } from '../ent..

[Nest] TS2345: Argument of type 'TypedPropertyDescriptor<'somthing'>' is not assignable to parameter of type 'number'
Backend/🐯 Nest 2021. 8. 25. 22:34

TS2345: Argument of type 'TypedPropertyDescriptor Podcast[]>' is not assignable to parameter of type 'number' GraphQL Query 를 작성할 때, @nestjs/common 이 아닌 @nestjs/graphql 에서 import 되어야 한다. 자동으로 common 에서 import 되는 경우가 많으니 주의하도록 하자. import { Query } from '@nestjs/common'; import { Resolver } from '@nestjs/graphql'; import { Podcast } from './entities/podcast.entity'; import { PodcastsService } from..

[MongoDB] collections에 필드 생성 및 삭제
Backend/🛢 DataBase 2020. 12. 22. 20:16

- 기존에 쓰고있던 collections ( Post - 게시글 데이터베이스 ) 에서, 게시글을 각각 지우는 것은 로직 비용이 크기에, isDeleted 컬럼을 추가하여 사용여부를 판단하기로 결정하였다. mongoDB로 기존에 쓰고있던 collections에 어떻게 field를 추가할까? > db.posts.update({}, {$set: {isDelete:false}}, false, true) WriteResult({ "nMatched" : 4, "nUpserted" : 0, "nModified" : 4 }) > db.posts.update({}, {$unset: {isDelete:false}}, false, true) WriteResult({ "nMatched" : 4, "nUpserted" : 0,..