Hello, I was wondering about the usage of Fragments
in the UI. If you are trying to follow a more clean architecture approach, a Fragment
would be considered a DTO
and then should be mapped to a model
from the domain to presentation layer. While this would be clean, it also adds a lot of extra code for the mapping.
Are there any suggestions on whether or not to map a fragment to a model?
In general, Iād aim not to map your schema to your data model.
The graph/schema should āact as an abstraction layer that provides flexibility to consumers while hiding service implementation details.ā. Apollo directly recommends designing your schemas in a demand-oriented, abstract way.
Here is a great talk from Summit a few years ago that explores some schema design practices and pit falls to aligning a schema to the data model: https://www.youtube.com/watch?v=5EdJFTdk_Yo
1 Like