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
* attempt at adding combine on observer level (doesn't work)
* feat(useQueries): combine
adapt getOptimisticResult to return both the result array and a combined result getter
* feat(useQueries): combine
make sure combinedResult stays in sync with result
* feat(vue-query): combine results for useQueries hook
* Add new options to svelte-query
* Add new options to solid-query
* fix: enable property tracking for useQueries
* fix: move property tracking to react layer
* chore: remove logging
* chore: remove unnecessary type assertion
* test: tests for combined data
* docs: combine
---------
Co-authored-by: Damian Osipiuk <[email protected]>
Co-authored-by: Lachlan Collins <[email protected]>
Co-authored-by: Aryan Deora <[email protected]>
The `useQueries` hook accepts an options object with a **queries** key whose value is an array with query option objects identical to the [`useQuery` hook](../reference/useQuery) (excluding the `context` option).
19
+
The `useQueries` hook accepts an options object with a **queries** key whose value is an array with query option objects identical to the [`useQuery` hook](../reference/useQuery) (excluding the `queryClient` option - because the `QueryClient` can be passed in on the top level).
20
20
21
21
-`queryClient?: QueryClient`,
22
-
- Use this to use a custom QueryClient. Otherwise, the one from the nearest context will be used.
22
+
- Use this to provide a custom QueryClient. Otherwise, the one from the nearest context will be used.
- Use this to combine the results of the queries into a single value.
23
25
24
-
> Having the same query key more than once in the array of query objects may cause some data to be shared between queries, e.g. when using `placeholderData` and `select`. To avoid this, consider de-duplicating the queries and map the results back to the desired structure.
26
+
> Having the same query key more than once in the array of query objects may cause some data to be shared between queries. To avoid this, consider de-duplicating the queries and map the results back to the desired structure.
27
+
28
+
**placeholderData**
29
+
30
+
The `placeholderData` option exists for `useQueries` as well, but it doesn't get information passed from previously rendered Queries like `useQuery` does, because the input to `useQueries` can be a different number of Queries on each render.
25
31
26
32
**Returns**
27
33
28
34
The `useQueries` hook returns an array with all the query results. The order returned is the same as the input order.
35
+
36
+
## Combine
37
+
38
+
If you want to combine `data` (or other Query information) from the results into a single value, you can use the `combine` option. The result will be structurally shared to be as referentially stable as possible.
In the above example, `combinedQueries` will be an object with a `data` and a `pending` property. Note that all other properties of the Query results will be lost.
0 commit comments