Skip to content
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

[FEAT] React-Query v5 compatibility #5370

Open
bombillazo opened this issue Dec 13, 2023 · 24 comments
Open

[FEAT] React-Query v5 compatibility #5370

bombillazo opened this issue Dec 13, 2023 · 24 comments

Comments

@bombillazo
Copy link
Contributor

Is your feature request related to a problem? Please describe.

We've created a branch to migrate our application code to RQ v5, but have refrained since Refine uses RQ under the hood and want to avoid breaking any dependencies.

Describe alternatives you've considered

Keep using RQ v4 for the time being.

Additional context

https://tanstack.com/query/v5/docs/react/guides/migrating-to-v5

The migration process is relatively straightforward. They did remove the query callbacks, and the new paradigm for reacting to queries is doing so with useEffect hooks. One can still set global callbacks for queries, which refine uses for the notifications context, so the migration for Refine will likely center around that for their custom useQuery hooks.

They've also standardized the query function signatures only to accept objects. The typing should auto-alert the internal refine code.

Describe the thing to improve

Having the ability to use React Query v5 in our refine project.

@bombillazo bombillazo added the enhancement New feature or request label Dec 13, 2023
@BatuhanW
Copy link
Member

BatuhanW commented Dec 13, 2023

Thanks for the issue @bombillazo.

Migration looks straightforward, other than callbacks. @aliemir had the idea of providing these callbacks as a polyfill with the current v4 version of refine.

This means we could still accept queryOptions.onSuccess, onError, etc., and trigger them with useEffect inside our hooks.

@bombillazo
Copy link
Contributor Author

bombillazo commented Dec 13, 2023

Yeah! I think that would be the best approach for backward compatibility; in fact, I think (if I remember correctly from the RQ maintainers) that is what RQ is doing internally for those callbacks.

@BatuhanW BatuhanW added help wanted Extra attention is needed hacktoberfest labels Dec 14, 2023
@rilrom
Copy link
Contributor

rilrom commented Feb 6, 2024

Would migrating to v5 allow us to take advantage of the react query suspense features?

@zernie
Copy link

zernie commented Feb 7, 2024

yea suspense would be great

@bombillazo
Copy link
Contributor Author

any update on this?

@donalffons
Copy link

Just wanted to give my +1 for this request.

