-
Notifications
You must be signed in to change notification settings - Fork 786
feat(@apollo/react-hooks): implement skip option for useSubscription hook #3356
feat(@apollo/react-hooks): implement skip option for useSubscription hook #3356
Conversation
Co-Authored-By: Ayc0 <[email protected]>
Hey @hwillson, the absence of the Of course, I can understand that you might be busy with different stuff, but I would be grateful if you got time to review and point this pull request in the right direction. 😊 |
Thanks for working on this @n1ru4l - I'll definitely get this reviewed today. |
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.
Thanks very much for working on this @n1ru4l 🙇. I think we're good to go here, so LGTM!
Thanks for this @n1ru4l, looking forward to having it released! As for my use case, I need this for SSR with Next.js -- currently there's no way via the So I'm going to be wrapping Apollo's |
@matthewhuang-camelot Could you please share your custom hook? Thanks |
@jurajkrivda I was thinking a simple wrapper like this:
However, since the
This works out in Next.js SSR for Apollo -- when the initial render is run, the hook returns a dummy result + never calls the Apollo useSubscription. There's actually no issue here with violating the no-conditional-hooks rule -- in the SSR runtime, |
@matthewhuang97 what kind of apollo link are you using on the server side? |
This is a possible implementation for apollographql/apollo-feature-requests#121
Would love some recommendations on how to write a test that verifies a subscription is canceled after the value of
skip
has changed.Checklist:
patch-package patch:
patches/@apollo+react-hooks+3.0.1.patch
patches/@apollo+react-common+3.0.1.patch