Open 7nohe opened 4 months ago
Great idea! I can help if you need to support this feature!
@MalguyMQ This feature has been implemented in #122 and pre-released. You can try it with the following command.
npx @7nohe/openapi-react-query-codegen@0.0.0-1712acfb083e0b1eec43cfc6f917f780ae5b5815 -i ./your-openapi-file.yaml
If you have any feedback or ideas for improvement, please leave a comment!
Is your feature request related to a problem? Please describe. Currently, this library does not support generating custom hooks for useInfiniteQuery. This limitation makes it difficult to handle APIs that require pagination or infinite scrolling, leading to additional manual coding and reduced efficiency.
Describe the solution you'd like I would like the library to support the generation of useInfiniteQuery custom hooks directly from OpenAPI schemas. This feature should automatically create hooks that handle pagination parameters and fetch data incrementally as needed, making it easier for developers to integrate infinite scrolling functionality into their applications. Specifically, the solution would involve adding CLI options
--next-page-param
and--page-param
to specify the relevant parameters. If the API has query parameters and responses that match these options, the library should automatically generate useInfiniteQuery custom hooks.Here is an example of a generated custom hook:
Additional context Here is the documentation for useInfiniteQuery for reference.