diff --git a/packages/gatsby/src/schema/graphql-engine/webpack-remove-apis-loader.ts b/packages/gatsby/src/schema/graphql-engine/webpack-remove-apis-loader.ts index 638ece7fe78c3..148866cc0ad47 100644 --- a/packages/gatsby/src/schema/graphql-engine/webpack-remove-apis-loader.ts +++ b/packages/gatsby/src/schema/graphql-engine/webpack-remove-apis-loader.ts @@ -3,6 +3,9 @@ import { GatsbyNodeAPI } from "../../redux/types" import * as nodeApis from "../../utils/api-node-docs" import { schemaCustomizationAPIs } from "./print-plugins" +const apisToKeep = new Set(schemaCustomizationAPIs) +apisToKeep.add(`onPluginInit`) + module.exports = function loader(source: string): string | null | undefined { const result = transformSync(source, { babelrc: false, @@ -12,7 +15,7 @@ module.exports = function loader(source: string): string | null | undefined { require.resolve(`../../utils/babel/babel-plugin-remove-api`), { apis: (Object.keys(nodeApis) as Array).filter( - api => !schemaCustomizationAPIs.has(api) + api => !apisToKeep.has(api) ), }, ],