Skip to content

Latest commit

History

History
11 lines (8 loc) 路 1.28 KB

2021-08-15.md

File metadata and controls

11 lines (8 loc) 路 1.28 KB
publish_date
2021-08-15
  • Still making my through "Intro to Apollo Client 3.0"

    • Use the fields property in the apollo cache typePolices to create computed fields which are dynamically created per API request. e.g you could combile a first and last name together like this.
    • When fetching multiples "things" via graphql, make sure everything is denormalised in the cache. to do this just ensure that there is a unique identifier via an id or u have specified it via the keyFields type policy. This important becasue, if you wanted to query just a singular of the "Things". Apollo would still make a network request, even though it already has the information in the cache. To let apollo know that the data may already be in the cache we have to specify read rules for a the query in the InMemoryCache. Make use of the toReference callback function, which requires u to provide the __typeName and the unique identifier configured for that resolver. see 1h40.
    • delete specific parts of the cache with the evit() method.
  • Nullish coalescing operator ?? is handy. It's similar to tge logical OR operator ||, but it also determines 0 or ''(empty string) as falsey.