12. The read function field policy
1m

The read function

  • A field policy that customizes how a field is read from the cache.
  • Can transform cached data to suit our client's needs
  • Can return data for local-only fields

The read function syntax

cache: new InMemoryCache({
typePolicies: {
// 'Book' is the name of the type
Book: {
fields: {
// 'title' is the name of the field
title: {
read() {
// code goes here
}
}
}
}
}
});

The read function and the cache

How the read function works with the cache:

How the read function works with the cache

How the read function works with the cache and the @client directive:

How the read function works with the cache and the client directive
Previous
Next