1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Add missing url prop (#4078)

This was causing react-apollo  to crash on any SSR page that needed the page's query to make the GraphQL queries. 

It's magically passed on the client, but we have to manually pass it to the composed component here
This commit is contained in:
Wes Bos 2018-03-29 12:01:12 -04:00 committed by Tim Neutkens
parent 2ba8ad9760
commit 3949c82bdf

View file

@ -32,9 +32,16 @@ export default ComposedComponent => {
// and extract the resulting data
const apollo = initApollo()
try {
// create the url prop which is passed to every page
const url = {
query: ctx.query,
asPath: ctx.asPath,
pathname: ctx.pathname,
};
// Run all GraphQL queries
await getDataFromTree(
<ComposedComponent ctx={ctx} {...composedInitialProps} />,
<ComposedComponent ctx={ctx} url={url} {...composedInitialProps} />,
{
router: {
asPath: ctx.asPath,