posva / pinia-colada

🍹 The smart data fetching layer for Pinia
https://pinia-colada.esm.dev/
MIT License
761 stars 10 forks source link

[Mutations] Expose the possibility to invalidate a query without refetching it #53

Closed ElisePatrikainen closed 1 month ago

ElisePatrikainen commented 3 months ago

Currently, query invalidation is done through the keys mutation does not allow to choose if the query should be refetch immediately or not (and therefore refetches immediately). It would be nice to also expose this possibility, I see two use cases for that :

One option for allowing this could be to let passing a refetch option in the keys mutation option: for example keys: [{ key: [www, xxx], refetch: false }, [yyy, zzz] (with keeping the possibility to pass only the key, instead of the object, where then the refetch option would be set to true).

posva commented 3 months ago

I think it's better for this to just be automatic. The refresh of the data should only fetch if the query is active. If it's not being used, it will be invalidated but not fetched until it's needed somewhere

ElisePatrikainen commented 3 months ago

I hadn't thought about that, that's smart! Doing this first seems by far to be the best solution indeed - and we can still see later if people need to have more control on it (for example to save the refresh call after an optimistic update).