alphamikle / nest_transact

Simplest transactions support for Nestjs with Typeorm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot resolve ids of forwardRefs

sarathas opened this issue · comments

When a service has a forwardRef in its constructor, the id is undefined. Attempting to create a transactional service with a forwardRef results in an error when the id is scanned if it is a repository:

TypeError: Cannot read property 'includes' of undefined
    at SomeService.getArgument (/path/to/application/node_modules/nest-transact/lib/with-transaction.ts:47:32)
//... rest of the stack trace

Example for a service with forwardRefs:

@Injectable()
export class SomeService extends TransactionFor<SomeService> {
  constructor(
    @InjectRepository(SomeRepository)
    private readonly someRepository: SomeRepository,
    @Inject(forwardRef(() => SomeOtherClass))
    private someOtherClass: SomeOtherClass,
    moduleRef: ModuleRef,
  ) {
    super(moduleRef);
  }
}

The object in this case is a ForwardReference (provided by @nestjs/common), so one could get the forwardRef function of that object, execute it, and get the id by its name, for example.

Btw excluding the forwardRef does not work either as of right now, since the id is undefined.

Hello, @sarathas ! It needs to be investigated

@sarathas, Hi!
Please, check v.1.1.4, which has fixes for forwardRef from the community developer. I hope this version fix your problem. And... PRs are welcome!

@sarathas is v1.1.4 or the newest v1.1.5 fix this problem?

It does, thank you! I hope I will find time to file a PR myself, should there be any further problems.

No, it not working

@sarathas, @pvhuy84, hello!

Feel free to send PR with the fix of this issue, if it is annoying for you. Unfortunately for now I don't have much time to fix specific errors.