Skip to content

Conversation

@jtomaszewski
Copy link
Contributor

@jtomaszewski jtomaszewski commented Jan 9, 2026

Summary

  • Add createMutationHook wrapping useSWRMutation for POST/PUT/PATCH/DELETE with full OpenAPI type inference
  • Rename createMutateHookcreateRevalidateHook to clarify its purpose (cache invalidation vs remote mutations)

Usage

const useMutation = createMutationHook(client, "prefix");

// In components:
const { trigger, isMutating } = useMutation("post", "/pet");
await trigger({ body: { name: "Fluffy", photoUrls: [] } });

// Also supports PUT, PATCH, DELETE:
useMutation("put", "/pet");
useMutation("delete", "/pet/{petId}");

Breaking Changes

  • createMutateHook renamed to createRevalidateHook
  • Requires major version bump

jtomaszewski and others added 4 commits January 9, 2026 11:24
…idateHook

- Add createMutationHook wrapping useSWRMutation for POST/PUT/PATCH/DELETE
- Rename createMutateHook to createRevalidateHook (BREAKING CHANGE)
- Add MutationMethod type for mutation-related operations
- Cache key format: [prefix, method, path]

BREAKING CHANGE: createMutateHook renamed to createRevalidateHook

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
API change:
- Before: createMutationHook(client, "post", prefix) → useMutation(path)
- After:  createMutationHook(client, prefix) → useMutation("post", path)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add use-mutation.md documentation
- Rename use-mutate.md to use-revalidate.md
- Update hook-builders.md with new exports
- Update sidebar config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@prescottprue
Copy link

Happy to see this - started adding it when this was part of openapi-typescript here: openapi-ts/openapi-typescript#2552 but this seems more fleshed out 👏

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.

2 participants