@graphql-mesh/urql-exchange 8.0.6-alpha-20221115232557-4780edf98 → 8.0.6-alpha-20221116101236-75e43159f

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.
@@ -1,31 +1,29 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const wonka = require('wonka');
6
- const core = require('@urql/core');
7
- const utils = require('@graphql-tools/utils');
8
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.meshExchange = void 0;
4
+ const wonka_1 = require("wonka");
5
+ const core_1 = require("@urql/core");
6
+ const utils_1 = require("@graphql-tools/utils");
9
7
  const ROOT_VALUE = {};
10
8
  const makeExecuteSource = (operation, options) => {
11
9
  const operationFn = operation.kind === 'subscription' ? options.subscribe : options.execute;
12
- const operationName = core.getOperationName(operation.query);
13
- return wonka.make(observer => {
10
+ const operationName = (0, core_1.getOperationName)(operation.query);
11
+ return (0, wonka_1.make)(observer => {
14
12
  let ended = false;
15
13
  operationFn(operation.query, operation.variables, operation.context, ROOT_VALUE, operationName)
16
14
  .then((result) => {
17
15
  if (ended || !result) {
18
16
  return;
19
17
  }
20
- else if (!utils.isAsyncIterable(result)) {
21
- observer.next(core.makeResult(operation, result));
18
+ else if (!(0, utils_1.isAsyncIterable)(result)) {
19
+ observer.next((0, core_1.makeResult)(operation, result));
22
20
  return;
23
21
  }
24
22
  const iterator = result[Symbol.asyncIterator]();
25
23
  let prevResult = null;
26
24
  function next({ done, value }) {
27
25
  if (value) {
28
- observer.next((prevResult = prevResult ? core.mergeResultPatch(prevResult, value) : core.makeResult(operation, value)));
26
+ observer.next((prevResult = prevResult ? (0, core_1.mergeResultPatch)(prevResult, value) : (0, core_1.makeResult)(operation, value)));
29
27
  }
30
28
  if (!done && !ended) {
31
29
  return iterator.next().then(next);
@@ -40,7 +38,7 @@ const makeExecuteSource = (operation, options) => {
40
38
  observer.complete();
41
39
  })
42
40
  .catch(error => {
43
- observer.next(core.makeErrorResult(operation, error));
41
+ observer.next((0, core_1.makeErrorResult)(operation, error));
44
42
  observer.complete();
45
43
  });
46
44
  return () => {
@@ -51,17 +49,16 @@ const makeExecuteSource = (operation, options) => {
51
49
  /** Exchange for executing queries locally on a schema using graphql-js. */
52
50
  const meshExchange = (options) => ({ forward }) => {
53
51
  return ops$ => {
54
- const sharedOps$ = wonka.share(ops$);
55
- const executedOps$ = wonka.pipe(sharedOps$, wonka.filter((operation) => {
52
+ const sharedOps$ = (0, wonka_1.share)(ops$);
53
+ const executedOps$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)((operation) => {
56
54
  return operation.kind === 'query' || operation.kind === 'mutation' || operation.kind === 'subscription';
57
- }), wonka.mergeMap((operation) => {
55
+ }), (0, wonka_1.mergeMap)((operation) => {
58
56
  const { key } = operation;
59
- const teardown$ = wonka.pipe(sharedOps$, wonka.filter(op => op.kind === 'teardown' && op.key === key));
60
- return wonka.pipe(makeExecuteSource(operation, options), wonka.takeUntil(teardown$));
57
+ const teardown$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)(op => op.kind === 'teardown' && op.key === key));
58
+ return (0, wonka_1.pipe)(makeExecuteSource(operation, options), (0, wonka_1.takeUntil)(teardown$));
61
59
  }));
62
- const forwardedOps$ = wonka.pipe(sharedOps$, wonka.filter(operation => operation.kind === 'teardown'), forward);
63
- return wonka.merge([executedOps$, forwardedOps$]);
60
+ const forwardedOps$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)(operation => operation.kind === 'teardown'), forward);
61
+ return (0, wonka_1.merge)([executedOps$, forwardedOps$]);
64
62
  };
65
63
  };
66
-
67
64
  exports.meshExchange = meshExchange;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,7 +1,6 @@
1
- import { share, pipe, filter, mergeMap, make, takeUntil, merge } from 'wonka';
2
- import { makeResult, makeErrorResult, getOperationName, mergeResultPatch } from '@urql/core';
1
+ import { pipe, share, filter, takeUntil, mergeMap, merge, make } from 'wonka';
2
+ import { makeResult, makeErrorResult, mergeResultPatch, getOperationName, } from '@urql/core';
3
3
  import { isAsyncIterable } from '@graphql-tools/utils';
4
-
5
4
  const ROOT_VALUE = {};
6
5
  const makeExecuteSource = (operation, options) => {
7
6
  const operationFn = operation.kind === 'subscription' ? options.subscribe : options.execute;
@@ -45,7 +44,7 @@ const makeExecuteSource = (operation, options) => {
45
44
  });
46
45
  };
47
46
  /** Exchange for executing queries locally on a schema using graphql-js. */
48
- const meshExchange = (options) => ({ forward }) => {
47
+ export const meshExchange = (options) => ({ forward }) => {
49
48
  return ops$ => {
50
49
  const sharedOps$ = share(ops$);
51
50
  const executedOps$ = pipe(sharedOps$, filter((operation) => {
@@ -59,5 +58,3 @@ const meshExchange = (options) => ({ forward }) => {
59
58
  return merge([executedOps$, forwardedOps$]);
60
59
  };
61
60
  };
62
-
63
- export { meshExchange };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@graphql-mesh/urql-exchange",
3
- "version": "8.0.6-alpha-20221115232557-4780edf98",
3
+ "version": "8.0.6-alpha-20221116101236-75e43159f",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/runtime": "0.44.32-alpha-20221115232557-4780edf98",
7
- "@urql/core": "^2.4.3",
6
+ "@graphql-mesh/runtime": "0.44.32-alpha-20221116101236-75e43159f",
8
7
  "graphql": "^15.2.0 || ^16.0.0",
8
+ "@urql/core": "^2.4.3",
9
9
  "wonka": "^4.0.15"
10
10
  },
11
11
  "dependencies": {
@@ -18,21 +18,28 @@
18
18
  "directory": "packages/urql"
19
19
  },
20
20
  "license": "MIT",
21
- "main": "index.js",
22
- "module": "index.mjs",
23
- "typings": "index.d.ts",
21
+ "main": "cjs/index.js",
22
+ "module": "esm/index.js",
23
+ "typings": "typings/index.d.ts",
24
24
  "typescript": {
25
- "definition": "index.d.ts"
25
+ "definition": "typings/index.d.ts"
26
26
  },
27
+ "type": "module",
27
28
  "exports": {
28
29
  ".": {
29
- "require": "./index.js",
30
- "import": "./index.mjs"
31
- },
32
- "./*": {
33
- "require": "./*.js",
34
- "import": "./*.mjs"
30
+ "require": {
31
+ "types": "./typings/index.d.cts",
32
+ "default": "./cjs/index.js"
33
+ },
34
+ "import": {
35
+ "types": "./typings/index.d.ts",
36
+ "default": "./esm/index.js"
37
+ },
38
+ "default": {
39
+ "types": "./typings/index.d.ts",
40
+ "default": "./esm/index.js"
41
+ }
35
42
  },
36
43
  "./package.json": "./package.json"
37
44
  }
38
- }
45
+ }
File without changes
@@ -0,0 +1,8 @@
1
+ import { Exchange } from '@urql/core';
2
+ import { ExecuteMeshFn, SubscribeMeshFn } from '@graphql-mesh/runtime';
3
+ export interface MeshExchangeOptions {
4
+ execute: ExecuteMeshFn;
5
+ subscribe?: SubscribeMeshFn;
6
+ }
7
+ /** Exchange for executing queries locally on a schema using graphql-js. */
8
+ export declare const meshExchange: (options: MeshExchangeOptions) => Exchange;