@graphql-mesh/apollo-link 0.105.21 → 0.105.22

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.
Files changed (3) hide show
  1. package/cjs/index.js +13 -12
  2. package/esm/index.js +14 -13
  3. package/package.json +3 -2
package/cjs/index.js CHANGED
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const graphql_1 = require("graphql");
6
6
  const apolloClient = tslib_1.__importStar(require("@apollo/client"));
7
7
  const utils_1 = require("@graphql-tools/utils");
8
+ const promise_helpers_1 = require("@whatwg-node/promise-helpers");
8
9
  const ROOT_VALUE = {};
9
10
  function createMeshApolloRequestHandler(options) {
10
11
  return function meshApolloRequestHandler(operation) {
@@ -14,21 +15,21 @@ function createMeshApolloRequestHandler(options) {
14
15
  }
15
16
  const operationFn = operationAst.operation === 'subscription' ? options.subscribe : options.execute;
16
17
  return new apolloClient.Observable(observer => {
17
- (0, utils_1.mapMaybePromise)(operationFn(operation.query, operation.variables, operation.getContext(), ROOT_VALUE, operation.operationName), async (results) => {
18
+ (0, promise_helpers_1.handleMaybePromise)(() => operationFn(operation.query, operation.variables, operation.getContext(), ROOT_VALUE, operation.operationName), results => {
18
19
  if ((0, utils_1.isAsyncIterable)(results)) {
19
- for await (const result of results) {
20
- if (observer.closed) {
21
- return;
20
+ return (0, utils_1.fakePromise)().then(async () => {
21
+ for await (const result of results) {
22
+ if (observer.closed) {
23
+ return;
24
+ }
25
+ observer.next(result);
22
26
  }
23
- observer.next(result);
24
- }
25
- observer.complete();
26
- }
27
- else {
28
- if (!observer.closed) {
29
- observer.next(results);
30
27
  observer.complete();
31
- }
28
+ });
29
+ }
30
+ if (!observer.closed) {
31
+ observer.next(results);
32
+ observer.complete();
32
33
  }
33
34
  }, error => {
34
35
  if (!observer.closed) {
package/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { getOperationAST } from 'graphql';
2
2
  import * as apolloClient from '@apollo/client';
3
- import { isAsyncIterable, mapMaybePromise } from '@graphql-tools/utils';
3
+ import { fakePromise, isAsyncIterable } from '@graphql-tools/utils';
4
+ import { handleMaybePromise } from '@whatwg-node/promise-helpers';
4
5
  const ROOT_VALUE = {};
5
6
  function createMeshApolloRequestHandler(options) {
6
7
  return function meshApolloRequestHandler(operation) {
@@ -10,21 +11,21 @@ function createMeshApolloRequestHandler(options) {
10
11
  }
11
12
  const operationFn = operationAst.operation === 'subscription' ? options.subscribe : options.execute;
12
13
  return new apolloClient.Observable(observer => {
13
- mapMaybePromise(operationFn(operation.query, operation.variables, operation.getContext(), ROOT_VALUE, operation.operationName), async (results) => {
14
+ handleMaybePromise(() => operationFn(operation.query, operation.variables, operation.getContext(), ROOT_VALUE, operation.operationName), results => {
14
15
  if (isAsyncIterable(results)) {
15
- for await (const result of results) {
16
- if (observer.closed) {
17
- return;
16
+ return fakePromise().then(async () => {
17
+ for await (const result of results) {
18
+ if (observer.closed) {
19
+ return;
20
+ }
21
+ observer.next(result);
18
22
  }
19
- observer.next(result);
20
- }
21
- observer.complete();
22
- }
23
- else {
24
- if (!observer.closed) {
25
- observer.next(results);
26
23
  observer.complete();
27
- }
24
+ });
25
+ }
26
+ if (!observer.closed) {
27
+ observer.next(results);
28
+ observer.complete();
28
29
  }
29
30
  }, error => {
30
31
  if (!observer.closed) {
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@graphql-mesh/apollo-link",
3
- "version": "0.105.21",
3
+ "version": "0.105.22",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "@apollo/client": "^3.5.9",
7
7
  "graphql": "^15.2.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "@graphql-mesh/runtime": "^0.105.21",
10
+ "@graphql-mesh/runtime": "^0.105.22",
11
11
  "@graphql-tools/utils": "^10.8.0",
12
+ "@whatwg-node/promise-helpers": "^1.0.0",
12
13
  "tslib": "^2.4.0"
13
14
  },
14
15
  "repository": {