-
Still making my through “Intro to Apollo Client 3.0”
- Use the
fields
property in the apollo cachetypePolices
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 thekeyFields
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 specifyread
rules for a the query in theInMemoryCache
. Make use of thetoReference
callback function, which requires u to provide the__typeName
and 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 determines0
or''
(empty string) as falsey.