(I'm having a "brownfield" project, which is already using react-query@5 and I tried using refine there. It looks like the missing support for the new version of react-query sadly blocks me from adopting refine.)

Also: Huge "thank you" for this fantastic project 🙂!

@zernie
Copy link

zernie commented Mar 14, 2024

@BatuhanW could you please specify what needs to be done in preparation before migration to react-query v5?

@BatuhanW
Copy link
Member

Hey @zernie the main refactor should be replacing removed onXXX calbacks with useEffect for notifications in internal logic. Also, since these callbacks might be used by current Refine users, we also need to keep these types and trigger them with useEffect. Other thing is we need to check react-query's new types and make sure there is no breaking change with current Refine types.

We are open to contributions for this issue, if anyone wants to work on this.

@bombillazo
Copy link
Contributor Author

Was anyone able to look into this? The Refine source is pretty daunting and internally has lots of file/usage of RQ, perhaps identifying where the changes are required will motivate others to take the challenge?

@kziemski
Copy link

Curious if this is on roadmap and/or in need of contributors? Haven't seen any mention of it in awhile.

@BatuhanW
Copy link
Member

BatuhanW commented Jun 20, 2024

Hey @kziemski we are open to contributions for this one.

We've discussed with core team internally, there is no way to do this upgrade without a breaking change in refine v4. If we update react-query to v5, we'll have users both on react-query v4 and v5. We will not release a major Refine version atm, and we also have plans to make react-query (Store provider) agnostic on our next major release. But they aren't clear yet.

@BatuhanW BatuhanW added wontfix This will not be worked on to be continued and removed enhancement New feature or request help wanted Extra attention is needed hacktoberfest labels Jun 20, 2024
@stale stale bot removed wontfix This will not be worked on labels Jun 20, 2024
@kziemski
Copy link

@BatuhanW apologies wasn't expecting such a quick response(s). is agnostic the next major version release or is that not yet determined?

@zernie
Copy link

zernie commented Jun 20, 2024

@BatuhanW wait, does that mean it'd be possible to use RTK Query in the future?

@BatuhanW
Copy link
Member

We don't want to release this update as a basic version bump, but we want to deeply integrate new features such as suspense, server components into Refine. Things are moving fast nowadays on RSC side. We'll keep you posted in the future.

@kziemski
Copy link

And another library becomes infected with RSC. Really was hoping to keep this library as part of my stack. oh well good luck

@BatuhanW
Copy link
Member

And another library becomes infected with RSC. Really was hoping to keep this library as part of my stack. oh well good luck

We don't want to enforce anything on users. That's why we are not doing the upgrade at the moment. Even if we support some features, that wouldn't be required or would be opt-in. RSC is controversial topic right now, we'll wait for it to become more mature and see how community positions itself with it.

@kziemski
Copy link

I think you're right to hold back. React core's head space is clearly in supporting vercel/nextjs priorities.
Thankfully, this time they tripped over tanner's library. mess with the wrong library and you will incur the wrath of x.

I was just hoping to keep the libraries version in sync as react-query v5 is a dependency but i'll make do. ty for the response.

Copy link

stale bot commented Aug 20, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Aug 20, 2024
@stale stale bot closed this as completed Aug 27, 2024
@BatuhanW BatuhanW reopened this Aug 28, 2024
@stale stale bot removed the wontfix This will not be worked on label Aug 28, 2024
@datner
Copy link

datner commented Sep 4, 2024

Hey, this makes new projects that use pnpm start out broken because of how pnpm treats peers. I'm very interested in seeing this resolved, even if not properly solved, as the current situation is a proper blocker on the whole thing..
I am willing to help if it's a matter of effort, I have some familiarity with the project internals

@zernie
Copy link

zernie commented Sep 5, 2024

we also have plans to make react-query

that'd be perfect since we use redux. is there any way to contribute to this effort?

@zernie
Copy link

zernie commented Sep 30, 2024

Forgot to mention @BatuhanW

@BatuhanW
Copy link
Member

Hey @zernie sorry, your comment is overlooked among bloated GitHub notifications, my colleague @aliemir will provide some context and our plans on this issue.

@aliemir
Copy link
Member

aliemir commented Oct 23, 2024

Hey everyone 👋

I'd like to share some context on the delay in updating Refine to use TanStack React Query v5 and our plans moving forward.

The main reason for the delay is our focus on ensuring the new features in Refine v4 are stable and won't require breaking changes later on. Given that our last major release included updates across almost all providers, we wanted to be cautious and make sure everything is mature enough before introducing another major change.

We also wanted to make sure that we're in a stable environment for new features such as Server components etc. Our approach is to release the upcoming improvements in Refine gradually, allowing users to adapt their codebases smoothly. Once these changes are stable, we'll proceed with updating React Query to the latest version, which will be part of a major release from @refinedev/core.

The migration from React Query v4 to v5 is relatively straightforward for Refine; it mainly involves renaming a few props and updating internal query callbacks. However, for users who use @tanstack/react-query separately or rely heavily on deprecated options from queryOptions and mutationOptions, some manual adjustments will be needed. To make this transition as easy as possible, we'll roll out the upcoming Refine improvements first, so when the major release occurs, users will only need to focus on adjusting for the React Query changes in their Refine projects.

We'll keep this issue updated. You can expect to hear from us soon with a roadmap of the improvements, new features and eventually the major update.

@datner
Copy link

datner commented Oct 27, 2024

This means that Refine v4 would have a non-major breaking version update? Maybe refine should adopt the epoch approach as outlined by the semver spec creator and github cofounder here? It feels like the major increment is more of a hinderance than a blessing for refine with it's dual marketing/semantics purpose, and I can totally relate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants