posva / pinia-colada

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

fix(query): query refresh on defineQuery output composable call #40

Closed ElisePatrikainen closed 1 month ago

ElisePatrikainen commented 1 month ago

I noticed that queries defined with defineQuery are not refreshed when the composable returned by defineQuery is called (for example on component mount). Indeed, since, in the case of a defined query, the setup function is only called once (at initiation of the defined query), the queries called inside the setup function are not called again when this composable is reused.

Therefore, in this PR I am testing an idea to address this, which consists in registering (in the defineQueryMap) the queries which are called by the setup function in order to refresh them when the defineQuery output composable is called.

⚠️ Important note: since the queries are registered by registering the queries called while the setup function is running (cf https://github.com/posva/pinia-colada/pull/40/files#diff-ac8c2f7434eefb694c9ead0745e4cd8297e90afe0a9a4c5ba4a54586c7e8596cR195), the current implementation implies that the setup function must be synchronous.

netlify[bot] commented 1 month ago

Deploy Preview for funny-banoffee-0afb46 canceled.

Name Link
Latest commit 225a87db7429a35d0552eafc37d4080637726b4e
Latest deploy log https://app.netlify.com/sites/funny-banoffee-0afb46/deploys/6643346c1d125000080f7d14