@graphcommerce/graphql-mesh 3.0.9 → 3.2.0
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 +39 -0
- package/{createHandler.ts → createServer.ts} +14 -33
- package/index.ts +1 -2
- package/package.json +13 -6
- package/createTabs.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,45 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.2.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql-mesh@3.1.0...@graphcommerce/graphql-mesh@3.2.0) (2021-10-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **graphql-mesh:** use a build mesh for production environments ([cd2f318](https://github.com/ho-nl/m2-pwa/commit/cd2f3189383fa9d304bd367334e3f47ca4aa6100))
|
|
12
|
+
* unable to find cache matching inmemoryLru ([520f6f3](https://github.com/ho-nl/m2-pwa/commit/520f6f329573471ecfdbdc4aa6f2e4b688b31f11))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **graphql-mesh:** remove the api project and use a single project 🎉👩👩👦👦 ([ea4ad03](https://github.com/ho-nl/m2-pwa/commit/ea4ad0397d4ff289ef3b3253593fb0914c8c5246))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# [3.1.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql-mesh@3.0.11...@graphcommerce/graphql-mesh@3.1.0) (2021-10-20)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* **graphql-mesh:** simplified the handler to use less code in the project ([f62b752](https://github.com/ho-nl/m2-pwa/commit/f62b75249492f40c5972deede529a25a17c8a617))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## [3.0.11](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql-mesh@3.0.10...@graphcommerce/graphql-mesh@3.0.11) (2021-10-20)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* **recaptcha:** allow and forward the the X-ReCaptcha to Magento ([2f3170e](https://github.com/ho-nl/m2-pwa/commit/2f3170e0f1652d84948b69a446634ffe02f08f80))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
6
45
|
## [3.0.9](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql-mesh@3.0.8...@graphcommerce/graphql-mesh@3.0.9) (2021-10-18)
|
|
7
46
|
|
|
8
47
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { processConfig } from '@graphql-mesh/config'
|
|
2
|
+
import { getMesh as getGraphQLMesh, MeshInstance } from '@graphql-mesh/runtime'
|
|
2
3
|
import { YamlConfig } from '@graphql-mesh/types'
|
|
3
4
|
import { ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core'
|
|
4
5
|
import { ApolloServer } from 'apollo-server-micro'
|
|
@@ -7,39 +8,17 @@ import '@graphql-mesh/graphql'
|
|
|
7
8
|
import '@graphql-mesh/merger-stitching'
|
|
8
9
|
import '@graphql-mesh/transform-cache'
|
|
9
10
|
import '@graphql-mesh/cache-inmemory-lru'
|
|
11
|
+
import '@vue/compiler-sfc'
|
|
10
12
|
import 'ts-tiny-invariant'
|
|
11
13
|
import 'micro'
|
|
12
14
|
import cors from 'micro-cors'
|
|
13
15
|
|
|
14
|
-
export function
|
|
15
|
-
|
|
16
|
-
let content = JSON.stringify(json)
|
|
17
|
-
|
|
18
|
-
if (typeof process === 'undefined' || 'env' in process === false) {
|
|
19
|
-
throw new Error('Process process.env not available')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
content = content.replace(/\$\{(.*?)\}/g, (_, variable) => {
|
|
23
|
-
let varName = variable
|
|
24
|
-
let defaultValue = ''
|
|
25
|
-
|
|
26
|
-
if (variable.includes(':')) {
|
|
27
|
-
const spl = variable.split(':')
|
|
28
|
-
varName = spl.shift()
|
|
29
|
-
defaultValue = spl.join(':')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!process.env[varName]) {
|
|
33
|
-
throw new Error(`Env variable ${varName} not defined`)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return process.env[varName] || defaultValue
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
return JSON.parse(content)
|
|
16
|
+
export async function getMesh(config: unknown): Promise<MeshInstance> {
|
|
17
|
+
return getGraphQLMesh(await processConfig(config as YamlConfig.Config, { dir: process.cwd() }))
|
|
40
18
|
}
|
|
41
19
|
|
|
42
|
-
export async function
|
|
20
|
+
export async function createServer(mesh: Promise<MeshInstance>, path: string) {
|
|
21
|
+
const meshInstance = await mesh
|
|
43
22
|
const apolloServer = new ApolloServer({
|
|
44
23
|
context: ({ req }) => req,
|
|
45
24
|
introspection: true,
|
|
@@ -53,6 +32,8 @@ export async function createHandler(meshInstance: MeshInstance, path: string) {
|
|
|
53
32
|
})
|
|
54
33
|
await apolloServer.start()
|
|
55
34
|
|
|
35
|
+
const apolloHandler = apolloServer.createHandler({ path })
|
|
36
|
+
|
|
56
37
|
const corsHandler = cors({
|
|
57
38
|
allowMethods: ['GET', 'POST', 'OPTIONS'],
|
|
58
39
|
allowHeaders: [
|
|
@@ -67,16 +48,16 @@ export async function createHandler(meshInstance: MeshInstance, path: string) {
|
|
|
67
48
|
'X-Api-Version',
|
|
68
49
|
'Access-Control-Allow-Origin',
|
|
69
50
|
'X-HTTP-Method-Override',
|
|
51
|
+
'x-apollo-tracing',
|
|
52
|
+
'apollographql-client-name',
|
|
53
|
+
|
|
54
|
+
// Magento 2 related headers
|
|
70
55
|
'Authorization',
|
|
71
56
|
'Store',
|
|
72
57
|
'Preview-Version',
|
|
73
58
|
'Content-Currency',
|
|
74
|
-
'X-
|
|
75
|
-
'x-apollo-tracing',
|
|
76
|
-
'apollographql-client-name',
|
|
59
|
+
'X-ReCaptcha',
|
|
77
60
|
],
|
|
78
61
|
})
|
|
79
|
-
|
|
80
|
-
const apolloHandler = apolloServer.createHandler({ path })
|
|
81
62
|
return corsHandler((req, res) => (req.method === 'OPTIONS' ? res.end() : apolloHandler(req, res)))
|
|
82
63
|
}
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/graphql-mesh",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"author": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -10,25 +10,32 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@graphql-mesh/cache-inmemory-lru": "^0.5.24",
|
|
13
|
-
"@graphql-mesh/cli": "^0.42.
|
|
14
|
-
"@graphql-mesh/config": "^0.24.
|
|
13
|
+
"@graphql-mesh/cli": "^0.42.4",
|
|
14
|
+
"@graphql-mesh/config": "^0.24.3",
|
|
15
15
|
"@graphql-mesh/graphql": "^0.18.18",
|
|
16
16
|
"@graphql-mesh/merger-stitching": "^0.13.1",
|
|
17
|
-
"@graphql-mesh/runtime": "^0.
|
|
17
|
+
"@graphql-mesh/runtime": "^0.24.0",
|
|
18
|
+
"@graphql-mesh/store": "^0.1.18",
|
|
18
19
|
"@graphql-mesh/transform-cache": "^0.9.20",
|
|
19
20
|
"@graphql-mesh/transform-federation": "^0.6.10",
|
|
20
21
|
"@graphql-mesh/transform-filter-schema": "^0.12.1",
|
|
21
22
|
"@graphql-mesh/types": "^0.53.0",
|
|
23
|
+
"@graphql-mesh/utils": "^0.18.1",
|
|
24
|
+
"@graphql-tools/utils": "^8.4.0",
|
|
25
|
+
"@vue/compiler-sfc": "^3.2.20",
|
|
22
26
|
"apollo-server-core": "^3.4.0",
|
|
23
27
|
"apollo-server-micro": "^3.4.0",
|
|
28
|
+
"camel-case": "^4.1.2",
|
|
29
|
+
"fetchache": "^0.1.1",
|
|
24
30
|
"graphql": "^15.6.1",
|
|
25
31
|
"micro": "^9.3.4",
|
|
26
32
|
"micro-cors": "^0.1.1",
|
|
33
|
+
"pascal-case": "^3.1.2",
|
|
27
34
|
"ts-tiny-invariant": "^0.0.3"
|
|
28
35
|
},
|
|
29
36
|
"devDependencies": {
|
|
30
37
|
"@graphcommerce/browserslist-config-pwa": "^3.0.2",
|
|
31
|
-
"@graphcommerce/eslint-config-pwa": "^3.0
|
|
38
|
+
"@graphcommerce/eslint-config-pwa": "^3.1.0",
|
|
32
39
|
"@graphcommerce/prettier-config-pwa": "^3.0.3",
|
|
33
40
|
"@graphcommerce/typescript-config-pwa": "^3.1.1",
|
|
34
41
|
"@playwright/test": "^1.15.2",
|
|
@@ -50,5 +57,5 @@
|
|
|
50
57
|
"project": "./tsconfig.json"
|
|
51
58
|
}
|
|
52
59
|
},
|
|
53
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "5a288cb32af2e48278c330ffb36d72be03700ffd"
|
|
54
61
|
}
|
package/createTabs.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DocumentNode, print } from 'graphql'
|
|
2
|
-
|
|
3
|
-
export function createTabs(queries: DocumentNode[], endpoint: string) {
|
|
4
|
-
return Object.entries(queries)
|
|
5
|
-
.filter(([name]) => name.endsWith('Document'))
|
|
6
|
-
.map(([name, gql]) => ({
|
|
7
|
-
name: name.replace('Document', ''),
|
|
8
|
-
query: print(gql),
|
|
9
|
-
endpoint,
|
|
10
|
-
}))
|
|
11
|
-
.filter(({ query }) => query.includes('@client') === false)
|
|
12
|
-
}
|