HoudiniGraphql / houdini

The disappearing GraphQL framework
http://www.houdinigraphql.com
MIT License
913 stars 99 forks source link

Add Cache Reset for Specific List #1366

Closed banakh closed 1 month ago

banakh commented 1 month ago

Describe the feature

Description

Currently, Houdini provides the ability to reset the entire cache via cache.reset(). However, there is no functionality to clear the cache for a specific list. This can be useful in scenarios where only a certain list's cached data needs to be reset without affecting other parts of the application.

Current Behavior

At the moment, the only way to reset the cache is through:

import { cache } from '$houdini'
cache.reset()

This command resets the entire cache, affecting all cached queries and lists.

Feature Request

I would like to request the ability to reset the cache for a specific list, similarly to how we can interact with a list through cache.list(). This feature could be implemented as an extension of the list object, allowing developers to reset individual lists' caches without needing to clear the entire cache.

For example:

const list = cache.list('all_tickets', { allLists: true })
list.reset()

This functionality would allow developers to more selectively manage cached data, improving performance and avoiding unnecessary refetching of data unrelated to the list being reset.

Performance Optimization: In larger applications, resetting the entire cache can lead to performance issues, especially when unnecessary data refetching occurs. With list-specific cache clearing, developers can minimize such issues by only resetting what is needed.

Conclusion

Adding this feature will provide more flexibility in managing cached data and improve performance in use cases where only specific parts of the cache need to be reset. This would be a valuable addition for developers looking for fine-tuned cache management in Houdini.

Thank you for considering this feature request!

Criticality

cool improvement, my projects will benefit from it