Replies: 1 comment
-
Rest seems fine but remove loading. Server rendered pages don't use loading. If you forcefully use loading from Apollo then it will lazy load the data instead of server rendering it, although the data would be in initial Apollo state but you won't see dom elements using Apollo data. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In the withApollo example, there is a need for a separate page that showcase how to use getServerSideProps , because just changing getStaticProps method in the current index.js to getServerSideProps does not work .The following changes are required to get it working with SSR-
1 update getStaticProps method in index.js like so..
(change method name and remove unstable_revalidate: 1)
export async function getServerSideProps(context) {
const apolloClient = initializeApollo()
await apolloClient.query({
query: ALL_POSTS_QUERY,
variables: allPostsQueryVars,
})
return {
props: {
initialApolloState: apolloClient.cache.extract(),
},
}
}
update if ( loading && !loadingMorePosts) return
if ( !data && (loading && !loadingMorePosts)) return
this is required for page to be server rendered
Am I doing something wrong ?
Iam happy to create a pull request with a new page, let me know
Beta Was this translation helpful? Give feedback.
All reactions