From f64314d825a30492ad81ec38d91ce323536f6608 Mon Sep 17 00:00:00 2001 From: Tyler Barnes Date: Tue, 26 Jul 2022 14:49:43 -0700 Subject: [PATCH] refactor sourceNodes api and add I&C/CFLOW as a codeowner --- CODEOWNERS | 1 + .../src/utils/source-nodes-api-runner.ts | 25 +++++++++++++++++++ packages/gatsby/src/utils/source-nodes.ts | 7 +++--- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 CODEOWNERS create mode 100644 packages/gatsby/src/utils/source-nodes-api-runner.ts diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000000..35ca87584b213 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +packages/gatsby/src/utils/source-nodes-api-runner.ts @gatsbyjs/integrations-collaboration diff --git a/packages/gatsby/src/utils/source-nodes-api-runner.ts b/packages/gatsby/src/utils/source-nodes-api-runner.ts new file mode 100644 index 0000000000000..34dc44d336018 --- /dev/null +++ b/packages/gatsby/src/utils/source-nodes-api-runner.ts @@ -0,0 +1,25 @@ +import { Span } from "opentracing" +import apiRunner from "./api-runner-node" + +export function sourceNodesApiRunner({ + traceId, + deferNodeMutation, + parentSpan, + webhookBody, + pluginName, +}: { + traceId: string + webhookBody: unknown + pluginName?: string + parentSpan?: Span + deferNodeMutation?: boolean +}): Promise { + return apiRunner(`sourceNodes`, { + traceId, + waitForCascadingActions: true, + deferNodeMutation, + parentSpan, + webhookBody: webhookBody || {}, + pluginName, + }) +} diff --git a/packages/gatsby/src/utils/source-nodes.ts b/packages/gatsby/src/utils/source-nodes.ts index ebdbcaf6b51bb..a748cf3a268f3 100644 --- a/packages/gatsby/src/utils/source-nodes.ts +++ b/packages/gatsby/src/utils/source-nodes.ts @@ -1,6 +1,6 @@ import report from "gatsby-cli/lib/reporter" import { Span } from "opentracing" -import apiRunner from "./api-runner-node" +import { sourceNodesApiRunner } from "./source-nodes-api-runner" import { store } from "../redux" import { getDataStore, getNode } from "../datastore" import { actions } from "../redux/actions" @@ -106,12 +106,11 @@ export default async ({ const traceId = isInitialSourcing ? `initial-sourceNodes` : `sourceNodes #${sourcingCount}` - await apiRunner(`sourceNodes`, { + await sourceNodesApiRunner({ traceId, - waitForCascadingActions: true, deferNodeMutation, parentSpan, - webhookBody: webhookBody || {}, + webhookBody, pluginName, })