inflearn logo
강의

講義

知識共有

[コードキャンプ]ブートキャンプで作られた高濃縮バックエンドコース

10-01 Entity 実装

schema.gql 질문 드립니다.

解決済みの質問

51

gkdlsb1234

投稿した質問数 14

0

 entity 등으로 생성된 tpye 에서
강의에서 사용된 코드로 예시를 들면

# product.entity.ts
@JoinTable()
  @ManyToMany(() => ProductTag, (productTags) => productTags.products)
  @Field(() => [ProductTag], { nullable: true })
  productTags: ProductTag[];

위와같이 nullable 을 사용하여

#schema.gql

type Product {
  productId: String
  productName: String!
  description: String!
  productPrice: Int!
  isSoldout: Boolean!
  productSalesLocation: ProductSalesLocation
  productCategory: ProductCategory
  user: User
  productTags: [ProductTag!]
}

productTags: [ProductTag!] 와 같이 할 수 있었습니다.

위에서 productTags: [ProductTag!]
를 productTags: [ProductTag] 와같이 변경 해보려고합니다.
방법이 있나요?

@Field(() => [ProductTag, { nullable: true }], { nullable: true })

에러는 발생하지 않지만 안됩니다.

javascript node.js docker rest-api nestjs

回答 1

0

nwd09074926

안녕하세요! gkdlsb1234님!

이전부터 점점 실력이 많이 늘고 계신게 느껴지네요!^^

nullable을 주는 방법으로 크게 3가지 방법이 있어요!

// 1. nullable: true
@Field(() => [ProductTag], { nullable: true }) // 결과: [ProductTag!]


// 2. nullable: "items"
@Field(() => [ProductTag], { nullable: "items" }) // 결과: [ProductTag]!


// 3. nullable: "itemsAndList"
@Field(() => [ProductTag], { nullable: "itemsAndList" }) // 결과: [ProductTag]

 

따라서, nullable: "itemsAndList"를 활용해 보시면 좋을 것 같아요!^^

 

그래프 ql 문서 사용할때 느낌표 남는거 어떻게 없애나요?

0

83

2

강의 전체 소스 코드를 받고싶습니다.

0

76

2

fontawesome 사용 문의

0

77

2

소스 코드 부탁드립니다~

0

85

2

깃 레포지터리 소스

0

82

2

커리큘럼12.css 정렬 에 나오는 과제 정답알고싶어요

0

73

2

10-01 Entity TypeOrmModule.forRoot 에 entities

0

85

3

강의 버전관련 문의입니다

0

102

2

Ubuntu 설치 관련

0

61

1

서버 재실행시 Many to Many

0

101

3

input 관련 문의

0

90

2

Rest API 보다는 graphql이 주된 내용인데

0

130

2

강의 전체 소스코드 받을수있을까요?

0

155

1

도커볼륨 마운트 관련

0

127

2

findOne 타입스크립트오류

0

109

1

http => htrtps 호출 인증서 신뢰 오류

0

350

1

self-signed certificate in certificate chain 에러 발생

0

413

1

mongoose 설치 오류

0

142

1

특정 API, 특정 IP 허용 (단일경로에 CORS 활성화)

0

281

2

08-06

0

178

3

구조랑 패턴 관련해서 질문

0

125

2

mydocker

0

128

2

coolsms statuscode 2000 인데 전송안돼는 경우 확인.

0

156

1

싸이월드 과제 쪽이 궁금합니다.

0

147

2