[Bug?]: Result type of combine works not as expected
Describe the bug
I have already posted a question to the discord: https://discord.com/channels/719702312431386674/1003327027849474198/1247640278987309058
Unfortunately no one answered in the thread and in the meanwhile I'm pretty sure that this is an incorrect result type.
Steps to reproduce
return createQueries(() => {
const list = ["test1", "test2"];
return ({
queries: list .map((key) => ({
queryKey: ["key", key],
queryFn: () => true,
})),
combine: (results) => ({
data: results.every(result => result.data)
})
});
});
Expected behavior
As already said in the discord thread. I expect to just return a combined data and all other fields like isPending, isError and so on should be automatically handled by tanstack query. And if this is not possible, because I think in react it doesn't do that, it should be possible to freely define this result, because when we look at the react documentation (https://tanstack.com/query/latest/docs/framework/react/reference/useQueries#combine) clearly only uses data and pending
How often does this bug happen?
Every time
Screenshots or Videos
Platform
OS: Windows Browser: Chrome Node: v21.7.3
Tanstack Query adapter
solid-query
TanStack Query version
5.40.0
TypeScript version
No response
Additional context
No response
can you please show a typescript playground? thanks
closing until we get a typescript playground reproduction
Sorry I must have overseen the comment. If you really need a playground I can provide one.
Your wish shall be granted: https://codesandbox.io/p/github/BierDav/temp-tanstack-query-ssr-bug/combine-not-working
What I want to add additionally is that there is also a bug in executing this code too as you can see on the right hand side of my screenshot:
➜ Network: use --host to expose
TypeError: state.map is not a function
at file:///project/workspace/node_modules/@tanstack/solid-query/build/dev.js:450:19
at file:///project/workspace/node_modules/solid-js/dist/server.js:123:12
at createMemo (file:///project/workspace/node_modules/solid-js/dist/server.js:95:9)
at Module.createQueries (file:///project/workspace/node_modules/@tanstack/solid-query/build/dev.js:447:25)
at __vite_ssr_exports__.default (/project/workspace/src/routes/index.tsx?pick=default&pick=$css:15:41)
at Module.createComponent (file:///project/workspace/node_modules/solid-js/dist/server.js:353:15)
at Promise.Comp [as resolved] (/project/workspace/node_modules/@solidjs/start/dist/router/lazyRoute.js:35:107)
at wrap (file:///project/workspace/node_modules/solid-js/dist/server.js:591:30)
at Module.createComponent (file:///project/workspace/node_modules/solid-js/dist/server.js:353:15)
at Object.outlet (/project/workspace/node_modules/@solidjs/router/dist/routing.js:450:53)
at get children [as children] (/project/workspace/node_modules/@solidjs/router/dist/routers/components.jsx:138:23)
at file:///project/workspace/node_modules/solid-js/dist/server.js:216:35
at file:///project/workspace/node_modules/solid-js/dist/server.js:179:49
at createMemo (file:///project/workspace/node_modules/solid-js/dist/server.js:95:9)
at children (file:///project/workspace/node_modules/solid-js/dist/server.js:179:16)
at file:///project/workspace/node_modules/solid-js/dist/server.js:216:14
at createMemo (file:///project/workspace/node_modules/solid-js/dist/server.js:95:9)
at provider (file:///project/workspace/node_modules/solid-js/dist/server.js:211:12)
at Module.createComponent (file:///project/workspace/node_modules/solid-js/dist/server.js:353:15)
at children (/project/workspace/node_modules/@solidjs/router/dist/routers/components.jsx:135:49)
at Show (file:///project/workspace/node_modules/solid-js/dist/server.js:421:9)
at Module.createComponent (file:///project/workspace/node_modules/solid-js/dist/server.js:353:15)
Please reopen this issue, if this would work it would really be an outstanding feature
sorry, is this now a runtime issue (state.map is not a function) or a type level issue as you initially claimed with the screenshot showing "argument of type ... is not assignable to parameter of type ..." ?
It is both, but i recommend to resolve the type issue first, maybe this resolves the other one too
here is a typescript playground with the error.
@lachlancollins can you take a look please? The same code works fine when using useQueries from @tanstack/react-query
here is a typescript playground with the error.
@lachlancollins can you take a look please? The same code works fine when using
useQueriesfrom@tanstack/react-query
Did you mean to ping @ardeora ?
yes, sorry 🙈
Just wondering if this issue with createQueries for SolidJS has been fixed yet?