@graphcommerce/graphql-mesh 9.0.4-canary.9 → 9.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -17
- package/api/createEnvelop.ts +5 -5
- package/index.ts +0 -3
- package/package.json +4 -4
- package/plugins/meshConfigFake.ts +1 -2
- package/tsconfig.json +1 -1
- package/Config.graphqls +0 -7
- package/api/globalThisMesh.ts +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## 9.0.4
|
|
3
|
+
## 9.0.4
|
|
4
4
|
|
|
5
|
-
## 9.0.
|
|
5
|
+
## 9.0.3
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- [#2480](https://github.com/graphcommerce-org/graphcommerce/pull/2480) [`4075474`](https://github.com/graphcommerce-org/graphcommerce/commit/40754746e3d3a05193525ebf94247ed85b6f111d) - GraphQL Mesh will now be in read-only mode by default, so only a single instance is created globally. This means it doesn't get recreated on each page compilation and fast refresh. Creating the instance is an expensive operation and can take multiple seconds and during development (and this can happen multiple times during a single change). Now only a single instance is created during development. To make sure changes are picked up during development set the config value `graphqlMeshEditMode: true` in your graphcommerce.config.js or set the env variable `GC_GRAPHQL_MESH_EDIT_MODE=1`. This is the same as the old behavior and this _will_ make the frontend considerably slower. ([@paales](https://github.com/paales))
|
|
10
|
-
|
|
11
|
-
## 9.0.4-canary.7
|
|
12
|
-
|
|
13
|
-
## 9.0.4-canary.6
|
|
14
|
-
|
|
15
|
-
## 9.0.4-canary.5
|
|
16
|
-
|
|
17
|
-
## 9.0.4-canary.4
|
|
7
|
+
## 9.0.3-canary.0
|
|
18
8
|
|
|
19
|
-
## 9.0.
|
|
9
|
+
## 9.0.2
|
|
20
10
|
|
|
21
|
-
## 9.0.
|
|
11
|
+
## 9.0.2-canary.0
|
|
22
12
|
|
|
23
|
-
## 9.0.
|
|
13
|
+
## 9.0.1
|
|
24
14
|
|
|
25
|
-
## 9.0.
|
|
15
|
+
## 9.0.1-canary.1
|
|
26
16
|
|
|
27
17
|
## 9.0.0
|
|
28
18
|
|
package/api/createEnvelop.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
|
2
|
-
import { createBuiltMeshHTTPHandler } from '
|
|
2
|
+
import { createBuiltMeshHTTPHandler } from '../.mesh'
|
|
3
|
+
|
|
4
|
+
const handler = createBuiltMeshHTTPHandler()
|
|
3
5
|
|
|
4
6
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
5
7
|
export const createServer = async (endpoint: string) => {
|
|
6
8
|
if (endpoint !== '/api/graphql')
|
|
7
9
|
throw Error('Moving the GraphQL Endpoint is not supported at the moment')
|
|
8
|
-
|
|
9
|
-
const handler = createBuiltMeshHTTPHandler()
|
|
10
|
-
return async (req: NextApiRequest, res: NextApiResponse) => {
|
|
10
|
+
return (req: NextApiRequest, res: NextApiResponse) => {
|
|
11
11
|
res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*')
|
|
12
12
|
const requestedHeaders = req.headers['access-control-request-headers']
|
|
13
13
|
if (requestedHeaders) {
|
|
@@ -20,6 +20,6 @@ export const createServer = async (endpoint: string) => {
|
|
|
20
20
|
return
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
handler(req, res)
|
|
24
24
|
}
|
|
25
25
|
}
|
package/index.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
/* eslint-disable import/export */
|
|
2
1
|
export * from './api/createEnvelop'
|
|
3
2
|
export * from './api/apolloLink'
|
|
4
3
|
export * from './.mesh'
|
|
5
|
-
// @ts-expect-error getBuiltMesh and createBuiltMeshHTTPHandler are re-exported here and override the export from .mesh
|
|
6
|
-
export * from './api/globalThisMesh'
|
|
7
4
|
export * from './utils/traverseSelectionSet'
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/graphql-mesh",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.0.4
|
|
5
|
+
"version": "9.0.4",
|
|
6
6
|
"main": "index.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@whatwg-node/fetch": "^0.10.1",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@apollo/client": "*",
|
|
17
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.4
|
|
18
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.4
|
|
19
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.4
|
|
17
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.4",
|
|
18
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.4",
|
|
19
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.4",
|
|
20
20
|
"@graphql-mesh/runtime": "*",
|
|
21
21
|
"@graphql-mesh/types": "*"
|
|
22
22
|
},
|
|
@@ -7,7 +7,6 @@ export const config: PluginConfig = {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* This plugin does not apply any changes to the Mesh configuration, but solely exists to generate
|
|
11
|
-
* the meshConfig.interceptor.ts file.
|
|
10
|
+
* This plugin does not apply any changes to the Mesh configuration, but solely exists to generate the meshConfig.interceptor.ts file.
|
|
12
11
|
*/
|
|
13
12
|
export const meshConfig: FunctionPlugin<MeshConfigFunction> = (prev, ...args) => prev(...args)
|
package/tsconfig.json
CHANGED
package/Config.graphqls
DELETED
package/api/globalThisMesh.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { MeshInstance } from '@graphql-mesh/runtime'
|
|
2
|
-
import type {
|
|
3
|
-
ServerAdapter,
|
|
4
|
-
ServerAdapterBaseObject,
|
|
5
|
-
ServerAdapterRequestHandler,
|
|
6
|
-
} from '@whatwg-node/server'
|
|
7
|
-
import { createBuiltMeshHTTPHandlerBase, getBuiltMeshBase } from '../.mesh'
|
|
8
|
-
|
|
9
|
-
type MeshHTTPHandler<TServerContext = Record<string, unknown>> = ServerAdapter<
|
|
10
|
-
TServerContext,
|
|
11
|
-
ServerAdapterBaseObject<TServerContext, ServerAdapterRequestHandler<TServerContext>>
|
|
12
|
-
>
|
|
13
|
-
|
|
14
|
-
declare global {
|
|
15
|
-
// eslint-disable-next-line vars-on-top, no-var
|
|
16
|
-
var buildMesh: Promise<MeshInstance> | undefined
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line vars-on-top, no-var
|
|
19
|
-
var builtMeshHandler: MeshHTTPHandler | undefined
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const shouldGlobalThisMeshBeCreated =
|
|
23
|
-
process.env.NODE_ENV === 'development' && import.meta.graphCommerce.graphqlMeshEditMode !== true
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* We are creating a global instance of the mesh so it doesn't get recreated on every change.
|
|
27
|
-
* Creating the instance is a very long operation and with sufficiently complex schema's it can take
|
|
28
|
-
* multiple seconds. During development it can happen multiple times during a single change.
|
|
29
|
-
*
|
|
30
|
-
* During development this creates a big advantage as we do not recreate the mesh on every reload.
|
|
31
|
-
* This makes development a lot faster.
|
|
32
|
-
*
|
|
33
|
-
* The disadvantage of this is that the mesh and any resolvers custom resolver will not be refreshed
|
|
34
|
-
* whenever code changes are made, to enable this set the config value `graphqlMeshEditMode: true`
|
|
35
|
-
* in your graphcommerce.config.js or set the env variable `GC_GRAPHQL_MESH_EDIT_MODE=1`.
|
|
36
|
-
*/
|
|
37
|
-
export function getBuiltMesh() {
|
|
38
|
-
if (shouldGlobalThisMeshBeCreated) {
|
|
39
|
-
globalThis.buildMesh ??= getBuiltMeshBase()
|
|
40
|
-
return globalThis.buildMesh
|
|
41
|
-
}
|
|
42
|
-
return getBuiltMeshBase()
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Same as globalThisGetBuiltMesh but for the mesh handler. As the handler uses additional logic so
|
|
47
|
-
* we can't re-use globalThisGetBuiltMesh.
|
|
48
|
-
*/
|
|
49
|
-
export function createBuiltMeshHTTPHandler(): MeshHTTPHandler {
|
|
50
|
-
if (shouldGlobalThisMeshBeCreated) {
|
|
51
|
-
globalThis.builtMeshHandler ??= createBuiltMeshHTTPHandlerBase() as MeshHTTPHandler
|
|
52
|
-
return globalThis.builtMeshHandler
|
|
53
|
-
}
|
|
54
|
-
return createBuiltMeshHTTPHandlerBase() as MeshHTTPHandler
|
|
55
|
-
}
|