What do you consider to be the best practice for using defineQueryOption?
#585
-
|
I’m planning to use However, I’ve run into an issue. To map data, I need to use composables such as Would the best approach be to call the composables in the place where they are used and pass the results into |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
What do you need to use from the other composables? Ideally, you define a parameter and call the composables in the components, per usual: export const profileQuery = defineQueryOptions((opts: { ... }) => ({
// ...
})
// inside of setup
const store = useMyStore()
useQuery(() => profileQuery({ a: store. a })) |
Beta Was this translation helpful? Give feedback.
I think that for globals like that, it's worth checking if they can be stored globally somewhere else.
The other solution is to call these composables within the function of defineQueryOptions, but then you are responsible for calling it only in composable places, it might be even be worth it to rename
getSomeQueryOptionstouseSomeQueryOptions