Skip to content

Commit 1810874

Browse files
authored
fix(gatsby-source-wordpress): draft previews (#32915)
* debug * fix draft previews * invoke leftover callbacks at the start of preview sourcing * use proper status
1 parent 7c72ab8 commit 1810874

File tree

2 files changed

+18
-9
lines changed
  • packages/gatsby-source-wordpress/src/steps

2 files changed

+18
-9
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { formatLogMessage } from "~/utils/format-log-message"
1919
import { touchValidNodes } from "../source-nodes/update-nodes/fetch-node-updates"
2020

2121
import { Reporter } from "gatsby/reporter"
22+
import { invokeAndCleanupLeftoverPreviewCallbacks } from "./cleanup"
2223

2324
const inDevelopPreview =
2425
process.env.NODE_ENV === `development` &&
@@ -367,14 +368,11 @@ export const sourcePreviews = async (helpers: GatsbyHelpers): Promise<void> => {
367368
dump(webhookBody)
368369
}
369370

370-
if (previewForIdIsAlreadyBeingProcessed(webhookBody?.id)) {
371-
if (inPreviewDebugMode) {
372-
reporter.info(
373-
`Preview for id ${webhookBody?.id} is already being sourced.`
374-
)
375-
}
376-
return
377-
}
371+
// in case there are preview callbacks from our last build
372+
await invokeAndCleanupLeftoverPreviewCallbacks({
373+
status: `GATSBY_PREVIEW_PROCESS_ERROR`,
374+
context: `Starting sourcePreviews`,
375+
})
378376

379377
const wpGatsbyPreviewNodeManifestsAreSupported =
380378
await remoteSchemaSupportsFieldNameOnTypeName({

packages/gatsby-source-wordpress/src/steps/source-nodes/update-nodes/wp-actions/update.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const fetchAndCreateSingleNode = async ({
2424
cachedNodeIds,
2525
token = null,
2626
isPreview = false,
27+
isDraft = false,
2728
userDatabaseId = null,
2829
}) => {
2930
function getNodeQuery() {
@@ -34,7 +35,7 @@ export const fetchAndCreateSingleNode = async ({
3435
// if it's a preview but it's the initial blank node
3536
// then use the regular node query as the preview query wont
3637
// return anything
37-
const query = isPreview ? previewQuery : nodeQuery
38+
const query = isPreview && !isDraft ? previewQuery : nodeQuery
3839

3940
return query
4041
}
@@ -81,6 +82,16 @@ export const fetchAndCreateSingleNode = async ({
8182
)
8283
)
8384

85+
reporter.info({
86+
singleName,
87+
id,
88+
actionType,
89+
cachedNodeIds,
90+
token,
91+
isPreview,
92+
userDatabaseId,
93+
})
94+
8495
return { node: null }
8596
}
8697

0 commit comments

Comments
 (0)