@graphql-tools/executor-urql-exchange 0.0.8 → 0.0.9-alpha-20230406062259-3c0a93c4
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/cjs/index.js +9 -6
- package/esm/index.js +10 -7
- package/package.json +2 -2
package/cjs/index.js
CHANGED
|
@@ -6,13 +6,11 @@ const core_1 = require("@urql/core");
|
|
|
6
6
|
const utils_1 = require("@graphql-tools/utils");
|
|
7
7
|
function executorExchange(executor) {
|
|
8
8
|
function makeYogaSource(operation) {
|
|
9
|
-
const operationName = (0, core_1.getOperationName)(operation.query);
|
|
10
9
|
const extraFetchOptions = typeof operation.context.fetchOptions === 'function'
|
|
11
10
|
? operation.context.fetchOptions()
|
|
12
11
|
: operation.context.fetchOptions;
|
|
13
12
|
const executionRequest = {
|
|
14
13
|
document: operation.query,
|
|
15
|
-
operationName,
|
|
16
14
|
operationType: operation.kind,
|
|
17
15
|
variables: operation.variables,
|
|
18
16
|
context: operation.context,
|
|
@@ -38,7 +36,12 @@ function executorExchange(executor) {
|
|
|
38
36
|
let prevResult = null;
|
|
39
37
|
for await (const value of result) {
|
|
40
38
|
if (value) {
|
|
41
|
-
|
|
39
|
+
if (prevResult && value.incremental) {
|
|
40
|
+
prevResult = (0, core_1.mergeResultPatch)(prevResult, value);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
prevResult = (0, core_1.makeResult)(operation, value);
|
|
44
|
+
}
|
|
42
45
|
observer.next(prevResult);
|
|
43
46
|
}
|
|
44
47
|
if (ended) {
|
|
@@ -63,11 +66,11 @@ function executorExchange(executor) {
|
|
|
63
66
|
return function executorExchangeFn({ forward }) {
|
|
64
67
|
return function executorExchangeIO(ops$) {
|
|
65
68
|
const sharedOps$ = (0, wonka_1.share)(ops$);
|
|
66
|
-
const executedOps$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)(operation => operation.kind === 'query' || operation.kind === 'mutation' || operation.kind === 'subscription'), (0, wonka_1.mergeMap)(operation => {
|
|
67
|
-
const teardown$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)(op => op.kind === 'teardown' && op.key === operation.key));
|
|
69
|
+
const executedOps$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)((operation) => operation.kind === 'query' || operation.kind === 'mutation' || operation.kind === 'subscription'), (0, wonka_1.mergeMap)((operation) => {
|
|
70
|
+
const teardown$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)((op) => op.kind === 'teardown' && op.key === operation.key));
|
|
68
71
|
return (0, wonka_1.pipe)(makeYogaSource(operation), (0, wonka_1.takeUntil)(teardown$));
|
|
69
72
|
}));
|
|
70
|
-
const forwardedOps$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)(operation => operation.kind === 'teardown'), forward);
|
|
73
|
+
const forwardedOps$ = (0, wonka_1.pipe)(sharedOps$, (0, wonka_1.filter)((operation) => operation.kind === 'teardown'), forward);
|
|
71
74
|
return (0, wonka_1.merge)([executedOps$, forwardedOps$]);
|
|
72
75
|
};
|
|
73
76
|
};
|
package/esm/index.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { pipe, share, filter, takeUntil, mergeMap, merge, make } from 'wonka';
|
|
2
|
-
import { makeResult, makeErrorResult, mergeResultPatch,
|
|
2
|
+
import { makeResult, makeErrorResult, mergeResultPatch, } from '@urql/core';
|
|
3
3
|
import { isAsyncIterable } from '@graphql-tools/utils';
|
|
4
4
|
export function executorExchange(executor) {
|
|
5
5
|
function makeYogaSource(operation) {
|
|
6
|
-
const operationName = getOperationName(operation.query);
|
|
7
6
|
const extraFetchOptions = typeof operation.context.fetchOptions === 'function'
|
|
8
7
|
? operation.context.fetchOptions()
|
|
9
8
|
: operation.context.fetchOptions;
|
|
10
9
|
const executionRequest = {
|
|
11
10
|
document: operation.query,
|
|
12
|
-
operationName,
|
|
13
11
|
operationType: operation.kind,
|
|
14
12
|
variables: operation.variables,
|
|
15
13
|
context: operation.context,
|
|
@@ -35,7 +33,12 @@ export function executorExchange(executor) {
|
|
|
35
33
|
let prevResult = null;
|
|
36
34
|
for await (const value of result) {
|
|
37
35
|
if (value) {
|
|
38
|
-
|
|
36
|
+
if (prevResult && value.incremental) {
|
|
37
|
+
prevResult = mergeResultPatch(prevResult, value);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
prevResult = makeResult(operation, value);
|
|
41
|
+
}
|
|
39
42
|
observer.next(prevResult);
|
|
40
43
|
}
|
|
41
44
|
if (ended) {
|
|
@@ -60,11 +63,11 @@ export function executorExchange(executor) {
|
|
|
60
63
|
return function executorExchangeFn({ forward }) {
|
|
61
64
|
return function executorExchangeIO(ops$) {
|
|
62
65
|
const sharedOps$ = share(ops$);
|
|
63
|
-
const executedOps$ = pipe(sharedOps$, filter(operation => operation.kind === 'query' || operation.kind === 'mutation' || operation.kind === 'subscription'), mergeMap(operation => {
|
|
64
|
-
const teardown$ = pipe(sharedOps$, filter(op => op.kind === 'teardown' && op.key === operation.key));
|
|
66
|
+
const executedOps$ = pipe(sharedOps$, filter((operation) => operation.kind === 'query' || operation.kind === 'mutation' || operation.kind === 'subscription'), mergeMap((operation) => {
|
|
67
|
+
const teardown$ = pipe(sharedOps$, filter((op) => op.kind === 'teardown' && op.key === operation.key));
|
|
65
68
|
return pipe(makeYogaSource(operation), takeUntil(teardown$));
|
|
66
69
|
}));
|
|
67
|
-
const forwardedOps$ = pipe(sharedOps$, filter(operation => operation.kind === 'teardown'), forward);
|
|
70
|
+
const forwardedOps$ = pipe(sharedOps$, filter((operation) => operation.kind === 'teardown'), forward);
|
|
68
71
|
return merge([executedOps$, forwardedOps$]);
|
|
69
72
|
};
|
|
70
73
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/executor-urql-exchange",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9-alpha-20230406062259-3c0a93c4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^15.2.0 || ^16.0.0",
|
|
7
|
-
"@urql/core": "^3.0.0",
|
|
7
|
+
"@urql/core": "^3.0.0 || ^4.0.0",
|
|
8
8
|
"wonka": "^6.0.0"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|