Prevent SSR crash from GraphQL errors again.

This commit is contained in:
Jayden Seric 2018-04-27 10:11:13 +10:00
parent 9390f514a8
commit 24305dc3e6

View File

@ -45,13 +45,17 @@ export default Composed =>
if (ctx.req) {
const apolloClient = createApolloClient()
await getDataFromTree(
<App
router={new Router(ctx.pathname, ctx.query, ctx.asPath)}
pageProps={{ apolloClient, pageProps: props }}
Component={this.renderPage}
/>
)
try {
await getDataFromTree(
<App
router={new Router(ctx.pathname, ctx.query, ctx.asPath)}
pageProps={{ apolloClient, pageProps: props }}
Component={this.renderPage}
/>
)
} catch (error) {
// Prevent crash from GraphQL errors.
}
props.cache = apolloClient.cache.extract()
}