@graphcommerce/graphql-mesh 4.1.4 → 4.1.7
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/index.ts +1 -0
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.1.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1598](https://github.com/graphcommerce-org/graphcommerce/pull/1598) [`707dbc73d`](https://github.com/graphcommerce-org/graphcommerce/commit/707dbc73d181204d88fdbbd2e09340e25b2b5f7b) Thanks [@paales](https://github.com/paales)! - Upgraded dependencies
|
|
8
|
+
|
|
9
|
+
## 4.1.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
15
|
+
## 4.1.5
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#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
|
|
20
|
+
|
|
3
21
|
## 4.1.4
|
|
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/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,25 +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.7",
|
|
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-
|
|
10
|
+
"@graphql-mesh/apollo-link": "^5.0.1",
|
|
11
|
+
"@graphql-mesh/config": "5.1.6",
|
|
12
|
+
"@graphql-mesh/graphql": "0.29.8",
|
|
13
|
+
"@graphql-mesh/types": "0.78.7",
|
|
14
|
+
"@graphql-mesh/utils": "0.37.8",
|
|
15
|
+
"@graphql-yoga/node": "^2.13.4",
|
|
15
16
|
"graphql": "16.5.0",
|
|
16
|
-
"next": "12.
|
|
17
|
+
"next": "12.2.5"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
20
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.10",
|
|
20
21
|
"@graphcommerce/prettier-config-pwa": "^4.0.6",
|
|
21
|
-
"@graphcommerce/typescript-config-pwa": "^4.0.
|
|
22
|
+
"@graphcommerce/typescript-config-pwa": "^4.0.4",
|
|
22
23
|
"@playwright/test": "^1.21.1",
|
|
23
|
-
"typescript": "4.7.
|
|
24
|
+
"typescript": "4.7.4"
|
|
24
25
|
},
|
|
25
26
|
"sideEffects": false,
|
|
26
27
|
"prettier": "@graphcommerce/prettier-config-pwa",
|