Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to persist and restore data with an array #16

Open
omniteq opened this issue Mar 26, 2020 · 0 comments
Open

how to persist and restore data with an array #16

omniteq opened this issue Mar 26, 2020 · 0 comments

Comments

@omniteq
Copy link

omniteq commented Mar 26, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant