w3tecch / express-graphql-typescript-boilerplate

A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
MIT License
185 stars 73 forks source link

Advantages of abstraction used #5

Open ravishivt opened 7 years ago

ravishivt commented 7 years ago

As a new user to this project, the organization of this repo's logic is very convoluted and hard to get a full picture. The README with the code structure helps but isn't enough. It would be helpful to better explain the abstraction choices made to help people understand how it all works together. It would also help to include examples of how to leverage those abstractions since a lot of them appear to be set up but not used in the sample app. Here are a few examples of my uncertainties:

  1. What is the difference between models.book.Attributes and models.book.RawAttributes? My understanding is they are used for serializing data to be put into the database (raw) and for serializing data coming out of DB (regular)? This would allow you to exclude some data from client responses or include additional data to be put into the DB. Is that accurate? If so, maybe change the two interfaces so there are some differences between the two that would allow the user to infer the purpose.
  2. There are getters/setters in the model. The setters aren't standard TypeScript set functions though. Why not? Also, all of the getters/setters simply update or read data with no additional logic, i.e. with the samples provided, the user doesn't see any benefit.
  3. What advantages are there of abstracting Context into its own class?

If there are any articles that explain the advantages of the above abstractions or the choices made to get these abstractions, please share.