orval-labs / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
3.01k stars 329 forks source link

useInfiniteQuery hooks have a wrong return type #1565

Open DragosRomaniuc opened 2 months ago

DragosRomaniuc commented 2 months ago

What are the steps to reproduce this issue?

  1. Generate a react query infinite hook.

    Screenshot 2024-08-06 at 23 39 23
  2. Use the query:

    Screenshot 2024-08-06 at 23 39 49
  3. Observe that the return type is wrong as data.data instead of data.pages (it actually returns data.pages)

Screenshot 2024-08-06 at 23 40 18
  1. Use useInfiniteQuery directly from @tanstack/react-query

    Screenshot 2024-08-06 at 23 41 28
  2. Observe that the data sits inside data.pages

    Screenshot 2024-08-06 at 23 41 53

What happens?

The infinite query return type is wrong data.data when it should be data.pages.

What were you expecting to happen?

Have the correct type data.pages

Any logs, error output, etc?

useGetPaginatedEventsForUsersInfinite<PageDto & GetPaginatedEventsForUsers200AllOf, ErrorType<unknown>>(params?: GetPaginatedEventsForUsersParams, options?: {
    ...;
}): UseInfiniteQueryResult<PageDto & GetPaginatedEventsForUsers200AllOf, ErrorType<...>> & {
    queryKey: QueryKey;
}
import useGetPaginatedEventsForUsersInfinite

Any other comments?

What versions are you using?

System: OS: macOS 14.5 CPU: (10) arm64 Apple M1 Max Memory: 2.63 GB / 32.00 GB Shell: 5.9 - /bin/zsh

npmPackages: orval: ^7.0.1 => 7.0.1 "@tanstack/react-query": "^5.51.11",

Please execute npx envinfo --system --npmPackages orval,zod,axios,msw,@tanstack/react-query and paste the results here.