Skip to content

how to persist and restore data with an array #16

@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions