7nohe / openapi-react-query-codegen

OpenAPI React Query Codegen is a code generator for creating React Query (also known as TanStack Query) hooks based on your OpenAPI schema.
https://openapi-react-query-codegen.vercel.app
MIT License
298 stars 30 forks source link

Adding initialPageParam and nested nextPageParam support #143

Closed adamgoose closed 2 months ago

adamgoose commented 2 months ago

This adds a new argument --initialPageParam to customize the initialPageParam option passed to useInfiniteQuery. Defaults to 1.

Fixes #141.


When nextPageParam is set to meta.nextPage, split on . and generate the appropriately nested typehint:

  getNextPageParam: response => (response as {
    meta: {
      nextPage: number;
    };
  }).meta.nextPage

Fixes https://github.com/7nohe/openapi-react-query-codegen/issues/142.

adamgoose commented 2 months ago

I've combined my two PRs into this one to prevent having to rebase and re-generate the snapshots between merges. I've also added docs as requested. 👍

AnderssonPeter commented 1 week ago

@adamgoose @7nohe this caused a breaking change, if you dont provide the initialPageParam parameter it now defaults to "initialPageParam", before it defaulted to "1".. It would be nice if it still had 1 as default value.