RobinCK / typeorm-fixtures

:pill: Fixtures loader for typeorm 🇺🇦
https://robinck.github.io/typeorm-fixtures/
MIT License
566 stars 45 forks source link

[FEATURE REQUEST | WIP | FORK] Resolve promises for lazy loading relations #158

Closed nmacherey closed 3 years ago

nmacherey commented 3 years ago

Hi,

I've created a fork to work on the ability to resolve promises for lazy loaded relations in typeorm. The idea is to have the same principle as resolving references but adding a promise.resolve once it has been resolved.

https://github.com/getbigger-io/typeorm-fixtures/blob/master/src/parsers/PromiseReferenceParser.ts

I am facing issues in the Builder expecially regarding the usage of the class-transformer package. The current code is the following:

plainToClassFromExist(entity, data, { ignoreDecorators: true }) -> decorator are ignored and the class-transformer produces the following plaintToClass transformation:

MyEntity {
  id: 'c0ed46a6-7c84-4879-9bbb-4123897eb122',
  name: 'DEMO',
  __promise_property__: Promise { <pending> }
}

I fully understand why the option is there, but I cannot find any solution to get rid of this and get the resolved promise in the transformation output.

If you have any idea on how we can easilly solve this step and get the proper property names in the output it would be great ! Thanks

nmacherey commented 3 years ago

Solution proposed here:

https://github.com/RobinCK/typeorm-fixtures/pull/159

RobinCK commented 3 years ago

thanks published in 1.9.0 version