인프런 커뮤니티 질문&답변

Cheng Wan님의 프로필 이미지

작성한 질문수

Slack 클론 코딩[백엔드 with NestJS + TypeORM]

e2e 테스트(강좌 마무리)

NestJs, Apollo Federation 관련 질문 입니다.

22.04.19 10:56 작성

·

282

0

nestjs를 리용하여 microservice를 만들고 있는데 gateway를 통하여 하위앱들에 접근하고 있습니다.

 

applications- app에서 정의한 스키마 schoolyear.entity.ts를 users-app, students-app등 다른 여러 app 들에서 사용하려고 합니다.

 

//application-app

@ObjectType()

@Directive(

  '@key(fields: "school_year_id, date_begin, date_end")',

)

@Entity({ name: 'mth_schoolyear' })

export class SchoolYear extends BaseEntity {

  @Column()

  @Field(() => ID, { nullable: true })

  @PrimaryGeneratedColumn()

  school_year_id?: number;

 

  @Column()

  @Field(() => Date, { nullable: true })

  date_begin: Date;

 

  @Column()

  @Field(() => Date, { nullable: true })

  date_end: Date;

}

 

//users-app

 

@ObjectType()

@Directive('@extends')

@Directive(

  '@key(fields: "school_year_id , date_begin, date_end")',

)

@Entity({ name: 'mth_schoolyear' })

export class SchoolYear extends BaseEntity {

  @Column()

  @Field(() => ID, { nullable: true })

  @PrimaryGeneratedColumn()

  @Directive('@external')

  school_year_id?: number;

 

  @Column()

  @Field(() => Date, { nullable: true })

  @Directive('@external')

  date_begin: Date;

 

  @Column()

  @Field(() => Date, { nullable: true })

  @Directive('@external')

  date_end: Date;

}

 

//students-app

@ObjectType()

@Directive('@extends')

@Directive(

  '@key(fields: "school_year_id , date_begin, date_end")',

)

@Entity({ name: 'mth_schoolyear' })

export class SchoolYear extends BaseEntity {

  @Column()

  @Field(() => ID, { nullable: true })

  @PrimaryGeneratedColumn()

  @Directive('@external')

  school_year_id?: number;

 

  @Column()

  @Field(() => Date, { nullable: true })

  @Directive('@external')

  date_begin: Date;

 

  @Column()

  @Field(() => Date, { nullable: true })

  @Directive('@external')

  date_end: Date;

}

 

1. @Directive(@key(fields)) 와 @Directive('@external') 사이에 어떤 관계가 있는지?

@Directive('@external')가 정의된 모든 field를  @Directive(@key(fields))에 정의해야 합니까?

2. Users-app에서 정의한 external field "date_begin", "date_end"가 stuents-app에도 중복존재하는데 오유가 아닙니까?

 

 

 

 

 

 

 

답변 1

0

제로초(조현영)님의 프로필 이미지
제로초(조현영)
지식공유자

2022. 04. 19. 11:47

제가 graphql을 안 해서 @Directive가 무슨 역할인지 잘 모르겠습니다.