File tree 8 files changed +25
-23
lines changed
8 files changed +25
-23
lines changed Original file line number Diff line number Diff line change @@ -4,12 +4,8 @@ import { build } from "../schema"
4
4
import reporter from "gatsby-cli/lib/reporter"
5
5
6
6
export async function buildSchema ( {
7
- store,
8
7
parentSpan,
9
8
} : Partial < IBuildContext > ) : Promise < void > {
10
- if ( ! store ) {
11
- reporter . panic ( `Cannot build schema before store initialization` )
12
- }
13
9
const activity = reporter . activityTimer ( `building schema` , {
14
10
parentSpan,
15
11
} )
Original file line number Diff line number Diff line change 1
1
import { calcInitialDirtyQueryIds , groupQueryIds } from "../query"
2
2
import { IBuildContext , IGroupedQueryIds } from "./"
3
- import reporter from "gatsby-cli/lib/reporter "
3
+ import { assertStore } from "../utils/assert-store "
4
4
5
5
export async function calculateDirtyQueries ( {
6
6
store,
7
7
} : Partial < IBuildContext > ) : Promise < {
8
8
queryIds : IGroupedQueryIds
9
9
} > {
10
- if ( ! store ) {
11
- reporter . panic ( `Cannot run service without a redux store` )
12
- }
10
+ assertStore ( store )
11
+
13
12
const state = store . getState ( )
14
13
// TODO: Check filesDirty from context
15
14
Original file line number Diff line number Diff line change @@ -2,15 +2,14 @@ import { IBuildContext } from "./"
2
2
3
3
import reporter from "gatsby-cli/lib/reporter"
4
4
import apiRunnerNode from "../utils/api-runner-node"
5
+ import { assertStore } from "../utils/assert-store"
5
6
6
7
export async function createPages ( {
7
8
parentSpan,
8
9
gatsbyNodeGraphQLFunction,
9
10
store,
10
11
} : Partial < IBuildContext > ) : Promise < void > {
11
- if ( ! store ) {
12
- reporter . panic ( `store not initialized` )
13
- }
12
+ assertStore ( store )
14
13
const activity = reporter . activityTimer ( `createPages` , {
15
14
parentSpan,
16
15
} )
Original file line number Diff line number Diff line change 1
1
import { processPageQueries } from "../query"
2
2
import { IBuildContext } from "./"
3
3
import reporter from "gatsby-cli/lib/reporter"
4
+ import { assertStore } from "../utils/assert-store"
4
5
5
6
export async function runPageQueries ( {
6
7
parentSpan,
@@ -9,9 +10,8 @@ export async function runPageQueries({
9
10
program,
10
11
graphqlRunner,
11
12
} : Partial < IBuildContext > ) : Promise < void > {
12
- if ( ! store ) {
13
- reporter . panic ( `Cannot run service without a redux store` )
14
- }
13
+ assertStore ( store )
14
+
15
15
if ( ! queryIds ) {
16
16
return
17
17
}
Original file line number Diff line number Diff line change 1
1
import { processStaticQueries } from "../query"
2
2
import { IBuildContext } from "./"
3
3
import reporter from "gatsby-cli/lib/reporter"
4
+ import { assertStore } from "../utils/assert-store"
4
5
5
6
export async function runStaticQueries ( {
6
7
parentSpan,
@@ -9,9 +10,8 @@ export async function runStaticQueries({
9
10
program,
10
11
graphqlRunner,
11
12
} : Partial < IBuildContext > ) : Promise < void > {
12
- if ( ! store ) {
13
- reporter . panic ( `Cannot run service without a redux store` )
14
- }
13
+ assertStore ( store )
14
+
15
15
if ( ! queryIds ) {
16
16
return
17
17
}
Original file line number Diff line number Diff line change 1
1
import { IBuildContext } from "./"
2
2
import sourceNodesAndRemoveStaleNodes from "../utils/source-nodes"
3
3
import reporter from "gatsby-cli/lib/reporter"
4
+ import { assertStore } from "../utils/assert-store"
4
5
// import { findChangedPages } from "../utils/check-for-changed-pages"
5
6
// import { IGatsbyPage } from "../redux/types"
6
7
@@ -9,9 +10,8 @@ export async function sourceNodes({
9
10
webhookBody,
10
11
store,
11
12
} : Partial < IBuildContext > ) : Promise < void > {
12
- if ( ! store ) {
13
- reporter . panic ( `No redux store` )
14
- }
13
+ assertStore ( store )
14
+
15
15
const activity = reporter . activityTimer ( `source and transform nodes` , {
16
16
parentSpan,
17
17
} )
Original file line number Diff line number Diff line change 1
1
import { IBuildContext } from "./"
2
2
import reporter from "gatsby-cli/lib/reporter"
3
3
import { writeAll } from "../bootstrap/requires-writer"
4
+ import { assertStore } from "../utils/assert-store"
4
5
5
6
export async function writeOutRequires ( {
6
7
store,
7
8
parentSpan,
8
9
} : Partial < IBuildContext > ) : Promise < void > {
9
- if ( ! store ) {
10
- reporter . panic ( `No redux store` )
11
- }
10
+ assertStore ( store )
11
+
12
12
// Write out files.
13
13
const activity = reporter . activityTimer ( `write out requires` , {
14
14
parentSpan,
Original file line number Diff line number Diff line change
1
+ import { Store } from "redux"
2
+ import reporter from "gatsby-cli/lib/reporter"
3
+
4
+ export function assertStore ( store ?: Store ) : asserts store {
5
+ if ( ! store ) {
6
+ reporter . panic ( `Could not find Redux store` )
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments