Data comes in 2 forms a DTO and a model type

DTO vs Model

A DTO is a data structure required to hydrate a model. So a UserDTO is data required to create a User. The User is the model type.

DTO’s are shared between frontend and backend models, while the model type is not shared. The frontend & backend model type contains additional methods that are different.

Frontend

Cache First

The frontend layer uses mobx keystone, and we use a optimistic cache first approach. We update the cache, then we call a GraphQL endpoint. The UI is synced to the cache only, the GraphQL results don’t affect our UI.

Load

Takes external GraphQL data and hydrate the models. Usually put on an aggregate root.

Submit

This takes form data, does some mapping, then call Create and Save

writeCache

Exists on each model to update existing cache

Shared

Add

This takes in DTO data and create a model

Save

This does an upsert, update if exists or add if not exists.