diff --git a/packages/gatsby/src/redux/reducers/index.js b/packages/gatsby/src/redux/reducers/index.js index fe0607e1e1241..5a9c1b7a9224c 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 { webpackReducer } from "./webpack" @@ -59,7 +60,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..0c9d239746d7d --- /dev/null +++ b/packages/gatsby/src/redux/reducers/schema.ts @@ -0,0 +1,14 @@ +import { ActionsUnion, IGatsbyState } from "../types" +import { GraphQLSchema } from "graphql" + +export const schemaReducer = ( + state: IGatsbyState["schema"] = new GraphQLSchema({ query: null }), + 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 c47ce15fc5f20..2aa494a17ad10 100644 --- a/packages/gatsby/src/redux/types.ts +++ b/packages/gatsby/src/redux/types.ts @@ -240,6 +240,7 @@ export type ActionsUnion = | IReplaceWebpackConfigAction | ISetPluginStatusAction | ISetProgramStatusAction + | ISetSchemaAction | ISetWebpackCompilationHashAction | ISetWebpackConfigAction | IUpdatePluginsHashAction @@ -448,6 +449,11 @@ export interface ISetWebpackConfigAction { payload: Partial } +export interface ISetSchemaAction { + type: `SET_SCHEMA` + payload: IGatsbyState["schema"] +} + export interface ISetSiteConfig { type: `SET_SITE_CONFIG` payload: IGatsbyState["config"]