-
Notifications
You must be signed in to change notification settings - Fork 197
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
Error/redirection functionality for Smart Queries error hook #381
Comments
Also suffering from this problem - tried pretty much ever trick I can find on google to fix it. Only thing which works is not using smart queries and using asyncData with a catch/handler and redirect. My use case is when hitting a 3rd party GQL endpoint, this something goes does and then fails with a Atm when it happens makes the app fall over with a big bang, even with a custom error handler I cannot seem to stop it and doing a redirect also doesnt work, like the error to lower down the stack and non recoverable. To avoid this I have moved all the queries to using asyncData but its a massive refactoring effort. Would love to be able to properly handle these issues and still use a smart query. |
There are so many issues around Smart Queries and SSR error handling but no real solution that I can find 😔 . We have a huge Nuxt app that we've been building and so I am dreading having to refactor all our smart queries into asyncData ones. @jamesmorgan Did you end up refactoring or did you find a way to make Smart Queries work? If you did end up using async data it would be massively helpful if you could share an example. I'm not very familiar with using it. |
For those waiting for a fix: Probably not going to happen with nuxt2. I assume it's related to a similar issue about the fetch hook: nuxt/nuxt#7285 |
@toddpadwick Unfortunately we changes all our smart queries to inline queries which we can than handle better when things go wrong. A rough example is along the lines of this: this.$apollo.addSmartQuery('mySmartProp', {
client: this.client,
query: MY_QUERY,
error(error, vm, key, type, options) {
// Handle when things fail
}
}); It was a fairly painful experience refactoring this but once its done its okay from our experience. |
@jamesmorgan in what hook do you add the queries? Does it work fine with $apollo.queries.loading in the template? |
I have a similar question -- if an Apollo query returns 0 results from a page slug -- how do I redirect to an error page? Using Nuxt (latest) and Apollo. |
What problem does this feature solve?
Hook asyncDate({error}){...} has the option to handle errors with redirection to the error page that works fine in client-side and server-side.
For Appollo Smart Queries it seems like we have no options to do that on server side
We have this problem from 2017 (ex. #42) but it seems like we have no solution for smart query and have to use code like
but Smart Query is a much more elegant solution and gives many benefits.
What does the proposed changes look like?
The text was updated successfully, but these errors were encountered: