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

How to catch error(s) of useSubscription? #8338

Closed
afsharm opened this issue Jun 1, 2021 · 1 comment
Closed

How to catch error(s) of useSubscription? #8338

afsharm opened this issue Jun 1, 2021 · 1 comment

Comments

@afsharm
Copy link

afsharm commented Jun 1, 2021

I am using Apollo-Client React to receive data from a GraphQL Subscription server (Implemented with NestJs/Apollo). In order to implement authorization, I throw error in the server side. Now, I need to catch the error in the front-end so I can notify the user. But I do not know how can I catch it.
My best solution is to use following:

const { data, loading, error } = useSubscription(..)

This way I get the error int the error property. But I need the event. I have use onError on many hooks and objects. In the useSubscription, in the WebSocketLink and in the ‍‍‍‍ApolloClient, but none has worked.

Please guide me how can I catch the error event. Or give me any relevant documentation.

@bignimbus
Copy link
Contributor

This seems to have been fixed in #9495 - @afsharm let us know if you're still experiencing this issue with the latest release and we'll re-open. Thanks so much for opening this issue!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants