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

✨ Make it work with React Query v4 #60

Open
8 of 12 tasks
kaciakmaciak opened this issue Aug 21, 2022 · 8 comments
Open
8 of 12 tasks

✨ Make it work with React Query v4 #60

kaciakmaciak opened this issue Aug 21, 2022 · 8 comments
Projects

Comments

@kaciakmaciak
Copy link
Owner

kaciakmaciak commented Aug 21, 2022

Make react-query-subscription compatible with react-query@4.

Build

  • Support both React Query v3 and v4

Needs to be fixed

Need to be fixed for dev/tests

Consider for the future

@kaciakmaciak kaciakmaciak created this issue from a note in Version 1 (To do) Aug 21, 2022
@kaciakmaciak kaciakmaciak changed the title ✨ **Make it work with React Query v4** ✨ Make it work with React Query v4 Aug 21, 2022
@kaciakmaciak kaciakmaciak moved this from To do to In progress in Version 1 Sep 30, 2022
@mogobanyamwaro
Copy link

hello @kaciakmaciak is the issue solved?

@mogobanyamwaro
Copy link

i want to use the lib with react query v4?

@kaciakmaciak
Copy link
Owner Author

Hi, this is almost done, just a few tests are failing, but the examples look to work fine. So I need to figure out if the tests are failing because there is a regression or because of tests are written in a wrong way.

@kaciakmaciak
Copy link
Owner Author

The associated branch https://github.com/kaciakmaciak/react-query-subscription/tree/react-query-v4

I might release a beta version, to test in your project.

@kaciakmaciak
Copy link
Owner Author

The 2.0.0-beta.1 version is out with react query v4 as a peer dependency. Please give feedback and report if any issues. Cheers.

@kaciakmaciak
Copy link
Owner Author

Any feedback on beta version 👆 used with react query v4, please?

@Tbaut
Copy link

Tbaut commented Jan 26, 2023

I'm using it successfully with react-query v4, thanks a lot for having published the beta.

A couple comments regarding the documentation for the example using graphql-ws:

  • I'm not sure what QueryKey is used for. When using the example, I had the error:

Argument of type 'string' is not assignable to parameter of type 'QueryKey'.

Looking at the type I realized it's expecting an array. Using ["some-key"] silences the error, but I'd love to know more about this.

  • Also the fromWsClientSubscription expects a client as the firs argument.
fromWsClientSubscription<{ comments: Array<Comment> }>(
  client, // <-- this needs to be added
  {
    query:  ...

@vitoorgomes
Copy link

Hey there

I have a weird bug here, I've updated the package to the 2.0.0-beta.1 version but when I tried to navigate to a page that was using the useSubscription hook I got a weird error

SCR-20230220-jqd

I'm using NextJS 13 (without the app folder) and it's weird because I have the QueryClient at the entrypoint and everything else, but here comes the really weird part. I downloaded the .rar source code, copied:

subscription-storage.ts
use-observable-query-fn.ts
use-subscription.ts

and pasted on my project, after that I imported the useSubscription hook directly from the use-subscription.ts file and it worked, I got no errors.

Since my project is kinda big right now, I thought that I could have some weird config, so I created a fresh one and the problem and "solution" was the same. I will leave the minimal reproducible repo here and also a CodeSandbox, the dependencies version and everything else are the same as my original project (I can't share it).

I left some basic instructions at the readme, but if you clone and run the dev server you will get the no query client set error, but if you swap the import (pages/index.tsx) to the source file instead the installed package, you will be able to render without this problem

I'm not sure what is causing, but a wild guess would be that maybe it's something related to the bundle itself that it's missing something

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

No branches or pull requests

4 participants