@graphcommerce/graphql-mesh 4.0.9 → 4.1.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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1399](https://github.com/graphcommerce-org/graphcommerce/pull/1399) [`fb277d8e1`](https://github.com/graphcommerce-org/graphcommerce/commit/fb277d8e1e3612c5e9cf890a30d19cfd1ff70542) Thanks [@paales](https://github.com/paales)! - Now using [@graphql-yoga](https://github.com/dotansimha/graphql-yoga) for GraphQL which has full support for [envelop](https://www.envelop.dev/) plugins.
8
+
9
+ * [#1399](https://github.com/graphcommerce-org/graphcommerce/pull/1399) [`fb277d8e1`](https://github.com/graphcommerce-org/graphcommerce/commit/fb277d8e1e3612c5e9cf890a30d19cfd1ff70542) Thanks [@paales](https://github.com/paales)! - Added a new @graphcommerce/cli package to generate the mesh so it can be generated _inside_ the @graphcommerce/graphql-mesh package to allow for better future extensibility.
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1399](https://github.com/graphcommerce-org/graphcommerce/pull/1399) [`da0ae7d02`](https://github.com/graphcommerce-org/graphcommerce/commit/da0ae7d0236e4908ba0bf0fa16656be516e841d4) Thanks [@paales](https://github.com/paales)! - Updated dependencies
14
+
15
+ ## 4.0.11
16
+
17
+ ### Patch Changes
18
+
19
+ - [#1378](https://github.com/graphcommerce-org/graphcommerce/pull/1378) [`22ff9df16`](https://github.com/graphcommerce-org/graphcommerce/commit/22ff9df1677742ae8e07d9b7e5b12fbb487580dc) Thanks [@paales](https://github.com/paales)! - upgrade to latest versions of packages
20
+
21
+ ## 4.0.10
22
+
23
+ ### Patch Changes
24
+
25
+ - [#1369](https://github.com/graphcommerce-org/graphcommerce/pull/1369) [`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9) Thanks [@paales](https://github.com/paales)! - Upgraded dependencies
26
+
3
27
  ## 4.0.9
4
28
 
5
29
  ### Patch Changes
@@ -0,0 +1,35 @@
1
+ /* eslint-disable react-hooks/rules-of-hooks */
2
+ import { createServer as createYogaServer, useExtendContext } from '@graphql-yoga/node'
3
+ import { getBuiltMesh, rawConfig } from '../.mesh'
4
+
5
+ export async function createServer(endpoint: string) {
6
+ // retrieve the mesh instance (with configured Envelop plugins)
7
+ const mesh = await getBuiltMesh()
8
+
9
+ const { cors } = rawConfig.serve ?? {}
10
+
11
+ // pass the Mesh instance to Yoga and configure GraphiQL
12
+ const server = createYogaServer({
13
+ plugins: [
14
+ ...mesh.plugins,
15
+ useExtendContext(({ req, res }) => ({
16
+ ...req,
17
+ headers: req.headers,
18
+ cookies: req.cookies,
19
+ res,
20
+ })),
21
+ ],
22
+ context: ({ req }) => ({ ...req, ...mesh.meshContext }),
23
+ graphiql: {
24
+ endpoint,
25
+ title: 'GraphCommerce® Mesh',
26
+ },
27
+ maskedErrors: false,
28
+ parserCache: false,
29
+ validationCache: false,
30
+ logging: mesh.logger,
31
+ cors,
32
+ })
33
+
34
+ return server.requestListener
35
+ }
package/index.ts CHANGED
@@ -1,3 +1,2 @@
1
- export * from './createServer'
2
-
3
- export const config = { api: { bodyParser: false } }
1
+ export * from './api/createEnvelop'
2
+ export * from './.mesh'
package/package.json CHANGED
@@ -2,45 +2,31 @@
2
2
  "name": "@graphcommerce/graphql-mesh",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.0.9",
5
+ "version": "4.1.0",
6
6
  "author": "",
7
7
  "license": "MIT",
8
- "scripts": {
9
- "dev": "next",
10
- "build": "next build",
11
- "start": "next start"
12
- },
8
+ "main": "index.ts",
13
9
  "dependencies": {
14
- "@graphql-mesh/config": "0.31.12",
15
- "@graphql-mesh/graphql": "0.22.2",
16
- "@graphql-mesh/merger-stitching": "0.15.26",
17
- "@graphql-mesh/runtime": "0.33.2",
18
- "@graphql-mesh/store": "0.4.2",
19
- "@graphql-mesh/transform-cache": "0.11.33",
20
- "@graphql-mesh/transform-federation": "0.8.33",
21
- "@graphql-mesh/transform-filter-schema": "0.14.33",
22
- "@graphql-mesh/types": "0.68.0",
23
- "@graphql-mesh/utils": "0.30.2",
24
- "@vue/compiler-sfc": "^3.2.31",
25
- "apollo-server-core": "^3.6.4",
26
- "apollo-server-micro": "^3.6.4",
27
- "apollo-tracing": "^0.15.0",
28
- "camel-case": "^4.1.2",
29
- "fetchache": "^0.1.1",
30
- "graphql": "^16.3.0",
31
- "micro": "^9.3.4",
32
- "micro-cors": "^0.1.1",
33
- "pascal-case": "^3.1.2",
34
- "ts-tiny-invariant": "^1.0.5"
10
+ "@graphql-mesh/config": "0.34.4",
11
+ "@graphql-mesh/graphql": "0.23.6",
12
+ "@graphql-mesh/merger-stitching": "0.15.36",
13
+ "@graphql-mesh/runtime": "0.33.13",
14
+ "@graphql-mesh/store": "0.7.5",
15
+ "@graphql-mesh/transform-cache": "0.11.43",
16
+ "@graphql-mesh/transform-federation": "0.8.44",
17
+ "@graphql-mesh/transform-filter-schema": "0.14.43",
18
+ "@graphql-mesh/types": "0.70.5",
19
+ "@graphql-mesh/utils": "0.33.5",
20
+ "@graphql-yoga/node": "^2.3.0",
21
+ "graphql": "16.3.0",
22
+ "next": "12.1.5"
35
23
  },
36
24
  "devDependencies": {
37
- "@graphcommerce/eslint-config-pwa": "^4.1.1",
38
- "@graphcommerce/prettier-config-pwa": "^4.0.4",
25
+ "@graphcommerce/eslint-config-pwa": "^4.1.5",
26
+ "@graphcommerce/prettier-config-pwa": "^4.0.6",
39
27
  "@graphcommerce/typescript-config-pwa": "^4.0.2",
40
- "@playwright/test": "^1.19.2",
41
- "@types/micro-cors": "^0.1.2",
42
- "graphql-tag": "2.12.6",
43
- "typescript": "^4.6.2"
28
+ "@playwright/test": "^1.21.1",
29
+ "typescript": "4.6.3"
44
30
  },
45
31
  "sideEffects": false,
46
32
  "prettier": "@graphcommerce/prettier-config-pwa",
package/createServer.ts DELETED
@@ -1,66 +0,0 @@
1
- import { processConfig } from '@graphql-mesh/config'
2
- import { getMesh as getGraphQLMesh, MeshInstance } from '@graphql-mesh/runtime'
3
- import { YamlConfig } from '@graphql-mesh/types'
4
- import { ApolloServerPluginLandingPageGraphQLPlayground } from 'apollo-server-core'
5
- import { ApolloServer } from 'apollo-server-micro'
6
- import '@graphql-mesh/transform-filter-schema'
7
- import '@graphql-mesh/graphql'
8
- import '@graphql-mesh/merger-stitching'
9
- import '@graphql-mesh/transform-cache'
10
- import '@graphql-mesh/cache-inmemory-lru'
11
- import '@vue/compiler-sfc'
12
- import 'ts-tiny-invariant'
13
- import 'micro'
14
- import { plugin as apolloTracingPlugin } from 'apollo-tracing'
15
- import cors from 'micro-cors'
16
-
17
- export async function getMesh(config: unknown): Promise<MeshInstance> {
18
- return getGraphQLMesh(await processConfig(config as YamlConfig.Config, { dir: process.cwd() }))
19
- }
20
-
21
- export async function createServer(mesh: Promise<MeshInstance>, path: string) {
22
- const meshInstance = await mesh
23
- const apolloServer = new ApolloServer({
24
- context: ({ req }) => req,
25
- introspection: true,
26
- ...meshInstance,
27
- plugins: [
28
- ApolloServerPluginLandingPageGraphQLPlayground({
29
- // @ts-expect-error https://github.com/graphql/graphql-playground/issues/1289
30
- shareEnabled: true,
31
- }),
32
- // @ts-expect-error apolloTracingPlugin is not officially supported anymore
33
- apolloTracingPlugin(),
34
- ],
35
- })
36
- await apolloServer.start()
37
-
38
- const apolloHandler = apolloServer.createHandler({ path })
39
-
40
- const corsHandler = cors({
41
- allowMethods: ['GET', 'POST', 'OPTIONS'],
42
- allowHeaders: [
43
- 'X-CSRF-Token',
44
- 'X-Requested-With',
45
- 'Accept',
46
- 'Accept-Version',
47
- 'Content-Length',
48
- 'Content-MD5',
49
- 'Content-Type',
50
- 'Date',
51
- 'X-Api-Version',
52
- 'Access-Control-Allow-Origin',
53
- 'X-HTTP-Method-Override',
54
- 'x-apollo-tracing',
55
- 'apollographql-client-name',
56
-
57
- // Magento 2 related headers
58
- 'Authorization',
59
- 'Store',
60
- 'Preview-Version',
61
- 'Content-Currency',
62
- 'X-ReCaptcha',
63
- ],
64
- })
65
- return corsHandler((req, res) => (req.method === 'OPTIONS' ? res.end() : apolloHandler(req, res)))
66
- }
package/next-env.d.ts DELETED
@@ -1,3 +0,0 @@
1
- /// <reference types="next" />
2
- /// <reference types="next/types/global" />
3
- /// <reference types="next/image-types/global" />