Answer the question
In order to leave comments, you need to log in
What layer should mappers be in in clean architecture?
I only deal with dependency injection and clean architecture, so the question may be generally incorrect :)
There are 2 entities.
Let's call them Source
and Destination
.
Both are in the domain layer.
There is a need and the possibility of converting one entity to another without using any dependencies.
Therefore, the mapper, at the moment, is also in the domain layer.
But now, during the conversion, it was necessary not only to move the field values from Source
to Destination
, but also to write to one of the model fields a Destination
value that should be obtained from another model (let's sayThirdPartyEntity
), which is obtained from the repository, the implementation of which is in the infrastructure layer, and in the data layer there is only an interface (needed for use cases).
Does this mean that you need to move the mapper to the infrastructure layer, and create a mapper interface in the data layer and use it?
You can, of course, add ThirdPartyEntity
it as a parameter to the mapper, and get the model itself from the repository where the mapper is called, probably it will be more correct.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question