typestack / typeorm-typedi-extensions

Dependency injection and service container integration with TypeORM using TypeDI library.
MIT License
262 stars 37 forks source link

question: how to inject repository with ciruclar services? #34

Closed jagabs closed 3 years ago

jagabs commented 5 years ago

Service A injects to Service B and Service B injects to Service A.

@Service()
@Resolver()
@EntityRepository(ProjectEntity)
export class ProjectService extends DatabaseService<ProjectEntity> {
    @InjectRepository("custom-pTransaction-service")
    private readonly pTransactionService: ProjectTransactionService;
}

@Service()
@Resolver()
@EntityRepository(ProjectTransactionEntity)
export class ProjectTransactionService extends DatabaseService<ProjectTransactionEntity> {

    @InjectRepository("custom-project-service")
    private projectService: ProjectService;
}
const project: any = await this.projectService.readOneProject(pTransactionInput.projectId);

Where readOneProject also uses "ProjectTransactionService`.

This doesn't work.

Versions:

NoNameProvided commented 3 years ago

Wrong repo, if you still face this issue, ask it on the TypeDI repo.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.