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
도 깜빡하지 말고 넣자.
- GraphQL 에게 타입을 알려주는
import { ObjectType } from '@nestjs/graphql'; import { CommonOutput } from 'src/common/dtos/output.dto'; import { Podcast } from '../entities/podcast.entity'; export class PodcastsOutput extends CommonOutput { podcasts?: Podcast[]; } export class PodcastOutput extends CommonOutput { podcast?: Podcast; } -> @ObjectType() export class PodcastsOutput extends CommonOutput { @Field((type) => [Podcast], { nullable: true }) podcasts?: Podcast[]; } @ObjectType() export class PodcastOutput extends CommonOutput { @Field((type) => Podcast, { nullable: true }) podcast?: Podcast; }
- GraphQL 에서 Return Type을 통일시켜주기 위해
Backend/🐯 Nest
Uploaded by Notion2Tistory v1.1.0