Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug?]: Result type of combine works not as expected #7522

Open
BierDav opened this issue Jun 6, 2024 · 9 comments
Open

[Bug?]: Result type of combine works not as expected #7522

BierDav opened this issue Jun 6, 2024 · 9 comments

Comments

@BierDav
Copy link
Contributor

BierDav commented Jun 6, 2024

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

image

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

@TkDodo
Copy link
Collaborator

TkDodo commented Jun 7, 2024

can you please show a typescript playground? thanks

@TkDodo
Copy link
Collaborator

TkDodo commented Jul 17, 2024

closing until we get a typescript playground reproduction

@TkDodo TkDodo closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2024
@BierDav
Copy link
Contributor Author

BierDav commented Jul 17, 2024

Sorry I must have overseen the comment. If you really need a playground I can provide one.

@BierDav
Copy link
Contributor Author

BierDav commented Jul 17, 2024

Your wish shall be granted: https://codesandbox.io/p/github/BierDav/temp-tanstack-query-ssr-bug/combine-not-working
image
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

@TkDodo
Copy link
Collaborator

TkDodo commented Jul 26, 2024

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 ..." ?

@BierDav
Copy link
Contributor Author

BierDav commented Jul 26, 2024

It is both, but i recommend to resolve the type issue first, maybe this resolves the other one too

@TkDodo
Copy link
Collaborator

TkDodo commented Jul 26, 2024

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

@TkDodo TkDodo reopened this Jul 26, 2024
@TkDodo TkDodo removed the needs-info label Jul 26, 2024
@lachlancollins
Copy link
Member

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

Did you mean to ping @ardeora ?

@TkDodo
Copy link
Collaborator

TkDodo commented Jul 26, 2024

yes, sorry 🙈

@ardeora ardeora self-assigned this Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants