You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using tanstack query with a (far from perfect) vue-ified version of https://openapi-ts.dev/openapi-react-query/ which means I have a very generic query function and a small useQuery wrapper that provides some defaults and type safety for the query key. Basically I create basically the following signature useQuery(path: keyof paths, params: Params /* { path: {], serach: {}, etc based on openapi types } */, options: UseQueryOptions) => UseQueryReturn<ResponseBody<Path>>
I recently came across pinia colada that seems much more vue-native and could allow me to use things like pinia persist plugin etc to get a better devtools experience etc. However, While trying to recreate the same thing I came across some question marks.
The query function context doesn't seem to contain the query key like in tanstack query, making it harder to have a reuseable query function, is this something that could be considered as an extension to UseQueryFnContext?
When reading https://pinia-colada.esm.dev/advanced/reusable-queries.html I realised this is possibly the wrong way to go about it though? However I find it a bit difficult to figure out what the recommended way to achieve a way to useQuery generic views in a way where child components can call the function with the same arguments and return the same query, the option of returning a ref from a defineQuery will risk modifying global state for local needs (say one want to fetch the list of resources called "services" and one want to fetch the list of resources called "users". Would it be on me to maybe write a wrapper function that caches defineQuery results? Especially if I want to change the sub-component's query (key) without affecting a global-state parent?
Sorry, bit too loose and unstrucutred thought perhaps?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I've been using tanstack query with a (far from perfect) vue-ified version of https://openapi-ts.dev/openapi-react-query/ which means I have a very generic query function and a small useQuery wrapper that provides some defaults and type safety for the query key. Basically I create basically the following signature
useQuery(path: keyof paths, params: Params /* { path: {], serach: {}, etc based on openapi types } */, options: UseQueryOptions) => UseQueryReturn<ResponseBody<Path>>I recently came across pinia colada that seems much more vue-native and could allow me to use things like pinia persist plugin etc to get a better devtools experience etc. However, While trying to recreate the same thing I came across some question marks.
The query function context doesn't seem to contain the query key like in tanstack query, making it harder to have a reuseable query function, is this something that could be considered as an extension to
UseQueryFnContext?When reading https://pinia-colada.esm.dev/advanced/reusable-queries.html I realised this is possibly the wrong way to go about it though? However I find it a bit difficult to figure out what the recommended way to achieve a way to useQuery generic views in a way where child components can call the function with the same arguments and return the same query, the option of returning a ref from a defineQuery will risk modifying global state for local needs (say one want to fetch the list of resources called "services" and one want to fetch the list of resources called "users". Would it be on me to maybe write a wrapper function that caches defineQuery results? Especially if I want to change the sub-component's query (key) without affecting a global-state parent?
Sorry, bit too loose and unstrucutred thought perhaps?
Beta Was this translation helpful? Give feedback.
All reactions