Skip to content

Conversation

@minchodang
Copy link

Changes

  • Added the $api.mutationOptions helper to openapi-react-query, mirroring the existing query helpers so consumers can generate fully typed React Query mutation configs without rewriting fetchers.
  • Extended the test and type surface to cover the new helper, ensuring mutation keys and inferred data/error types line up with the underlying OpenAPI schema.
  • Documented the helper in docs/openapi-react-query/mutation-options.md with a worked example, API breakdown, and guidance on when to prefer it over $api.useMutation.
  • Closes #2485.

How to Review

  • Review packages/openapi-react-query/src/index.ts to confirm mutationOptions shares the same contract as $api.useMutation, especially around the inferred types and key generation.
  • Check the accompanying tests under packages/openapi-react-query/test/ to verify they cover both the happy path and type expectations for the new helper.
  • Open the new doc page (pnpm docs:dev/openapi-react-query/mutation-options) to ensure the example builds, links resolve, and the narrative aligns with the query-side documentation.
  • Validate there are no regressions for existing helpers by running pnpm check (or the repo’s CI equivalent) before merging.

Checklist

  • Unit tests updated
  • docs/ updated (if necessary)
  • pnpm run update:examples run (only applicable for openapi-typescript)

@minchodang minchodang requested a review from a team as a code owner October 6, 2025 08:31
@changeset-bot
Copy link

changeset-bot bot commented Oct 6, 2025

⚠️ No Changeset found

Latest commit: f2ca453

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Oct 6, 2025

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit f2ca453

// Helper type to infer TPageParam type
type InferPageParamType<T> = T extends { initialPageParam: infer P } ? P : unknown;

export type InfiniteQueryOptionsFunction<

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.

Copy link
Author

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.
@minchodang minchodang force-pushed the feature/mutation-options branch from 3b8a0c9 to f2ca453 Compare October 27, 2025 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add mutationOptions (parity with TanStack Query)

2 participants