When utilizing Smart Query for redirection, how can we redirect to a 400 page?
While working with Vue Apollo, I attempted the following:
apollo: {
queryName: {
prefetch: true,
query: wrongQuery,
error(errorData) {
this.$nuxt.error({
statusCode: 500,
message: 'Error message',
});
},
},
};
Unfortunately, if the page is reloaded, the redirection does not function properly due to server-side rendering:
https://i.sstatic.net/H4zhU.png
Even when attempting a global error handler like the one below:
// /plugins/apollo-error-handler.js
export default ({ graphQLErrors, networkError, operation, forward }, nuxtContext) => {
console.log(networkError)
nuxtContext.error({
statusCode: 404,
message: 'Error message',
});
};
Only error logging seems to be functional, as redirection remains ineffective.
Is there any method to handle errors within smart queries and redirect to a 400 page, for example?
Can we implement error handling in smart queries similar to try...catch... in asyncData() to prevent application crashes?