-
-
Couldn't load subscription status.
- Fork 591
Feat: add mutation options #2487
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
base: main
Are you sure you want to change the base?
Conversation
|
👷 Deploy request for openapi-ts pending review.Visit the deploys page to approve it
|
| // Helper type to infer TPageParam type | ||
| type InferPageParamType<T> = T extends { initialPageParam: infer P } ? P : unknown; | ||
|
|
||
| export type InfiniteQueryOptionsFunction< |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to include this type? I think it'd be good to also include the infiniteQueryOptions() helper for completeness as well as mutationOptions() but probably outside the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jamesmoss
Yes, that’s correct. In my previous PR I added it together with the infiniteQueryOptions changes to strengthen the typing for infinite queries, so it seems to have been carried over. That was my mistake. I’ll remove this part and update the source. Thanks for the feedback.
- Remove InfiniteQueryOptionsFunction type (not used) - Fix mutation onSuccess test to match React Query callback signature
…callback signatures React Query's onSuccess callback signature varies between versions. Instead of asserting exact call arguments, now verify only the first two arguments (data and variables) using mock.calls to be version-agnostic.
3b8a0c9 to
f2ca453
Compare
Changes
$api.mutationOptionshelper toopenapi-react-query, mirroring the existing query helpers so consumers can generate fully typed React Query mutation configs without rewriting fetchers.docs/openapi-react-query/mutation-options.mdwith a worked example, API breakdown, and guidance on when to prefer it over$api.useMutation.How to Review
packages/openapi-react-query/src/index.tsto confirmmutationOptionsshares the same contract as$api.useMutation, especially around the inferred types and key generation.packages/openapi-react-query/test/to verify they cover both the happy path and type expectations for the new helper.pnpm docs:dev→/openapi-react-query/mutation-options) to ensure the example builds, links resolve, and the narrative aligns with the query-side documentation.pnpm check(or the repo’s CI equivalent) before merging.Checklist
docs/updated (if necessary)pnpm run update:examplesrun (only applicable for openapi-typescript)