Skip to content

Accessing cached data outside hooks. #253

@omerman

Description

@omerman

I think its crucial to access cached data, at least while mutating.

lets say I have 2 endpoints - api/users & api/user/<id>

say i update api/user/<id>, i do not want to invalidate api/users, I would just like to mutate it, something like this - mutate('api/users', [...usersWithoutModifiedUser, modifiedUser])

the problem is.. I can't get the cached value for api/users at the time of the mutation.. since I only have the single user data I'm modifying.

I was thinking mutation api should look something like this

mutate('api/users', (cachedData) => {
  ... // using the cached data to build the new cached data.
   return [...usersWithoutModifiedUser, modifiedUser];
})

Hope you understand my issue, looking forward hearing from you,
Thank you for the great lib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions