Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 2bb4427

Browse files
committed
Use apollo state in static props
1 parent f1d5298 commit 2bb4427

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

api/wordpress/_global/getPostTypeStaticProps.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import getPostTypeById from './getPostTypeById'
2+
import {addApolloState} from '../connector'
23

34
/**
45
* Retrieve static props by post type.
@@ -19,12 +20,13 @@ export default async function getPostTypeStaticProps(
1920
const slug = Array.isArray(params.slug) ? params.slug.join('/') : params.slug
2021

2122
// Retrieve post data.
22-
const post = await getPostTypeById(postType, slug)
23+
const {apolloClient, post} = await getPostTypeById(postType, slug)
2324

24-
return {
25+
// Merge in query results as Apollo state.
26+
return addApolloState(apolloClient, {
2527
props: {
2628
post
2729
},
2830
revalidate: 60 * 5
29-
}
31+
})
3032
}

0 commit comments

Comments
 (0)