I've searched for a lot of tutorials about local state management with Apollo Client.
To initialize the cache with some init values, from this example, I can do it with typePolicies
. By defining reactive variables like this:
const todosInitialValue = ...
export const todosVar: ReactiveVar<Todos> = makeVar<Todos>(
todosInitialValue
);
Also, I've seen tutorials initializing by cache.writeData({ data: initialState });
after the client is created.
I would love to know the difference, and which one is preferred.