From ac0e309272690233e6561180a1e967647a03da5c Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Tue, 17 Jan 2023 15:43:47 -0800 Subject: [PATCH 1/2] add fallback array to prevent errors when cachedNodeIds aren't passed --- .../src/steps/source-nodes/update-nodes/wp-actions/update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js b/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js index 88a4318cafbcd..4f53436feb684 100644 --- a/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js +++ b/packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js @@ -24,7 +24,7 @@ export const fetchAndCreateSingleNode = async ({ singleName, id, actionType, - cachedNodeIds, + cachedNodeIds = [], token = null, isPreview = false, isDraft = false, From 541f833cb7434c23e10b9d1404fd057ad642b962 Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Tue, 17 Jan 2023 16:29:25 -0800 Subject: [PATCH 2/2] if there's a token we're previewing - also await non node root fields for previews --- .../src/steps/source-nodes/index.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/gatsby-source-wordpress/src/steps/source-nodes/index.ts b/packages/gatsby-source-wordpress/src/steps/source-nodes/index.ts index 2b33cd033fa44..bfa331f4ac110 100644 --- a/packages/gatsby-source-wordpress/src/steps/source-nodes/index.ts +++ b/packages/gatsby-source-wordpress/src/steps/source-nodes/index.ts @@ -12,24 +12,19 @@ import { sourcePreviews } from "~/steps/preview" const sourceNodes: Step = async helpers => { const { cache, webhookBody, refetchAll } = helpers + // fetch non-node root fields such as settings. + // For now, we're refetching them on every build + const nonNodeRootFieldsPromise = fetchAndCreateNonNodeRootFields() + // if this is a preview we want to process it and return early - if (webhookBody.preview) { + if (webhookBody.token && webhookBody.userDatabaseId) { await sourcePreviews(helpers) - + await nonNodeRootFieldsPromise return } - // if it's not a preview but we have a token - // we should source any pending previews then continue sourcing - else if (webhookBody.token && webhookBody.userDatabaseId) { - await sourcePreviews(helpers) - } const now = Date.now() - // fetch non-node root fields such as settings. - // For now, we're refetching them on every build - const nonNodeRootFieldsPromise = fetchAndCreateNonNodeRootFields() - const lastCompletedSourceTime = webhookBody.refreshing && webhookBody.since ? webhookBody.since