-
Still making my through “Intro to Apollo Client 3.0”
- Use the
fieldsproperty in the apollo cachetypePolicesto 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
idor u have specified it via thekeyFieldstype 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 specifyreadrules for a the query in theInMemoryCache. Make use of thetoReferencecallback function, which requires u to provide the__typeNameand the unique identifier configured for that resolver. see1h40. - delete specific parts of the cache with the
evit()method.
- Use the
-
Nullish coalescing operator
??is handy. It’s similar to tge logical OR operator||, but it also determines0or''(empty string) as falsey.