DamianOsipiuk / vue-query

Hooks for fetching, caching and updating asynchronous data in Vue
https://vue-query.vercel.app/
MIT License
1.11k stars 48 forks source link

useQueries doesn't seem to unpack deep ref options #227

Closed Evertt closed 1 year ago

Evertt commented 2 years ago

I mean, I can do it myself, but I thought vue-query was made to do it for me. It works with the normal useQuery().

So I'm talking about the enabled option for example. Which can be a ref or a computed and then when you use it in useQuery() then it automatically unwraps the ref/computed. But when I use it in useQueries() I get an error from react-query that enabled is not a boolean and indeed, when I check, it is indeed still a computed.

Oh yeah I'm using version 1.25.2 btw.

DamianOsipiuk commented 2 years ago

Well, In v1 only useQuery/useInfiniteQuery unwrap refs automatically. In v2 all composables besides useQueries.

So it is something that needs to be added and possibly back ported to v1

Evertt commented 2 years ago

I think so, personally. Like it's just strange that useQuery() would cloneDeepUnref the options, but useQueries() wouldn't. And unfortunately you don't export cloneDeepUnref, so now I have to copy that function to my own src folder.

DamianOsipiuk commented 2 years ago

The idea is not to implement it on your side, but contribute to the repository and add a support for it for everyone to use 😉

DamianOsipiuk commented 2 years ago

@Evertt Try https://github.com/DamianOsipiuk/vue-query/releases/tag/v1.26.0

Evertt commented 2 years ago

I tried, and at first it seemed to work, but later it seemed like the attributes that I get back every query, like data, stopped being reactive. So I went back to 1.25 and my previous workaround. 😬

Edit

Wait, that's not precise enough. If I asked for the data attribute of one of those queries immediately on page load, then it would work. But I also have a popover element, which means that when I hover over an element, a new component appears, that uses the same list of useQueries() as the first component did. But it gets a different query (at a different index in the list) and then the data attribute of that query isn't reactive for some reason.

While it was reactive while I was using my workaround. 😅

DamianOsipiuk commented 2 years ago

Few question:

DamianOsipiuk commented 1 year ago

This should be fixed in @tanstack/vue-query