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): Add steps for refetch_ALL #33264

Merged
merged 7 commits into from
Oct 19, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type GatsbyNodeApiHelpers = NodePluginArgs & {
context: any
updatedAt: number
}
refetchAll?: boolean
}
export type GatsbyHelpers = GatsbyNodeApiHelpers
export type GatsbyReporter = Reporter