-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(react-query): add mutationOptions #8960
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?
feat(react-query): add mutationOptions #8960
Conversation
5e14207
to
596896d
Compare
View your CI Pipeline Execution ↗ for commit ff15e5d.
☁️ Nx Cloud last updated this comment at |
describe('mutationOptions', () => { | ||
it('should not allow excess properties', () => { | ||
return mutationOptions({ | ||
mutationFn: () => Promise.resolve(5), | ||
mutationKey: ['key'], | ||
// @ts-expect-error this is a good error, because onMutates does not exist! | ||
onMutates: 1000, | ||
}) | ||
}) | ||
|
||
it('should infer types for callbacks', () => { | ||
return mutationOptions({ | ||
mutationFn: () => Promise.resolve(5), | ||
mutationKey: ['key'], | ||
onSuccess: (data) => { | ||
expectTypeOf(data).toEqualTypeOf<number>() | ||
}, | ||
}) | ||
}) | ||
}) |
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.
In my opinion, Adding type testing about DataTag would be better. When adding DataTag for queryOptions there is lots of pull requests to fix its typescript error. so if we can guarantee mutationOption's type before releasing this new feature, mutationOptions, it would be better
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.
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.
Are there any updates?
mutationOptions helps extracting mutation options into separate functions.