rsnext/examples/with-apollo/pages/index.js

37 lines
806 B
JavaScript
Raw Normal View History

import App from '../components/App'
import InfoBox from '../components/InfoBox'
import Header from '../components/Header'
import Submit from '../components/Submit'
import PostList, {
ALL_POSTS_QUERY,
allPostsQueryVars,
} from '../components/PostList'
import { initializeApollo } from '../lib/apolloClient'
const IndexPage = () => (
<App>
<Header />
<InfoBox> This page shows how to use SSG with Apollo.</InfoBox>
<Submit />
<PostList />
</App>
)
export async function getStaticProps() {
const apolloClient = initializeApollo()
await apolloClient.query({
query: ALL_POSTS_QUERY,
variables: allPostsQueryVars,
})
return {
props: {
initialApolloState: apolloClient.cache.extract(),
},
unstable_revalidate: 1,
}
}
export default IndexPage