Closed oscar-nuanxed closed 2 years ago
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.
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
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.
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.
Hey @yuleicul @oscar-nuanxed , I've added support for react query v4 in this pr https://github.com/rametta/rapini/pull/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
V4 support is now in rapini@1.10.0 and can be used by adding the CLI flag called -rq-v4
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.
Nice! thanks @rametta , switched to v4 and it looks to be working as expected :+1:
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