-
Notifications
You must be signed in to change notification settings - Fork 235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/740 fix mappings from prisma models to domain objects #775
Feature/740 fix mappings from prisma models to domain objects #775
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this approach. It reflects the need for some amount of custom work to be done, which I think we should not shy away from at this point in the development process. Left a question.
import { BpiSubjectRole } from '../src/bri/identity/bpiSubjects/models/bpiSubjectRole'; | ||
import { IDomainObject } from '../src/shared/domainObject.interface'; | ||
|
||
// We do mapping from prisma models to domain objects using simple Object.assing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assing should be assign
import { BpiSubjectRole } from './bpiSubjectRole'; | ||
|
||
export class BpiSubject { | ||
export class BpiSubject implements IDomainObject { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it necessary to have the implemented interface IDomainObject and private activator. Just to ensure a common inherited value of id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interface is not needed at all. I was following an article and thought that it might be a good idea in order to make sure only domain objects are accepted for activation but on second thought i think it is over engineering. Removed.
The activator is necessary to avoid instantiation of each domain object ctor by providing empty params. I was hoping for a fully generic solution (one method for any mapping pair) but couldn't make it work so stopped here for now.
@ognjenkurtic please clear conflicts. |
…> do on bpi subjects example
…n in prisma mapper
c3e8ee2
to
e0c9037
Compare
@Kasshern done and addressed all other comments, please rereview |
@ognjenkurtic e2e test failing |
e2e step is failing because of this #769 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Gimme an approval please @Therecanbeonlyone1969 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach looks good to me.
Description
Implement an example of prisma model -> domain object mapping that does not rely on automapper as the automapper pojos strategy is bolierplate heavy and does not solve some edge cases.
New approach uses Object.assign and requires a single method per model - domain object pair.
If this approach looks good, i ll apply it across the codebase in a separate PR.
Related Issue
#740
Motivation and Context
Mapping was not done properly
How Has This Been Tested
Tested locally with postman, trying to fetch BpiSubject by id with associated roles and verified all mappings correctly performed.
Ran all unit tests
Screenshots (if appropriate)
Types of changes
Checklist