Hey everyone,
we use following pattern in our app:
export default function ProductPage() {
const pageContext = usePageContext();
const { loading, error, data } = useGetProductByHandleQuery({
variables: { handle: pageContext.routeParams.handle },
});
if (loading) {
return <FullPageLoading />;
}
if (error) {
return <FullPageError message="500 Server Error" />;
}
if (data?.product) {
return <ProductPageTemplate product={data.product} />;
} else {
return <FullPageError message="404 Not Found" />;
}
}
It works just fine; however, we cannot figure out how to return the 500 / 404 errors, so our server can pick them up from the React DOM tree and respond with proper HTTP code.
How this is typically handled?