Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the type definitions for mutation hooks (useUpdate, useUpdateMany, useCreate, useDelete, useDeleteMany) by removing the Omit<UseMutationOptions, 'mutationFn'> wrapper, allowing mutationFn to be included in the options type.
Key changes:
- Type definitions now directly use
UseMutationOptionsinstead of omittingmutationFn - Applies consistently across all five mutation hooks
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ra-core/src/dataProvider/useUpdateMany.ts | Removed Omit<..., 'mutationFn'> wrapper from UseUpdateManyOptions type definition |
| packages/ra-core/src/dataProvider/useUpdate.ts | Removed Omit<..., 'mutationFn'> wrapper from UseUpdateOptions type definition |
| packages/ra-core/src/dataProvider/useDeleteMany.ts | Removed Omit<..., 'mutationFn'> wrapper from UseDeleteManyOptions type definition |
| packages/ra-core/src/dataProvider/useDelete.ts | Removed Omit<..., 'mutationFn'> wrapper from UseDeleteOptions type definition |
| packages/ra-core/src/dataProvider/useCreate.ts | Removed Omit<..., 'mutationFn'> wrapper from UseCreateOptions type definition |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
slax57
left a comment
There was a problem hiding this comment.
Actually Copilot is right! (for once...)
However attempting to fix the issue uncovered other TS issues that I was unable to solve so far.
We'll need more time to properly fix this PR.
Btw this PR should target master rather that next IMHO.
Problem
Our mutation hooks explicitly exclude the
mutationFnoption.However, we might want to override it to simplify hooks that reuse everything from a core mutation hook except the actual dataProvider call (ex:
useSoftDeletecould just pass a custom mutationFn touseDelete).Besides, the
mutationFnis optional in TanStack query so it won’t change anything for our users.Solution
Update the mutation hook to remove the explicit exclusion.
Additional Checks
mutationFnoverrides in the mutation hooks.