Skip to content

Commit

Permalink
feat(gatsby): graphql engine (#33030)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
vladar authored Sep 6, 2021
1 parent 1bf112e commit 48cff06
Show file tree
Hide file tree
Showing 28 changed files with 857 additions and 61 deletions.
4 changes: 4 additions & 0 deletions packages/gatsby-plugin-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export interface IPluginRefObject {
resolve: string
options?: IPluginRefOptions
parentDir?: string

subPluginPaths?: Array<string>
module?: any
modulePath?: string
}

export type PluginRef = string | IPluginRefObject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ interface Context {

interface State {
key?: string
path?: string
path: Array<string | number>
parent?: any
reference?: any
ancestors?: any
Expand Down
31 changes: 31 additions & 0 deletions packages/gatsby/cache-dir/query-engine/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// IGatsbyPage, SystemPath and copied/inlined from redux/types so this file is self contained
type SystemPath = string
type Identifier = string

export interface IGatsbyPage {
internalComponentName: string
path: string
matchPath: undefined | string
component: SystemPath
componentChunkName: string
isCreatedByStatefulCreatePages: boolean
context: Record<string, unknown>
updatedAt: number
// eslint-disable-next-line @typescript-eslint/naming-convention
pluginCreator___NODE: Identifier
pluginCreatorId: Identifier
componentPath: SystemPath
ownerNodeId: Identifier
}

// also inlined
export interface IQueryResult {
errors?: Array<Error>
data?: any
}

export class GraphQLEngine {
constructor({ dbPath }: { dbPath: string })
runQuery(query: string, context: Record<string, any>): Promise<IQueryResult>
findPageByPath(pathName: string): IGatsbyPage | undefined
}
1 change: 1 addition & 0 deletions packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@types/http-proxy": "^1.17.4",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"@vercel/webpack-asset-relocator-loader": "^1.6.0",
"address": "1.1.2",
"anser": "^2.0.1",
"autoprefixer": "^10.2.4",
Expand Down
Loading

0 comments on commit 48cff06

Please sign in to comment.