Skip to content

Improve Tanstack Query Cache Management #195

@nkanchinadam

Description

@nkanchinadam

Description
Tanstack Query is a powerful library for managing data fetching, caching, and global state in an application, so we are using this library to manage our state. Currently, each of our queries simply fetches it state and returns it. However, this can lead to us unintentionally refetching the same data multiple times.

For instance, if we first fetched all albums and stored it under query key ['albums'] and then later on fetched a single album with id 1 under query key ['albums', 1], it would make another request despite the fact that album 1 is likely already in the cache.

Task
Go through all of our Tanstack Query hooks and if they are list queries, update them to manually populate the cache with individual items when they fetch data successfully.

Metadata

Metadata

Assignees

Labels

refactorStructural code improvement with no behavior change

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions