-
Notifications
You must be signed in to change notification settings - Fork 0
Learnings
Pamela Chong edited this page Jul 30, 2018
·
1 revision
-
Database structure & Linking tables
- We started this project by designing the database tables. We knew we wanted Users, Items, and Tags. However, we had to account for the connections that existed between these things. For example, there are many Tags and any Item can have any number of Tags. What database structure would best display data and reduce redundancies? Rather than repeating Tags on each Item it made more sense to use a 'Linking Table'. The Linking Table is used to describe the relationship between Tags and Items and queries can be made by joining the Items Table and Tags Table via a Linking Table.
-
You can't ask for it unless the schema says so
- Prior to GraphQL, developers relied largely on RESTful queries. This could result in overfetching of data or underfetching ( in which case, multiple queries would have to be made... eventually leading to overfetching). GraphQL is the query language we used and it creates one endpoint such that we can tailor a query to get exactly what we want. Except(!) that the appropriate schema must be written first. A schema is a contract between the server and the client, which defines types and fields - so for example, the schema says we may ask for a type User, who has fields: fullname, bio, and email. Without these fields, we would not be able to query for them.
-
"Smart" Components and "Dumb" Components
- With React, you don't want everything handling everything because it can make data flows difficult to manage. We limit the number of 'smart' components (those that handle logic, functions, and state) and allow these components to wrap the 'dumb' components (those that just hold things). For example, in this project we have the 'Item Container' which manages all of the item queries to the database. This Item Container then wraps the presentational(dumb) component and gives it data it can use in rendering the JSX.
-
Redux and the 'Store'
- Redux gives any component the ability to access a universal 'state'. This eliminates the difficult of trickling information from one parent component to a child (which may exist many nodes away). This also deals with the issue of handing information down to components that don't need it for the sake of getting the information to a child node. However, developers should be careful when considering if Redux is necessary. Not every project is made better with Redux. Writing all the necessary Actions and Reducers may be more trouble than it is worth.