@graphcommerce/graphql-mesh 3.0.1
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 +112 -0
- package/README.md +1 -0
- package/createHandler.ts +81 -0
- package/createTabs.ts +12 -0
- package/index.ts +4 -0
- package/next-env.d.ts +3 -0
- package/package.json +54 -0
- package/tsconfig.json +5 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [3.0.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql-mesh@3.0.0...@graphcommerce/graphql-mesh@3.0.1) (2021-09-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @graphcommerce/graphql-mesh
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 3.0.0 (2021-09-27)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* apollo server ([43c3535](https://github.com/ho-nl/m2-pwa/commit/43c3535fe26ab9c7b97be8feacba34794bb3fa20))
|
|
20
|
+
* ignore md files from triggering version updates ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
|
|
21
|
+
* products couldn’t be added to the cart ([79512a4](https://github.com/ho-nl/m2-pwa/commit/79512a440b02565808ac4becce9537a59ad4b463))
|
|
22
|
+
* remove conflicting files ([0c17ae4](https://github.com/ho-nl/m2-pwa/commit/0c17ae46be62b775ac83b35f11c532ce2d9401a3))
|
|
23
|
+
* yarn workspace packages hot reload ([d03fc9f](https://github.com/ho-nl/m2-pwa/commit/d03fc9fdda3486476761786f2b56a934cc92befc))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
* created stacked-pages package ([d86008e](https://github.com/ho-nl/m2-pwa/commit/d86008ee659ccb25b194a41d624b394a1ddbd088))
|
|
29
|
+
* **framer-next-pages:** implemented the FullPageShell for the remaining pages ([88386b4](https://github.com/ho-nl/m2-pwa/commit/88386b4652abb7765d6e755c7fb7a3cb6285a0e7))
|
|
30
|
+
* **GraphQL:** shareEnabled: true added to ApolloServer ([379df3c](https://github.com/ho-nl/m2-pwa/commit/379df3c363116a2434115497f9936dca868c58d4))
|
|
31
|
+
* i18n routing added (/ and /fr for demo) ([bb3b339](https://github.com/ho-nl/m2-pwa/commit/bb3b339fbc9fceddd264a891ad81f00327a241ae))
|
|
32
|
+
* **image:** introduced completely rewritten Image component ([e3413b3](https://github.com/ho-nl/m2-pwa/commit/e3413b3a57392d6571ea64cb8d9c8dca05ea31df))
|
|
33
|
+
* major performance refactor ([03f8e2f](https://github.com/ho-nl/m2-pwa/commit/03f8e2fa16ef919bd6bd6eadd36922d0245ed960))
|
|
34
|
+
* **mesh:** use mesh with build version with increased stability/performance ([63863f3](https://github.com/ho-nl/m2-pwa/commit/63863f3a2df4d596819b85f3cf736c7f52f828c1))
|
|
35
|
+
* next.js 11 ([7d61407](https://github.com/ho-nl/m2-pwa/commit/7d614075a778f488045034f74be4f75b93f63c43))
|
|
36
|
+
* **playwright:** added new playwright package to enable browser testing ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
|
|
37
|
+
* renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of [@reachdigital](https://github.com/reachdigital) ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
|
|
38
|
+
* upgrade to node 14 ([d079a75](https://github.com/ho-nl/m2-pwa/commit/d079a751e9bfd8dc7f5009d2c9f31c336a0c96ab))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 2.0.8 (2020-10-28)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## 2.0.7 (2020-10-28)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Bug Fixes
|
|
50
|
+
|
|
51
|
+
* another shot at preflight request ([11de0a3](https://github.com/ho-nl/m2-pwa/commit/11de0a36b45230818f8df4b52a4d5aeb35bf4029))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## 2.0.5 (2020-10-28)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Bug Fixes
|
|
59
|
+
|
|
60
|
+
* add OPTIONS header ([b35b009](https://github.com/ho-nl/m2-pwa/commit/b35b0097be1f9c9b5f8cf8b359c1a0e73ba078aa))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## 2.0.4 (2020-10-28)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
### Bug Fixes
|
|
68
|
+
|
|
69
|
+
* cross origin headers again ([1746cbc](https://github.com/ho-nl/m2-pwa/commit/1746cbce4cee848420927c2df52c31687b96e5c5))
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Features
|
|
73
|
+
|
|
74
|
+
* added separate api package ([65cdd49](https://github.com/ho-nl/m2-pwa/commit/65cdd493f74bb172c3434dd4fb63184601678e1d))
|
|
75
|
+
* split into packages ([2ee7fd6](https://github.com/ho-nl/m2-pwa/commit/2ee7fd6c0056f467d114f04d92c6c0ddf622d151))
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### BREAKING CHANGES
|
|
79
|
+
|
|
80
|
+
* huge folder structure refactor, please read README to reinstall
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
# Change Log
|
|
87
|
+
|
|
88
|
+
All notable changes to this project will be documented in this file. See
|
|
89
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
90
|
+
|
|
91
|
+
# [2.102.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql-mesh@2.101.2...@graphcommerce/graphql-mesh@2.102.0) (2021-08-13)
|
|
92
|
+
|
|
93
|
+
### Features
|
|
94
|
+
|
|
95
|
+
- **mesh:** use mesh with build version with increased stability/performance
|
|
96
|
+
([63863f3](https://github.com/ho-nl/m2-pwa/commit/63863f3a2df4d596819b85f3cf736c7f52f828c1))
|
|
97
|
+
|
|
98
|
+
# [2.101.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql-mesh@2.100.11...@graphcommerce/graphql-mesh@2.101.0) (2021-07-26)
|
|
99
|
+
|
|
100
|
+
### Features
|
|
101
|
+
|
|
102
|
+
- **playwright:** added new playwright package to enable browser testing
|
|
103
|
+
([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
|
|
104
|
+
|
|
105
|
+
## [2.100.11](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/graphql-mesh@2.100.10...@graphcommerce/graphql-mesh@2.100.11) (2021-07-20)
|
|
106
|
+
|
|
107
|
+
### Bug Fixes
|
|
108
|
+
|
|
109
|
+
- apollo server
|
|
110
|
+
([43c3535](https://github.com/ho-nl/m2-pwa/commit/43c3535fe26ab9c7b97be8feacba34794bb3fa20))
|
|
111
|
+
- ignore md files from triggering version updates
|
|
112
|
+
([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# GraphCommerce GraphQL Mesh
|
package/createHandler.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { MeshInstance } from '@graphql-mesh/runtime'
|
|
2
|
+
import { YamlConfig } from '@graphql-mesh/types'
|
|
3
|
+
import { ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core'
|
|
4
|
+
import { ApolloServer } from 'apollo-server-micro'
|
|
5
|
+
import '@graphql-mesh/transform-filter-schema'
|
|
6
|
+
import '@graphql-mesh/graphql'
|
|
7
|
+
import '@graphql-mesh/merger-stitching'
|
|
8
|
+
import '@graphql-mesh/transform-cache'
|
|
9
|
+
import 'ts-tiny-invariant'
|
|
10
|
+
import 'micro'
|
|
11
|
+
import cors from 'micro-cors'
|
|
12
|
+
|
|
13
|
+
export function injectEnv(json: YamlConfig.Config & { $schema?: string }): YamlConfig.Config {
|
|
14
|
+
delete json.$schema
|
|
15
|
+
let content = JSON.stringify(json)
|
|
16
|
+
|
|
17
|
+
if (typeof process === 'undefined' || 'env' in process === false) {
|
|
18
|
+
throw new Error('Process process.env not available')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
content = content.replace(/\$\{(.*?)\}/g, (_, variable) => {
|
|
22
|
+
let varName = variable
|
|
23
|
+
let defaultValue = ''
|
|
24
|
+
|
|
25
|
+
if (variable.includes(':')) {
|
|
26
|
+
const spl = variable.split(':')
|
|
27
|
+
varName = spl.shift()
|
|
28
|
+
defaultValue = spl.join(':')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!process.env[varName]) {
|
|
32
|
+
throw new Error(`Env variable ${varName} not defined`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return process.env[varName] || defaultValue
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return JSON.parse(content)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function createHandler(meshInstance: MeshInstance, path: string) {
|
|
42
|
+
const apolloServer = new ApolloServer({
|
|
43
|
+
context: meshInstance.contextBuilder,
|
|
44
|
+
introspection: true,
|
|
45
|
+
plugins: [
|
|
46
|
+
ApolloServerPluginLandingPageGraphQLPlayground({
|
|
47
|
+
// @ts-expect-error https://github.com/graphql/graphql-playground/issues/1289
|
|
48
|
+
shareEnabled: true,
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
...meshInstance,
|
|
52
|
+
})
|
|
53
|
+
await apolloServer.start()
|
|
54
|
+
|
|
55
|
+
const corsHandler = cors({
|
|
56
|
+
allowMethods: ['GET', 'POST', 'OPTIONS'],
|
|
57
|
+
allowHeaders: [
|
|
58
|
+
'X-CSRF-Token',
|
|
59
|
+
'X-Requested-With',
|
|
60
|
+
'Accept',
|
|
61
|
+
'Accept-Version',
|
|
62
|
+
'Content-Length',
|
|
63
|
+
'Content-MD5',
|
|
64
|
+
'Content-Type',
|
|
65
|
+
'Date',
|
|
66
|
+
'X-Api-Version',
|
|
67
|
+
'Access-Control-Allow-Origin',
|
|
68
|
+
'X-HTTP-Method-Override',
|
|
69
|
+
'Authorization',
|
|
70
|
+
'Store',
|
|
71
|
+
'Preview-Version',
|
|
72
|
+
'Content-Currency',
|
|
73
|
+
'X-Captcha',
|
|
74
|
+
'x-apollo-tracing',
|
|
75
|
+
'apollographql-client-name',
|
|
76
|
+
],
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const apolloHandler = apolloServer.createHandler({ path })
|
|
80
|
+
return corsHandler((req, res) => (req.method === 'OPTIONS' ? res.end() : apolloHandler(req, res)))
|
|
81
|
+
}
|
package/createTabs.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
package/index.ts
ADDED
package/next-env.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@graphcommerce/graphql-mesh",
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"author": "",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "next",
|
|
8
|
+
"build": "next build",
|
|
9
|
+
"start": "next start"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@graphql-mesh/cli": "^0.38.1",
|
|
13
|
+
"@graphql-mesh/config": "^0.23.1",
|
|
14
|
+
"@graphql-mesh/graphql": "^0.18.10",
|
|
15
|
+
"@graphql-mesh/merger-stitching": "^0.12.0",
|
|
16
|
+
"@graphql-mesh/runtime": "^0.20.0",
|
|
17
|
+
"@graphql-mesh/transform-cache": "^0.9.12",
|
|
18
|
+
"@graphql-mesh/transform-federation": "^0.6.2",
|
|
19
|
+
"@graphql-mesh/transform-filter-schema": "^0.10.28",
|
|
20
|
+
"@graphql-mesh/types": "^0.47.0",
|
|
21
|
+
"apollo-server-core": "^3.3.0",
|
|
22
|
+
"apollo-server-micro": "^3.3.0",
|
|
23
|
+
"graphql": "^15.5.2",
|
|
24
|
+
"micro": "^9.3.4",
|
|
25
|
+
"micro-cors": "^0.1.1",
|
|
26
|
+
"ts-tiny-invariant": "^0.0.3"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@graphcommerce/browserslist-config-pwa": "^3.0.1",
|
|
30
|
+
"@graphcommerce/eslint-config-pwa": "^3.0.1",
|
|
31
|
+
"@graphcommerce/prettier-config-pwa": "^3.0.1",
|
|
32
|
+
"@graphcommerce/typescript-config-pwa": "^3.0.1",
|
|
33
|
+
"@playwright/test": "^1.14.1",
|
|
34
|
+
"@types/micro-cors": "^0.1.2",
|
|
35
|
+
"@types/react": "^17.0.19",
|
|
36
|
+
"@types/react-dom": "^17.0.9",
|
|
37
|
+
"graphql-tag": "2.12.5",
|
|
38
|
+
"typescript": "^4.4.2"
|
|
39
|
+
},
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
42
|
+
"browserslist": [
|
|
43
|
+
"extends @graphcommerce/browserslist-config-pwa"
|
|
44
|
+
],
|
|
45
|
+
"eslint": {
|
|
46
|
+
"extends": "@graphcommerce/eslint-config-pwa"
|
|
47
|
+
},
|
|
48
|
+
"eslintConfig": {
|
|
49
|
+
"extends": "@graphcommerce/eslint-config-pwa",
|
|
50
|
+
"parserOptions": {
|
|
51
|
+
"project": "./tsconfig.json"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|