diff --git a/packages/gatsby/src/redux/reducers/index.js b/packages/gatsby/src/redux/reducers/index.js index 612df7a25eebb..426b53f021d22 100644 --- a/packages/gatsby/src/redux/reducers/index.js +++ b/packages/gatsby/src/redux/reducers/index.js @@ -1,6 +1,7 @@ const reduxNodes = require(`./nodes`) const lokiNodes = require(`../../db/loki/nodes`).reducer import { redirectsReducer } from "./redirects" +import { schemaReducer } from "./schema" import { staticQueryComponentsReducer } from "./static-query-components" import { statusReducer } from "./status" import { webpackCompilationHashReducer } from "./webpack-compilation-hash" @@ -55,7 +56,7 @@ module.exports = { flattenedPlugins: require(`./flattened-plugins`), config: require(`./config`), pages: require(`./pages`), - schema: require(`./schema`), + schema: schemaReducer, status: statusReducer, componentDataDependencies: require(`./component-data-dependencies`), components: require(`./components`), diff --git a/packages/gatsby/src/redux/reducers/schema.js b/packages/gatsby/src/redux/reducers/schema.js deleted file mode 100644 index 01fbacb86082e..0000000000000 --- a/packages/gatsby/src/redux/reducers/schema.js +++ /dev/null @@ -1,8 +0,0 @@ -module.exports = (state = {}, action) => { - switch (action.type) { - case `SET_SCHEMA`: - return action.payload - default: - return state - } -} diff --git a/packages/gatsby/src/redux/reducers/schema.ts b/packages/gatsby/src/redux/reducers/schema.ts new file mode 100644 index 0000000000000..1078072b56969 --- /dev/null +++ b/packages/gatsby/src/redux/reducers/schema.ts @@ -0,0 +1,13 @@ +import { ActionsUnion, IGatsbyState } from "../types" + +export const schemaReducer = ( + state: IGatsbyState["schema"] | {} = {}, + action: ActionsUnion +): IGatsbyState["schema"] | {} => { + switch (action.type) { + case `SET_SCHEMA`: + return action.payload + default: + return state + } +} diff --git a/packages/gatsby/src/redux/types.ts b/packages/gatsby/src/redux/types.ts index d6cce1796d385..0599580d1eec6 100644 --- a/packages/gatsby/src/redux/types.ts +++ b/packages/gatsby/src/redux/types.ts @@ -225,6 +225,7 @@ export type ActionsUnion = | IReplaceStaticQueryAction | ISetPluginStatusAction | ISetProgramStatusAction + | ISetSchemaAction | ISetWebpackCompilationHashAction | IUpdatePluginsHashAction @@ -399,3 +400,8 @@ export interface ISetPluginStatusAction { [key: string]: any } } + +export interface ISetSchemaAction { + type: `SET_SCHEMA` + payload: IGatsbyState["schema"] +}