Skip to content

Commit 48cff06

Browse files
authored
feat(gatsby): graphql engine (#33030)
* feat: graphql engine * lint * generate schema snapshot for v4 only * fix stack-trace utils * prevent schema snapshotting in workers * address engine PR review comments * revert require.resolve
1 parent 1bf112e commit 48cff06

File tree

28 files changed

+857
-61
lines changed

28 files changed

+857
-61
lines changed

packages/gatsby-plugin-utils/src/types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export interface IPluginRefObject {
5252
resolve: string
5353
options?: IPluginRefOptions
5454
parentDir?: string
55+
56+
subPluginPaths?: Array<string>
57+
module?: any
58+
modulePath?: string
5559
}
5660

5761
export type PluginRef = string | IPluginRefObject

packages/gatsby-plugin-utils/src/utils/plugin-options-schema-joi-type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1198,7 +1198,7 @@ interface Context {
11981198

11991199
interface State {
12001200
key?: string
1201-
path?: string
1201+
path: Array<string | number>
12021202
parent?: any
12031203
reference?: any
12041204
ancestors?: any
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// IGatsbyPage, SystemPath and copied/inlined from redux/types so this file is self contained
2+
type SystemPath = string
3+
type Identifier = string
4+
5+
export interface IGatsbyPage {
6+
internalComponentName: string
7+
path: string
8+
matchPath: undefined | string
9+
component: SystemPath
10+
componentChunkName: string
11+
isCreatedByStatefulCreatePages: boolean
12+
context: Record<string, unknown>
13+
updatedAt: number
14+
// eslint-disable-next-line @typescript-eslint/naming-convention
15+
pluginCreator___NODE: Identifier
16+
pluginCreatorId: Identifier
17+
componentPath: SystemPath
18+
ownerNodeId: Identifier
19+
}
20+
21+
// also inlined
22+
export interface IQueryResult {
23+
errors?: Array<Error>
24+
data?: any
25+
}
26+
27+
export class GraphQLEngine {
28+
constructor({ dbPath }: { dbPath: string })
29+
runQuery(query: string, context: Record<string, any>): Promise<IQueryResult>
30+
findPageByPath(pathName: string): IGatsbyPage | undefined
31+
}

packages/gatsby/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@types/http-proxy": "^1.17.4",
2525
"@typescript-eslint/eslint-plugin": "^4.29.3",
2626
"@typescript-eslint/parser": "^4.29.3",
27+
"@vercel/webpack-asset-relocator-loader": "^1.6.0",
2728
"address": "1.1.2",
2829
"anser": "^2.0.1",
2930
"autoprefixer": "^10.2.4",

0 commit comments

Comments
 (0)