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

Add onError option to useSubscription hook #9495

Conversation

jeroenvisser101
Copy link
Contributor

Feature

Adds onError option to the useSubscription 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:

@Avi-Cohen-Nehemia
Copy link

Just commenting to demonstrate my support and that I would love to see this feature added 🙏🏼

@jeroenvisser101
Copy link
Contributor Author

@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 main)

@jpvajda jpvajda added the 🏓 awaiting-contributor-response requires input from a contributor label May 3, 2022
@benjamn benjamn removed the 🏓 awaiting-contributor-response requires input from a contributor label May 5, 2022
Copy link
Member

@benjamn benjamn left a 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!

Comment on lines 213 to 215
onSubscriptionData?: (options: OnSubscriptionDataOptions<TData>) => any;
onError?: (error: ApolloError) => void;
onSubscriptionComplete?: () => void;
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hwillson @brainkim thoughts?

Copy link
Member

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.

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benjamn
Copy link
Member

benjamn commented May 5, 2022

I think I'm going to merge this into release-3.7 first, so we can put it out in a beta release. Since it is technically new functionality, v3.7 might be semantically the right version for this, but I'm open to slipping it into a v3.6.x patch release if there's value in that.

@benjamn benjamn added this to the Release 3.7 milestone May 5, 2022
@alessbell alessbell changed the base branch from main to release-3.7 September 21, 2022 16:22
@alessbell alessbell merged commit 1812a63 into apollographql:release-3.7 Sep 21, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants