Closed ognjenkurtic closed 10 months ago
This branch has a POC of using the pojos strategy of automapper to achieve mapping from prisma model to a domain object, on the example of reading a bpi subject via an id:
Obviously some more polishing is needed but the overall approach works and can be utilized to solve the issue we currently have. Please have a look.
@biscuitdey @Kasshern @Therecanbeonlyone1969 @Ybittan
Overview
Currently automapping from Prisma models to domain objects is broken, as automapper complains about using type (Prisma model) when invoking the mapping so we use domain objects as source which causes various issues and worksarounds (look for TODOs with the id of this issue).
example of a wrong mapping:
return this.mapper.map(bpiAccountModel, BpiAccount, BpiAccount);
should be something like:
return this.mapper.map(bpiAccountModel, BpiAccountPrismaClientModel, BpiAccount);
Reference
https://github.com/nartc/mapper/discussions/280
Questions
Acceptance
mapping is performed by giving automapper either a prisma model (type) or a new object which represenets the model (class).
All mappings in the app are fixed according to the new approach
New approach is documented in the readme
All tests pass
Tasks
[x] Research and decide on the approach
[x] Implement POC
[x] Apply everyhwere
[x] Update readme