Skip to content

Commit

Permalink
fix(gatsby-source-wordpress): Add steps for refetch_ALL (#33264)
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
  • Loading branch information
psharma-ii and TylerBarnes committed Oct 19, 2021
1 parent 4761dc3 commit 4d8e40b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Expand Up @@ -10,7 +10,7 @@ import { allowFileDownloaderProgressBarToClear } from "./create-nodes/create-rem
import { sourcePreviews } from "~/steps/preview"

const sourceNodes: Step = async helpers => {
const { cache, webhookBody } = helpers
const { cache, webhookBody, refetchAll } = helpers

// if this is a preview we want to process it and return early
if (webhookBody.preview) {
Expand Down Expand Up @@ -41,6 +41,7 @@ const sourceNodes: Step = async helpers => {
const fetchEverything =
foundUsableHardCachedData ||
!lastCompletedSourceTime ||
refetchAll ||
// don't refetch everything in development
(process.env.NODE_ENV !== `development` &&
// and the schema was changed
Expand Down
Expand Up @@ -6,6 +6,7 @@ import { paginatedWpNodeFetch } from "~/steps/source-nodes/fetch-nodes/fetch-nod

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

/**
* getWpActions
Expand Down Expand Up @@ -60,6 +61,9 @@ export const handleWpActions = async api => {
break
case `NON_NODE_ROOT_FIELDS`:
await fetchAndCreateNonNodeRootFields()
break
case `REFETCH_ALL`:
await sourceNodes({ ...helpers, refetchAll: true }, {})
}

await setHardCachedNodes({ helpers })
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-source-wordpress/src/utils/gatsby-types.ts
Expand Up @@ -9,6 +9,7 @@ export type GatsbyNodeApiHelpers = NodePluginArgs & {
context: any
updatedAt: number
}
refetchAll?: boolean
}
export type GatsbyHelpers = GatsbyNodeApiHelpers
export type GatsbyReporter = Reporter

0 comments on commit 4d8e40b

Please sign in to comment.