@graphcommerce/graphql-mesh 7.1.0-canary.8 → 8.0.0-canary.40

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,73 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.0.0-canary.40
4
+
5
+ ## 7.1.0-canary.39
6
+
7
+ ### Patch Changes
8
+
9
+ - [#2113](https://github.com/graphcommerce-org/graphcommerce/pull/2113) [`bf5ae8979`](https://github.com/graphcommerce-org/graphcommerce/commit/bf5ae8979b145e7a96303f839ef2b1238712531a) - Remove requirement of toplevelAwait for graphqlSsrClient and solve logging issue in cli ([@paales](https://github.com/paales))
10
+
11
+ ## 7.1.0-canary.38
12
+
13
+ ## 7.1.0-canary.37
14
+
15
+ ## 7.1.0-canary.36
16
+
17
+ ## 7.1.0-canary.35
18
+
19
+ ## 7.1.0-canary.34
20
+
21
+ ## 7.1.0-canary.33
22
+
23
+ ## 7.1.0-canary.32
24
+
25
+ ## 7.1.0-canary.31
26
+
27
+ ## 7.1.0-canary.30
28
+
29
+ ## 7.1.0-canary.29
30
+
31
+ ## 7.1.0-canary.28
32
+
33
+ ## 7.1.0-canary.27
34
+
35
+ ## 7.1.0-canary.26
36
+
37
+ ## 7.1.0-canary.25
38
+
39
+ ## 7.1.0-canary.24
40
+
41
+ ## 7.1.0-canary.23
42
+
43
+ ## 7.1.0-canary.22
44
+
45
+ ## 7.1.0-canary.21
46
+
47
+ ## 7.1.0-canary.20
48
+
49
+ ## 7.1.0-canary.19
50
+
51
+ ## 7.1.0-canary.18
52
+
53
+ ## 7.1.0-canary.17
54
+
55
+ ## 7.1.0-canary.16
56
+
57
+ ## 7.1.0-canary.15
58
+
59
+ ## 7.1.0-canary.14
60
+
61
+ ## 7.1.0-canary.13
62
+
63
+ ## 7.1.0-canary.12
64
+
65
+ ## 7.1.0-canary.11
66
+
67
+ ## 7.1.0-canary.10
68
+
69
+ ## 7.1.0-canary.9
70
+
3
71
  ## 7.1.0-canary.8
4
72
 
5
73
  ## 7.0.2-canary.7
package/api/apolloLink.ts CHANGED
@@ -1,38 +1,19 @@
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
1
  import { ApolloLink, FetchResult, Observable, Operation, RequestHandler } from '@apollo/client/core'
13
- import { ExecuteMeshFn, SubscribeMeshFn } from '@graphql-mesh/runtime'
2
+ import { ExecuteMeshFn, MeshInstance, SubscribeMeshFn } from '@graphql-mesh/runtime'
14
3
  import { isAsyncIterable } from '@graphql-tools/utils'
15
- import { getOperationAST } from 'graphql'
16
-
17
- export interface MeshApolloRequestHandlerOptions {
18
- execute: ExecuteMeshFn
19
- subscribe?: SubscribeMeshFn
20
- }
21
4
 
22
5
  const ROOT_VALUE = {}
23
- function createMeshApolloRequestHandler(options: MeshApolloRequestHandlerOptions): RequestHandler {
24
- return function meshApolloRequestHandler(operation: Operation): Observable<FetchResult> {
25
- const operationAst = getOperationAST(operation.query, operation.operationName)
26
- if (!operationAst) {
27
- throw new Error('GraphQL operation not found')
28
- }
29
- const operationFn =
30
- operationAst.operation === 'subscription' && options.subscribe
31
- ? options.subscribe
32
- : options.execute
33
- return new Observable((observer) => {
6
+
7
+ function createMeshApolloRequestHandler(
8
+ mesh: MeshInstance | Promise<MeshInstance>,
9
+ ): RequestHandler {
10
+ return (operation: Operation): Observable<FetchResult> =>
11
+ new Observable((observer) => {
34
12
  Promise.resolve()
35
13
  .then(async () => {
14
+ // Create a new executor for each request
15
+ const operationFn: SubscribeMeshFn | ExecuteMeshFn = (await mesh).createExecutor({})
16
+
36
17
  const results = await operationFn(
37
18
  operation.query,
38
19
  operation.variables,
@@ -42,9 +23,7 @@ function createMeshApolloRequestHandler(options: MeshApolloRequestHandlerOptions
42
23
  )
43
24
  if (isAsyncIterable(results)) {
44
25
  for await (const result of results) {
45
- if (observer.closed) {
46
- return
47
- }
26
+ if (observer.closed) return
48
27
  observer.next(result)
49
28
  }
50
29
  observer.complete()
@@ -54,16 +33,13 @@ function createMeshApolloRequestHandler(options: MeshApolloRequestHandlerOptions
54
33
  }
55
34
  })
56
35
  .catch((error) => {
57
- if (!observer.closed) {
58
- observer.error(error)
59
- }
36
+ if (!observer.closed) observer.error(error)
60
37
  })
61
38
  })
62
- }
63
39
  }
64
40
 
65
41
  export class MeshApolloLink extends ApolloLink {
66
- constructor(options: MeshApolloRequestHandlerOptions) {
42
+ constructor(options: MeshInstance | Promise<MeshInstance>) {
67
43
  super(createMeshApolloRequestHandler(options))
68
44
  }
69
45
  }
package/package.json CHANGED
@@ -2,12 +2,9 @@
2
2
  "name": "@graphcommerce/graphql-mesh",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "7.1.0-canary.8",
6
- "author": "",
7
- "license": "MIT",
5
+ "version": "8.0.0-canary.40",
8
6
  "main": "index.ts",
9
7
  "dependencies": {
10
- "@apollo/client": "~3.8.2",
11
8
  "@graphql-mesh/apollo-link": "latest",
12
9
  "@graphql-mesh/config": "latest",
13
10
  "@graphql-mesh/cross-helpers": "latest",
@@ -19,18 +16,19 @@
19
16
  "@graphql-mesh/transform-prune": "latest",
20
17
  "@graphql-mesh/types": "latest",
21
18
  "@graphql-mesh/utils": "latest",
22
- "@graphql-tools/utils": "^10.0.1",
23
- "@whatwg-node/fetch": "^0.9.4",
19
+ "@graphql-tools/utils": "^10.0.8",
20
+ "@whatwg-node/fetch": "^0.9.14",
24
21
  "fetch-retry": "^5.0.6",
25
- "tslib": "^2.4.0"
22
+ "tslib": "^2.6.2"
26
23
  },
27
24
  "peerDependencies": {
25
+ "@apollo/client": "^3",
26
+ "@graphcommerce/eslint-config-pwa": "8.0.0-canary.40",
27
+ "@graphcommerce/prettier-config-pwa": "8.0.0-canary.40",
28
+ "@graphcommerce/typescript-config-pwa": "8.0.0-canary.40",
28
29
  "graphql": "^16.7.1"
29
30
  },
30
31
  "devDependencies": {
31
- "@graphcommerce/eslint-config-pwa": "7.1.0-canary.8",
32
- "@graphcommerce/prettier-config-pwa": "7.1.0-canary.8",
33
- "@graphcommerce/typescript-config-pwa": "7.1.0-canary.8",
34
32
  "typescript": "5.2.2"
35
33
  },
36
34
  "sideEffects": false,