• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

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

22.04.19 10:56 작성 조회수 211

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

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