Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-source-wordpress): fix preview issues (#37492) #37495

Merged
merged 2 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions packages/gatsby-source-wordpress/src/steps/source-nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const fetchAndCreateSingleNode = async ({
singleName,
id,
actionType,
cachedNodeIds,
cachedNodeIds = [],
token = null,
isPreview = false,
isDraft = false,
Expand Down