-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add onError option to useSubscription hook #9495
Add onError option to useSubscription hook #9495
Conversation
Just commenting to demonstrate my support and that I would love to see this feature added 🙏🏼 |
71301fd
to
0084d9f
Compare
@trevorblades I'm sorry to ping you directly, but can you point me to the correct way (or person to reach out to) of getting this PR reviewed and merged? (I've just updated the branch so it's in-sync with |
0084d9f
to
ad85057
Compare
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.
LGTM with one question (below). Thanks for the implementation and especially the tests @jeroenvisser101!
onSubscriptionData?: (options: OnSubscriptionDataOptions<TData>) => any; | ||
onError?: (error: ApolloError) => void; | ||
onSubscriptionComplete?: () => void; |
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.
How would you feel about calling this onSubscriptionError
, for consistency with the other onSubscription*
options? I like onError
better too (for brevity), but to my eyes it looks a little out of place here.
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.
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.
I like onError
more as well, but we can't change the others in 3.7 so I'm 👍 with making it onSubscriptionError
.
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.
@benjamn confirmed we can release this change, but we want to consider a future improvement to change on
onSubscriptionData
and onSubscriptionComplete
to onData
and onComplete
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.
I think I'm going to merge this into |
Feature
Adds
onError
option to theuseSubscription
hook, similar to how it is offered on other hooks.I've added a simple test, but wasn't able to add an error-only result, I had to send
data
as well, I'm not sure why. If there's a better way to do that, I'd love to learn.Related issues and feature requests: