TallerWebSolutions / apollo-cache-instorage

Apollo Cache implementation that facilitates locally storing resources
MIT License
96 stars 11 forks source link

how to persist and restore data with an array #16

Open omniteq opened 4 years ago

omniteq commented 4 years ago

I'm having a really hard time trying to understand how to restore data properly. I managed to restore simple data (when key is a string) by overwriting the initial state. So before client.writeData(myInitialState) I replace values with those from the localStorage. However, it doesn't work for arrays which are somehow modified when saving to the apollo cache. For example, an initial state like this:

{
agents: []
}

is transformed (normalized?) to this:

{
agents: {type: "json", json: []}
}

When I set an initial state with the above, transformed version, my mutation doesn't work.