Skip to content

Commit 4d8e40b

Browse files
fix(gatsby-source-wordpress): Add steps for refetch_ALL (#33264)
Co-authored-by: Tyler Barnes <[email protected]>
1 parent 4761dc3 commit 4d8e40b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { allowFileDownloaderProgressBarToClear } from "./create-nodes/create-rem
1010
import { sourcePreviews } from "~/steps/preview"
1111

1212
const sourceNodes: Step = async helpers => {
13-
const { cache, webhookBody } = helpers
13+
const { cache, webhookBody, refetchAll } = helpers
1414

1515
// if this is a preview we want to process it and return early
1616
if (webhookBody.preview) {
@@ -41,6 +41,7 @@ const sourceNodes: Step = async helpers => {
4141
const fetchEverything =
4242
foundUsableHardCachedData ||
4343
!lastCompletedSourceTime ||
44+
refetchAll ||
4445
// don't refetch everything in development
4546
(process.env.NODE_ENV !== `development` &&
4647
// and the schema was changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { paginatedWpNodeFetch } from "~/steps/source-nodes/fetch-nodes/fetch-nod
66

77
import fetchAndCreateNonNodeRootFields from "~/steps/source-nodes/create-nodes/fetch-and-create-non-node-root-fields"
88
import { setHardCachedNodes } from "~/utils/cache"
9+
import { sourceNodes } from "~/steps/source-nodes"
910

1011
/**
1112
* getWpActions
@@ -60,6 +61,9 @@ export const handleWpActions = async api => {
6061
break
6162
case `NON_NODE_ROOT_FIELDS`:
6263
await fetchAndCreateNonNodeRootFields()
64+
break
65+
case `REFETCH_ALL`:
66+
await sourceNodes({ ...helpers, refetchAll: true }, {})
6367
}
6468

6569
await setHardCachedNodes({ helpers })

packages/gatsby-source-wordpress/src/utils/gatsby-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type GatsbyNodeApiHelpers = NodePluginArgs & {
99
context: any
1010
updatedAt: number
1111
}
12+
refetchAll?: boolean
1213
}
1314
export type GatsbyHelpers = GatsbyNodeApiHelpers
1415
export type GatsbyReporter = Reporter

0 commit comments

Comments
 (0)