Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Virtual Relation + Assembler doesn't work #1532

Open
mathieugeissler opened this issue Apr 1, 2022 · 0 comments
Open

Virtual Relation + Assembler doesn't work #1532

mathieugeissler opened this issue Apr 1, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@mathieugeissler
Copy link

mathieugeissler commented Apr 1, 2022

Describe the bug
I have a virtual relation in my DTO

@ObjectType('Test')
@Relation('user', () => UserDto, {
  dtoName: 'UserDetails',
  relationName: 'user',
  nullable: true,
})
@QueryOptions({ defaultResultSize: 100 })
export class TestDto {
  @IDField(() => ID)
  id: string;
  @FilterableField({ nullable: true })
  status: number;
  @FilterableField(() => GraphQLJSONObject, { nullable: true })
  Details: TestDetailsDto;
}
@QueryService(TestEntity)
export class TestEntityRelationQueryService extends RelationQueryService<TestEntity> {
  constructor(
    @InjectQueryService(TestEntity)
    queryService: QueryService<TestEntity>,
    @InjectQueryService(UserEntity)
    usrQueryService: QueryService<UserEntity>,
  ) {
    super(queryService, {
      user: {
        service: usrQueryService,
        query(t) {
          return { filter: { id: { eq: t.Details.UserId } } };
        },
      },
    });
  }
}

It's working fine without assembler.
But when I add assembler :

@Module({
  imports: [
    TypeOrmModule.forFeature([TestEntity, UserEntity]),
    NestjsQueryGraphQLModule.forFeature({
      imports: [
        NestjsQueryTypeOrmModule.forFeature([
          TestEntity,
          UserEntity,
        ]),
      ],
      assemblers: [TestAssembler],
      services: [
        TestEntityRelationQueryService,
      ],
      resolvers: [
        {
          DTOClass: TestDto,
          ServiceClass: TestEntityRelationQueryService,
          AssemblerClass: TestAssembler,
        },
        {
          DTOClass: UserDto,
          EntityClass: UserDto
        },
      ],
    }),
  ],
})
export class EntitiesModule {}

The virtual relation is not found (TestEntityRelationQueryService is not used at all)

Have you read the Contributing Guidelines?

Yes

To Reproduce
Steps to reproduce the behavior:

  1. Create two entity with dto
  2. Add virtual relation in first dto to second dto
  3. Add assembler for first dto

Expected behavior
It should use custom RelationQueryService when Assembler is define

Desktop (please complete the following information):

  • Node Version [e.g. 16.13.2]
  • Nestjs-query Version [e.g. v0.30.0]
@mathieugeissler mathieugeissler added the bug Something isn't working label Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant