Virtual Relation + Assembler doesn't work
mathieugeissler opened this issue · comments
Mathieu Geissler commented
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:
- Create two entity with dto
- Add virtual relation in first dto to second dto
- 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]