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

React Query v4 plans? #9

Closed
oscar-nuanxed opened this issue Sep 9, 2022 · 8 comments · Fixed by #10
Closed

React Query v4 plans? #9

oscar-nuanxed opened this issue Sep 9, 2022 · 8 comments · Fixed by #10
Labels
good first issue Good for newcomers

Comments

@oscar-nuanxed
Copy link

Hi @rametta !

We just started to use rapini which seems to be a real nice fit in our stack. The installation/setup experience was pretty much plugnplay. Do you have any plans bumping up to react-query v4? Noticed some fork with that but have not investigated myself if there is more to it than these small changes: https://github.com/tawandachiteshe/rapini/commits/main

Or any other plans for the project would ofc also be interesting to hear.

Thanks for sharing your work!

Br,
Oscar

@rametta
Copy link
Owner

rametta commented Sep 9, 2022

Hello @oscar-nuanxed, yes there are plans to support react query v4. I would like to do it in a backwards compatible way. So I would like to add a new CLI flag, such as --react-query-v4 so users can decide if they want to use react query v3 or v4 in the generated code.

It shouldn't require too much work, just need to find time to get to it. I'm also accepting PR's if anyone wants to give it a shot, I'd be more than happy to review and provide feedback on the PR - which may be faster than waiting for me to do it in the next couple weeks.

@rametta rametta added the good first issue Good for newcomers label Sep 9, 2022
@oscar-nuanxed
Copy link
Author

Thanks for quick reply @rametta! A CLI flag sounds like a plan. Maybe make it more generic too, assuming there might come a v5 or a partly breaking 4.something? -rqv, --react-query-version 4

We might take a stab at it. Will def make a PR in that case

@yuleicul
Copy link
Contributor

Hi @rametta @oscar-nuanxed,
I'm trying to implement the feature. Firstly to find the differences between generated files respectively using React Query v3 and v4, I used React Query codemod to transform the v3 generated file to v4 version. The result is that there is only one difference:

- import { useQuery, useMutation, useQueryClient, type QueryClient, type UseMutationOptions, type UseQueryOptions, type MutationFunction, type UseMutationResult, type UseQueryResult } from "react-query";
  import { useQuery, useMutation, useQueryClient, type QueryClient, type UseMutationOptions, type UseQueryOptions, type MutationFunction, type UseMutationResult, type UseQueryResult } from "@tanstack/react-query";

So I'm thinking that if it's necessary to support react query v4. If it is, I'm thinking what the best way is.

@yuleicul
Copy link
Contributor

Hi @rametta ,
I'm also thinking that wouldn't it be cool if we can support different query libraries, such as SWR. I'm very interested to implement that part.

@rametta
Copy link
Owner

rametta commented Sep 14, 2022

Hey @yuleicul @oscar-nuanxed , I've added support for react query v4 in this pr #10 it should be deployed to npm very shortly and ready to use.

@yuleicul In regards to supporting SWR, is that something you need? I'm not opposed to the idea

@rametta
Copy link
Owner

rametta commented Sep 14, 2022

V4 support is now in [email protected] and can be used by adding the CLI flag called -rq-v4

@yuleicul
Copy link
Contributor

Hi @rametta, after checking out your code I learned a lot, and the idea to support SWR occurred. In my opinion, implementing the support to SWR can help me understand your code better. I think it's a good opportunity for me to learn more about TypeScript Compiler API. If you are not opposed to that, I'm going to do it in the next couple of weeks.

@oscar-nuanxed
Copy link
Author

Nice! thanks @rametta , switched to v4 and it looks to be working as expected 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants