-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
[legacy-framework] (major) Upgrade to React Query v3 #2101
Conversation
yay! If you get blocked on the TS issues, let me know and I can take a look |
@flybayer Awesome, I could use help mostly on the mutation hook implementation. The query hooks weren't too bad (just an overload error right now on In // These were imported with v2
// import {MutateOptions, MutationResult} from "react-query"
// Not sure if this the right type to use with v3
import {UseMutationOptions, UseMutationResult} from "react-query" Those are used further down in the file: // Old types with v2
// export declare type MutateFunction<
// TResult,
// TError = unknown,
// TVariables = unknown,
// TSnapshot = unknown
// > = (
// variables?: TVariables,
// config?: MutateOptions<TResult, TError, TVariables, TSnapshot>,
// ) => Promise<TResult>
// export declare type MutationResultPair<TResult, TError, TVariables, TSnapshot> = [
// MutateFunction<TResult, TError, TVariables, TSnapshot>,
// MutationResult<TResult, TError>,
// ]
// New types with v3
export declare type MutateFunction<
TResult,
TError = unknown,
TVariables = unknown,
TSnapshot = unknown
> = (
variables?: TVariables,
config?: UseMutationOptions<TResult, TError, TVariables, TSnapshot>,
) => Promise<TResult>
export declare type MutationResultPair<TResult, TError, TVariables, TSnapshot> = [
MutateFunction<TResult, TError, TVariables, TSnapshot>,
UseMutationResult<TResult, TError>,
] That's giving me an error in
Error happens on the return line for the export function useMutation<TResult, TError = unknown, TVariables = undefined, TSnapshot = unknown>(
mutationResolver: MutationFunction<TResult, TVariables>,
config?: MutationOptions<TResult, TError, TVariables, TSnapshot>,
) {
const enhancedResolverRpcClient = sanitize(mutationResolver)
return useReactQueryMutation(
(variables: TVariables) => enhancedResolverRpcClient(variables, {fromQueryHook: true}),
{
throwOnError: true,
...config,
} as any,
) as MutationResultPair<TResult, TError, TVariables, TSnapshot>
} Pretty lost though on where to go with this one. Any help would be great 😄 |
@tundera I will investigate as soon as I can, but probably not before Monday. |
I got hit with a bunch of urgent client work this week, so haven't been able to write any blitz code this week yet. This is still top priority as soon as I get freed up a bit. |
@tundera I fixed those typescript issues! Remaining items I'll leave for you:
|
@flybayer Awesome, I'm going to try to get those wrapped up this weekend |
@flybayer Hey I had some to time to work on these issues this weekend and here's what I was able to get done:
Still having trouble on some tests in the core package. Not sure if that's because the query client provider isn't set up correctly in the test utils file, but that's my hunch. The tests that seem to fail are in the |
@tundera got those issues fixed! Now last code issue is jest tests inside user's apps. Looks like we should export a And then the last thing is making a PR to the docs repo to update all our docs :) |
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.
Awesome, looking good! Thanks for sticking with me on this!
And looks like we have some failing tests |
Ok yeah let's keep It provides a better DX, plus it's less breaking changes for everyone. |
This reverts commit 3a7e134.
@flybayer Cool, I added it back in . Getting a failing windows test in CI but having a hard time understanding what's causing it |
Awesome, thank you so much!!! |
Added @tundera contributions for test |
Closes blitz-js/legacy-framework#518
What are the changes and their implications?
This is still a work in progress. Probably some details I'm glossing over, but I wanted to get the ball rolling on this one, hoping someone will have some input for some of the TypeScript errors coming into play. The bulk of changes are happening in
@blitzjs/core/src/use-query-hooks.ts
.A couple of the TypeScript errors getting in the way of progressing are mentioned below. Please take a look if you have time! Would love some help on this one. Thanks 😄
Issues:
useInfiniteQuery
(line 155,packages/core/src/use-query-hooks.ts
)useReactQueryMutation
inuseMutation
export (line 27,packages/core/src/use-mutation.ts