diff --git a/packages/gatsby/cache-dir/query-result-store.js b/packages/gatsby/cache-dir/query-result-store.js
index 135157767a4a2..115be537f5adc 100644
--- a/packages/gatsby/cache-dir/query-result-store.js
+++ b/packages/gatsby/cache-dir/query-result-store.js
@@ -83,7 +83,7 @@ export class PageQueryStore extends React.Component {
return
}
- return
+ return
}
}
diff --git a/packages/gatsby/src/utils/page-data.ts b/packages/gatsby/src/utils/page-data.ts
index 1326108f67468..015c4ec3932bb 100644
--- a/packages/gatsby/src/utils/page-data.ts
+++ b/packages/gatsby/src/utils/page-data.ts
@@ -13,7 +13,7 @@ interface IPageData {
path: IGatsbyPage["path"]
}
-interface IPageDataWithQueryResult extends IPageData {
+export interface IPageDataWithQueryResult extends IPageData {
result: IExecutionResult
}
@@ -127,19 +127,15 @@ export async function flush(): Promise {
// them, a page might not exist anymore щ(゚Д゚щ)
// This is why we need this check
if (page) {
- const body = await writePageData(
+ const result = await writePageData(
path.join(program.directory, `public`),
page
)
if (program?._?.[0] === `develop`) {
websocketManager.emitPageData({
- ...body.result,
id: pagePath,
- result: {
- data: body.result.data,
- pageContext: body.result.pageContext,
- },
+ result,
})
}
}
diff --git a/packages/gatsby/src/utils/websocket-manager.ts b/packages/gatsby/src/utils/websocket-manager.ts
index a18e4b11a2fc7..4d81eb42d6e2d 100644
--- a/packages/gatsby/src/utils/websocket-manager.ts
+++ b/packages/gatsby/src/utils/websocket-manager.ts
@@ -4,7 +4,7 @@ import { store } from "../redux"
import { Server as HTTPSServer } from "https"
import { Server as HTTPServer } from "http"
import fs from "fs"
-import { readPageData } from "../utils/page-data"
+import { readPageData, IPageDataWithQueryResult } from "../utils/page-data"
import telemetry from "gatsby-telemetry"
import url from "url"
import { createHash } from "crypto"
@@ -13,7 +13,7 @@ import socketIO from "socket.io"
export interface IPageQueryResult {
id: string
- result: unknown // TODO: Improve this once we understand what the type is
+ result?: IPageDataWithQueryResult
}
export interface IStaticQueryResult {
@@ -35,10 +35,13 @@ const getCachedPageData = async (
const publicDir = path.join(program.directory, `public`)
if (pages.has(denormalizePagePath(pagePath)) || pages.has(pagePath)) {
try {
- const pageData = await readPageData(publicDir, pagePath)
+ const pageData: IPageDataWithQueryResult = await readPageData(
+ publicDir,
+ pagePath
+ )
return {
- result: pageData.result,
+ result: pageData,
id: pagePath,
}
} catch (err) {