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

feat(gatsby): add initial webhook body env var to bootstrap context #37478

Merged
merged 3 commits into from
Jan 19, 2023
Merged
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions packages/gatsby/src/services/initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { IBuildContext } from "./types"
import { loadConfig } from "../bootstrap/load-config"
import { loadPlugins } from "../bootstrap/load-plugins"
import type { InternalJob } from "../utils/jobs/types"
import type { IDataLayerContext } from "./../state-machines/data-layer/types"
import { enableNodeMutationsDetection } from "../utils/detect-node-mutations"
import { compileGatsbyFiles } from "../utils/parcel/compile-gatsby-files"
import { resolveModule } from "../utils/module-resolver"
Expand Down Expand Up @@ -71,12 +72,15 @@ process.on(`unhandledRejection`, (reason: unknown) => {
// Otherwise leave commented out.
// require(`../bootstrap/log-line-function`)

type WebhookBody = IDataLayerContext["webhookBody"]

export async function initialize({
program: args,
parentSpan,
}: IBuildContext): Promise<{
store: Store<IGatsbyState, AnyAction>
workerPool: WorkerPool.GatsbyWorkerPool
webhookBody?: WebhookBody
}> {
if (process.env.GATSBY_DISABLE_CACHE_PERSISTENCE) {
reporter.info(
Expand Down Expand Up @@ -651,8 +655,14 @@ export async function initialize({
}
}

const initialWebhookBody: WebhookBody = process.env
.GATSBY_INITIAL_WEBHOOK_BODY
? JSON.parse(process.env.GATSBY_INITIAL_WEBHOOK_BODY)
: undefined

return {
store,
workerPool,
webhookBody: initialWebhookBody,
}
}