@graphcommerce/graphql-mesh 4.1.3 → 4.1.6
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 +18 -0
- package/api/apolloLink.ts +71 -0
- package/api/createEnvelop.ts +2 -2
- package/index.ts +1 -0
- package/package.json +12 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1562](https://github.com/graphcommerce-org/graphcommerce/pull/1562) [`01f1588c9`](https://github.com/graphcommerce-org/graphcommerce/commit/01f1588c9200bb39dd61146e260bfa2b32060612) Thanks [@paales](https://github.com/paales)! - The context was missing in apollo client
|
|
8
|
+
|
|
9
|
+
## 4.1.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1552](https://github.com/graphcommerce-org/graphcommerce/pull/1552) [`18054c441`](https://github.com/graphcommerce-org/graphcommerce/commit/18054c441962ba750bed3acc39ab46c8d3a341ce) Thanks [@paales](https://github.com/paales)! - Updated to Next.js v12.2.2 and other packages and made compatible
|
|
14
|
+
|
|
15
|
+
## 4.1.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#1490](https://github.com/graphcommerce-org/graphcommerce/pull/1490) [`d311ef48b`](https://github.com/graphcommerce-org/graphcommerce/commit/d311ef48bb3e97806d992af5516d6b7f183ec9cb) Thanks [@paales](https://github.com/paales)! - upgraded packages
|
|
20
|
+
|
|
3
21
|
## 4.1.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a direct copy from
|
|
5
|
+
* https://github.com/Urigo/graphql-mesh/blob/master/packages/apollo-link/src/index.ts but because
|
|
6
|
+
* it throws an error we've created a local copy of it.
|
|
7
|
+
*
|
|
8
|
+
* https://github.com/apollographql/apollo-client/issues/9925
|
|
9
|
+
* https://github.com/Urigo/graphql-mesh/issues/4196
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// export * from '@graphql-mesh/apollo-link'
|
|
13
|
+
import { ApolloLink, FetchResult, Observable, Operation, RequestHandler } from '@apollo/client/core'
|
|
14
|
+
import { ExecuteMeshFn, SubscribeMeshFn } from '@graphql-mesh/runtime'
|
|
15
|
+
import { isAsyncIterable } from '@graphql-tools/utils'
|
|
16
|
+
import { getOperationAST } from 'graphql'
|
|
17
|
+
|
|
18
|
+
export interface MeshApolloRequestHandlerOptions {
|
|
19
|
+
execute: ExecuteMeshFn
|
|
20
|
+
subscribe?: SubscribeMeshFn
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ROOT_VALUE = {}
|
|
24
|
+
function createMeshApolloRequestHandler(options: MeshApolloRequestHandlerOptions): RequestHandler {
|
|
25
|
+
return function meshApolloRequestHandler(operation: Operation): Observable<FetchResult> {
|
|
26
|
+
const operationAst = getOperationAST(operation.query, operation.operationName)
|
|
27
|
+
if (!operationAst) {
|
|
28
|
+
throw new Error('GraphQL operation not found')
|
|
29
|
+
}
|
|
30
|
+
const operationFn =
|
|
31
|
+
operationAst.operation === 'subscription' && options.subscribe
|
|
32
|
+
? options.subscribe
|
|
33
|
+
: options.execute
|
|
34
|
+
|
|
35
|
+
return new Observable((observer) => {
|
|
36
|
+
Promise.resolve()
|
|
37
|
+
.then(async () => {
|
|
38
|
+
const results = await operationFn(
|
|
39
|
+
operation.query,
|
|
40
|
+
operation.variables,
|
|
41
|
+
operation.getContext(),
|
|
42
|
+
ROOT_VALUE,
|
|
43
|
+
operation.operationName,
|
|
44
|
+
)
|
|
45
|
+
if (isAsyncIterable(results)) {
|
|
46
|
+
for await (const result of results) {
|
|
47
|
+
if (observer.closed) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
observer.next(result)
|
|
51
|
+
}
|
|
52
|
+
observer.complete()
|
|
53
|
+
} else if (!observer.closed) {
|
|
54
|
+
observer.next(results)
|
|
55
|
+
observer.complete()
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
.catch((error) => {
|
|
59
|
+
if (!observer.closed) {
|
|
60
|
+
observer.error(error)
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class MeshApolloLink extends ApolloLink {
|
|
68
|
+
constructor(options: MeshApolloRequestHandlerOptions) {
|
|
69
|
+
super(createMeshApolloRequestHandler(options))
|
|
70
|
+
}
|
|
71
|
+
}
|
package/api/createEnvelop.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
2
|
import { createServer as createYogaServer, useExtendContext } from '@graphql-yoga/node'
|
|
3
|
-
import { getBuiltMesh,
|
|
3
|
+
import { getBuiltMesh, rawServeConfig } from '../.mesh'
|
|
4
4
|
|
|
5
5
|
export async function createServer(endpoint: string) {
|
|
6
6
|
// retrieve the mesh instance (with configured Envelop plugins)
|
|
7
7
|
const mesh = await getBuiltMesh()
|
|
8
8
|
|
|
9
|
-
const { cors, playgroundTitle } =
|
|
9
|
+
const { cors, playgroundTitle } = rawServeConfig ?? {}
|
|
10
10
|
|
|
11
11
|
// pass the Mesh instance to Yoga and configure GraphiQL
|
|
12
12
|
const server = createYogaServer({
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,31 +2,26 @@
|
|
|
2
2
|
"name": "@graphcommerce/graphql-mesh",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "4.1.
|
|
5
|
+
"version": "4.1.6",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "index.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-mesh/
|
|
11
|
-
"@graphql-mesh/
|
|
12
|
-
"@graphql-mesh/
|
|
13
|
-
"@graphql-mesh/
|
|
14
|
-
"@graphql-mesh/
|
|
15
|
-
"@graphql-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"@graphql-mesh/types": "0.72.1",
|
|
19
|
-
"@graphql-mesh/utils": "0.34.6",
|
|
20
|
-
"@graphql-yoga/node": "^2.5.0",
|
|
21
|
-
"graphql": "16.4.0",
|
|
22
|
-
"next": "12.1.5"
|
|
10
|
+
"@graphql-mesh/apollo-link": "^0.0.3",
|
|
11
|
+
"@graphql-mesh/config": "5.1.2",
|
|
12
|
+
"@graphql-mesh/graphql": "0.29.5",
|
|
13
|
+
"@graphql-mesh/types": "0.78.4",
|
|
14
|
+
"@graphql-mesh/utils": "0.37.5",
|
|
15
|
+
"@graphql-yoga/node": "^2.13.4",
|
|
16
|
+
"graphql": "16.5.0",
|
|
17
|
+
"next": "12.2.2"
|
|
23
18
|
},
|
|
24
19
|
"devDependencies": {
|
|
25
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
20
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.9",
|
|
26
21
|
"@graphcommerce/prettier-config-pwa": "^4.0.6",
|
|
27
|
-
"@graphcommerce/typescript-config-pwa": "^4.0.
|
|
22
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.4",
|
|
28
23
|
"@playwright/test": "^1.21.1",
|
|
29
|
-
"typescript": "4.
|
|
24
|
+
"typescript": "4.7.4"
|
|
30
25
|
},
|
|
31
26
|
"sideEffects": false,
|
|
32
27
|
"prettier": "@graphcommerce/prettier-config-pwa",
|