Apollo Client: best practice to initialize cache with default values?

434 Views Asked by At

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.

0

There are 0 best solutions below