Skip to content

Commit 541f833

Browse files
committed
if there's a token we're previewing - also await non node root fields for previews
1 parent ac0e309 commit 541f833

File tree

1 file changed

+6
-11
lines changed
  • packages/gatsby-source-wordpress/src/steps/source-nodes

1 file changed

+6
-11
lines changed

packages/gatsby-source-wordpress/src/steps/source-nodes/index.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,19 @@ import { sourcePreviews } from "~/steps/preview"
1212
const sourceNodes: Step = async helpers => {
1313
const { cache, webhookBody, refetchAll } = helpers
1414

15+
// fetch non-node root fields such as settings.
16+
// For now, we're refetching them on every build
17+
const nonNodeRootFieldsPromise = fetchAndCreateNonNodeRootFields()
18+
1519
// if this is a preview we want to process it and return early
16-
if (webhookBody.preview) {
20+
if (webhookBody.token && webhookBody.userDatabaseId) {
1721
await sourcePreviews(helpers)
18-
22+
await nonNodeRootFieldsPromise
1923
return
2024
}
21-
// if it's not a preview but we have a token
22-
// we should source any pending previews then continue sourcing
23-
else if (webhookBody.token && webhookBody.userDatabaseId) {
24-
await sourcePreviews(helpers)
25-
}
2625

2726
const now = Date.now()
2827

29-
// fetch non-node root fields such as settings.
30-
// For now, we're refetching them on every build
31-
const nonNodeRootFieldsPromise = fetchAndCreateNonNodeRootFields()
32-
3328
const lastCompletedSourceTime =
3429
webhookBody.refreshing && webhookBody.since
3530
? webhookBody.since

0 commit comments

Comments
 (0)