You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using withApollo on individual pages, the query object is undefined twice, before it is defined. This means that if you need to query based on props.query, it will only run the query on the client-side.
I'm having exactly same issue, props.query is undefined on the first two renders, making the served SSR content wrong.
Our client side is conditionally loading different components on query param, so nothing renders.
We ended up getting props.query once in getServerSideProps for that part of logic, and then again on client side with Router hooks... But I'm not really happy with this approach.
I couldn't manage to make the workaround @tomanagle suggested to work on our setup though.
When using
withApollo
on individual pages, the query object is undefined twice, before it is defined. This means that if you need to query based onprops.query
, it will only run the query on the client-side.For example: https://github.com/tomanagle/NextJS-NestJS-GraphQL-Starter/blob/master/client/pages/user/%5Bpermalink%5D.tsx#L13
I added a workaround to my project by adding
ctx
todefaultOptions
, then spreading that on the page object: https://github.com/tomanagle/NextJS-NestJS-GraphQL-Starter/blob/master/client/lib/withApollo.tsx#L29A cleaner solution would be for withApollo to return
ctx
to it is spread on to the page object with the apollo client.Please let me know if you'd like me to work on this solution, or if you have a better solution.
The text was updated successfully, but these errors were encountered: