@apollo/client 3.7.0-beta.6 → 3.7.0-beta.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/README.md +2 -0
- package/apollo-client.cjs +385 -78
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +15 -11
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +15 -11
- package/cache/core/types/common.d.ts +1 -1
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js +16 -11
- package/cache/core/types/common.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +24 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +15 -4
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +43 -8
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +43 -8
- package/core/types.d.ts.map +1 -1
- package/core/types.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/link/core/types.d.ts +30 -5
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js +0 -1
- package/link/core/types.js.map +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +14 -17
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +314 -44
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +314 -44
- package/link/http/iterators/async.d.ts +2 -0
- package/link/http/iterators/async.d.ts.map +1 -0
- package/link/http/iterators/async.js +14 -0
- package/link/http/iterators/async.js.map +1 -0
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.d.ts.map +1 -0
- package/link/http/iterators/nodeStream.js +71 -0
- package/link/http/iterators/nodeStream.js.map +1 -0
- package/link/http/iterators/promise.d.ts +2 -0
- package/link/http/iterators/promise.d.ts.map +1 -0
- package/link/http/iterators/promise.js +28 -0
- package/link/http/iterators/promise.js.map +1 -0
- package/link/http/iterators/reader.d.ts +2 -0
- package/link/http/iterators/reader.d.ts.map +1 -0
- package/link/http/iterators/reader.js +15 -0
- package/link/http/iterators/reader.js.map +1 -0
- package/link/http/parseAndCheckHttpResponse.d.ts +7 -1
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +131 -27
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts +3 -0
- package/link/http/responseIterator.d.ts.map +1 -0
- package/link/http/responseIterator.js +23 -0
- package/link/http/responseIterator.js.map +1 -0
- package/package.json +38 -27
- package/react/hooks/hooks.cjs +15 -10
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +15 -10
- package/react/hooks/useFragment.d.ts +1 -1
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js +6 -3
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +8 -6
- package/react/hooks/useMutation.js.map +1 -1
- package/react/types/types.d.ts +2 -2
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/itAsync.d.ts +3 -3
- package/testing/core/itAsync.d.ts.map +1 -1
- package/testing/core/subscribeAndCount.d.ts +2 -3
- package/testing/core/subscribeAndCount.d.ts.map +1 -1
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/utilities/common/canUse.d.ts +1 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +1 -0
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +3 -0
- package/utilities/common/incrementalResult.d.ts.map +1 -0
- package/utilities/common/incrementalResult.js +4 -0
- package/utilities/common/incrementalResult.js.map +1 -0
- package/utilities/common/responseIterator.d.ts +10 -0
- package/utilities/common/responseIterator.d.ts.map +1 -0
- package/utilities/common/responseIterator.js +21 -0
- package/utilities/common/responseIterator.js.map +1 -0
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +11 -2
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +1 -1
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/utilities.cjs +12 -1
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +12 -1
- package/version.js +1 -1
|
@@ -1,33 +1,137 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { responseIterator } from "./responseIterator.js";
|
|
1
3
|
import { throwServerError } from "../utils/index.js";
|
|
2
4
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
3
|
-
export function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
export function readMultipartBody(response, observer) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
8
|
+
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _d, value, done, chunk, bi, message, i, headers, contentType_1, body, result;
|
|
9
|
+
var _e;
|
|
10
|
+
return __generator(this, function (_f) {
|
|
11
|
+
switch (_f.label) {
|
|
12
|
+
case 0:
|
|
13
|
+
if (TextDecoder === undefined) {
|
|
14
|
+
throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
|
|
15
|
+
}
|
|
16
|
+
decoder = new TextDecoder("utf-8");
|
|
17
|
+
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get('content-type');
|
|
18
|
+
delimiter = "boundary=";
|
|
19
|
+
boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter))
|
|
20
|
+
? contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
|
|
21
|
+
: "-";
|
|
22
|
+
boundary = "--".concat(boundaryVal);
|
|
23
|
+
buffer = "";
|
|
24
|
+
iterator = responseIterator(response);
|
|
25
|
+
running = true;
|
|
26
|
+
_f.label = 1;
|
|
27
|
+
case 1:
|
|
28
|
+
if (!running) return [3, 3];
|
|
29
|
+
return [4, iterator.next()];
|
|
30
|
+
case 2:
|
|
31
|
+
_d = _f.sent(), value = _d.value, done = _d.done;
|
|
32
|
+
chunk = typeof value === "string" ? value : decoder.decode(value);
|
|
33
|
+
running = !done;
|
|
34
|
+
buffer += chunk;
|
|
35
|
+
bi = buffer.indexOf(boundary);
|
|
36
|
+
while (bi > -1) {
|
|
37
|
+
message = void 0;
|
|
38
|
+
_e = [
|
|
39
|
+
buffer.slice(0, bi),
|
|
40
|
+
buffer.slice(bi + boundary.length),
|
|
41
|
+
], message = _e[0], buffer = _e[1];
|
|
42
|
+
if (message.trim()) {
|
|
43
|
+
i = message.indexOf("\r\n\r\n");
|
|
44
|
+
headers = parseHeaders(message.slice(0, i));
|
|
45
|
+
contentType_1 = headers["content-type"];
|
|
46
|
+
if (contentType_1 &&
|
|
47
|
+
contentType_1.toLowerCase().indexOf("application/json") === -1) {
|
|
48
|
+
throw new Error("Unsupported patch content type: application/json is required.");
|
|
49
|
+
}
|
|
50
|
+
body = message.slice(i);
|
|
51
|
+
try {
|
|
52
|
+
result = parseJsonBody(response, body.replace("\r\n", ""));
|
|
53
|
+
if (Object.keys(result).length > 1 ||
|
|
54
|
+
"data" in result ||
|
|
55
|
+
"incremental" in result ||
|
|
56
|
+
"errors" in result) {
|
|
57
|
+
(_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, result);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
handleError(err, observer);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
bi = buffer.indexOf(boundary);
|
|
65
|
+
}
|
|
66
|
+
return [3, 1];
|
|
67
|
+
case 3:
|
|
68
|
+
(_c = observer.complete) === null || _c === void 0 ? void 0 : _c.call(observer);
|
|
69
|
+
return [2];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
export function parseHeaders(headerText) {
|
|
75
|
+
var headersInit = {};
|
|
76
|
+
headerText.split("\n").forEach(function (line) {
|
|
77
|
+
var i = line.indexOf(":");
|
|
78
|
+
if (i > -1) {
|
|
79
|
+
var name_1 = line.slice(0, i).trim().toLowerCase();
|
|
80
|
+
var value = line.slice(i + 1).trim();
|
|
81
|
+
headersInit[name_1] = value;
|
|
17
82
|
}
|
|
18
|
-
})
|
|
83
|
+
});
|
|
84
|
+
return headersInit;
|
|
85
|
+
}
|
|
86
|
+
export function parseJsonBody(response, bodyText) {
|
|
87
|
+
try {
|
|
88
|
+
return JSON.parse(bodyText);
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
var parseError = err;
|
|
92
|
+
parseError.name = "ServerParseError";
|
|
93
|
+
parseError.response = response;
|
|
94
|
+
parseError.statusCode = response.status;
|
|
95
|
+
parseError.bodyText = bodyText;
|
|
96
|
+
throw parseError;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export function handleError(err, observer) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
if (err.name === "AbortError")
|
|
102
|
+
return;
|
|
103
|
+
if (err.result && err.result.errors && err.result.data) {
|
|
104
|
+
(_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, err.result);
|
|
105
|
+
}
|
|
106
|
+
(_b = observer.error) === null || _b === void 0 ? void 0 : _b.call(observer, err);
|
|
107
|
+
}
|
|
108
|
+
export function readJsonBody(response, operation, observer) {
|
|
109
|
+
parseAndCheckHttpResponse(operation)(response)
|
|
19
110
|
.then(function (result) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
111
|
+
var _a, _b;
|
|
112
|
+
(_a = observer.next) === null || _a === void 0 ? void 0 : _a.call(observer, result);
|
|
113
|
+
(_b = observer.complete) === null || _b === void 0 ? void 0 : _b.call(observer);
|
|
114
|
+
})
|
|
115
|
+
.catch(function (err) { return handleError(err, observer); });
|
|
116
|
+
}
|
|
117
|
+
export function parseAndCheckHttpResponse(operations) {
|
|
118
|
+
return function (response) {
|
|
119
|
+
return response
|
|
120
|
+
.text()
|
|
121
|
+
.then(function (bodyText) { return parseJsonBody(response, bodyText); })
|
|
122
|
+
.then(function (result) {
|
|
123
|
+
if (response.status >= 300) {
|
|
124
|
+
throwServerError(response, result, "Response not successful: Received status code ".concat(response.status));
|
|
125
|
+
}
|
|
126
|
+
if (!Array.isArray(result) &&
|
|
127
|
+
!hasOwnProperty.call(result, "data") &&
|
|
128
|
+
!hasOwnProperty.call(result, "errors")) {
|
|
129
|
+
throwServerError(response, result, "Server response was missing for query '".concat(Array.isArray(operations)
|
|
130
|
+
? operations.map(function (op) { return op.operationName; })
|
|
131
|
+
: operations.operationName, "'."));
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
});
|
|
135
|
+
};
|
|
32
136
|
}
|
|
33
137
|
//# sourceMappingURL=parseAndCheckHttpResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseAndCheckHttpResponse.js","sourceRoot":"","sources":["../../../src/link/http/parseAndCheckHttpResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEpC,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAQ5C,MAA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Property } = Object.prototype;\n\nexport type ServerParseError = Error & {\n response: Response;\n statusCode: number;\n bodyText: string;\n};\n\nexport function parseAndCheckHttpResponse(\n operations: Operation | Operation[],\n) {\n return (response: Response) => response\n .text()\n .then(bodyText => {\n try {\n return JSON.parse(bodyText);\n } catch (err) {\n const parseError = err as ServerParseError;\n parseError.name = 'ServerParseError';\n parseError.response = response;\n parseError.statusCode = response.status;\n parseError.bodyText = bodyText;\n throw parseError;\n }\n })\n .then((result: any) => {\n if (response.status >= 300) {\n // Network error\n throwServerError(\n response,\n result,\n `Response not successful: Received status code ${response.status}`,\n );\n }\n\n if (\n !Array.isArray(result) &&\n !hasOwnProperty.call(result, 'data') &&\n !hasOwnProperty.call(result, 'errors')\n ) {\n // Data error\n throwServerError(\n response,\n result,\n `Server response was missing for query '${\n Array.isArray(operations)\n ? operations.map(op => op.operationName)\n : operations.operationName\n }'.`,\n );\n }\n return result;\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parseAndCheckHttpResponse.js","sourceRoot":"","sources":["../../../src/link/http/parseAndCheckHttpResponse.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGpC,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAQ5C,MAAM,UAAgB,iBAAiB,CACrC,QAAkB,EAClB,QAAqB;;;;;;;;oBAErB,IAAI,WAAW,KAAK,SAAS,EAAE;wBAC7B,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;qBACH;oBACK,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;oBACnC,WAAW,GAAG,MAAA,QAAQ,CAAC,OAAO,0CAAE,GAAG,CAAC,cAAc,CAAC,CAAC;oBACpD,SAAS,GAAG,WAAW,CAAC;oBAMxB,WAAW,GAAG,CAAA,WAAW,aAAX,WAAW,uBAAX,WAA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C,CAAC;QACxB,MAAA,QAAQ,CAAC,QAAQ,wDAAI,CAAC;IACxB,CAAC,CAAC;SACD,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,EAA1B,CAA0B,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,UAAmC;IAC3E,OAAO,UAAC,QAAkB;QACxB,OAAA,QAAQ;aACL,IAAI,EAAE;aACN,IAAI,CAAC,UAAC,QAAQ,IAAK,OAAA,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAjC,CAAiC,CAAC;aACrD,IAAI,CAAC,UAAC,MAAW;YAChB,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;gBAE1B,gBAAgB,CACd,QAAQ,EACR,MAAM,EACN,wDAAiD,QAAQ,CAAC,MAAM,CAAE,CACnE,CAAC;aACH;YACD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;gBACtB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;gBACpC,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EACtC;gBAEA,gBAAgB,CACd,QAAQ,EACR,MAAM,EACN,iDACE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;oBACvB,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,aAAa,EAAhB,CAAgB,CAAC;oBAC1C,CAAC,CAAC,UAAU,CAAC,aAAa,OAC1B,CACL,CAAC;aACH;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IA7BJ,CA6BI,CAAC;AACT,CAAC","sourcesContent":["import { responseIterator } from \"./responseIterator\";\nimport { Operation } from \"../core\";\nimport { throwServerError } from \"../utils\";\nimport { Observer } from \"../../utilities\";\n\nconst { hasOwnProperty } = Object.prototype;\n\nexport type ServerParseError = Error & {\n response: Response;\n statusCode: number;\n bodyText: string;\n};\n\nexport async function readMultipartBody<T = Record<string, unknown>>(\n response: Response,\n observer: Observer<T>\n) {\n if (TextDecoder === undefined) {\n throw new Error(\n \"TextDecoder must be defined in the environment: please import a polyfill.\"\n );\n }\n const decoder = new TextDecoder(\"utf-8\");\n const contentType = response.headers?.get('content-type');\n const delimiter = \"boundary=\";\n\n // parse boundary value and ignore any subsequent name/value pairs after ;\n // https://www.rfc-editor.org/rfc/rfc9110.html#name-parameters\n // e.g. multipart/mixed;boundary=\"graphql\";deferSpec=20220824\n // if no boundary is specified, default to -\n const boundaryVal = contentType?.includes(delimiter)\n ? contentType\n ?.substring(contentType?.indexOf(delimiter) + delimiter.length)\n .replace(/['\"]/g, \"\")\n .replace(/\\;(.*)/gm, \"\")\n .trim()\n : \"-\";\n\n let boundary = `--${boundaryVal}`;\n let buffer = \"\";\n const iterator = responseIterator(response);\n let running = true;\n\n while (running) {\n const { value, done } = await iterator.next();\n const chunk = typeof value === \"string\" ? value : decoder.decode(value);\n running = !done;\n buffer += chunk;\n let bi = buffer.indexOf(boundary);\n\n while (bi > -1) {\n let message: string;\n [message, buffer] = [\n buffer.slice(0, bi),\n buffer.slice(bi + boundary.length),\n ];\n if (message.trim()) {\n const i = message.indexOf(\"\\r\\n\\r\\n\");\n const headers = parseHeaders(message.slice(0, i));\n const contentType = headers[\"content-type\"];\n if (\n contentType &&\n contentType.toLowerCase().indexOf(\"application/json\") === -1\n ) {\n throw new Error(\"Unsupported patch content type: application/json is required.\");\n }\n const body = message.slice(i);\n\n try {\n const result = parseJsonBody<T>(response, body.replace(\"\\r\\n\", \"\"));\n if (\n Object.keys(result).length > 1 ||\n \"data\" in result ||\n \"incremental\" in result ||\n \"errors\" in result\n ) {\n // for the last chunk with only `hasNext: false`,\n // we don't need to call observer.next as there is no data/errors\n observer.next?.(result);\n }\n } catch (err) {\n handleError(err, observer);\n }\n }\n bi = buffer.indexOf(boundary);\n }\n }\n observer.complete?.();\n}\n\nexport function parseHeaders(headerText: string): Record<string, string> {\n const headersInit: Record<string, string> = {};\n headerText.split(\"\\n\").forEach((line) => {\n const i = line.indexOf(\":\");\n if (i > -1) {\n // normalize headers to lowercase\n const name = line.slice(0, i).trim().toLowerCase();\n const value = line.slice(i + 1).trim();\n headersInit[name] = value;\n }\n });\n return headersInit;\n}\n\nexport function parseJsonBody<T>(response: Response, bodyText: string): T {\n try {\n return JSON.parse(bodyText) as T;\n } catch (err) {\n const parseError = err as ServerParseError;\n parseError.name = \"ServerParseError\";\n parseError.response = response;\n parseError.statusCode = response.status;\n parseError.bodyText = bodyText;\n throw parseError;\n }\n}\n\nexport function handleError(err: any, observer: Observer<any>) {\n if (err.name === \"AbortError\") return;\n // if it is a network error, BUT there is graphql result info fire\n // the next observer before calling error this gives apollo-client\n // (and react-apollo) the `graphqlErrors` and `networErrors` to\n // pass to UI this should only happen if we *also* have data as\n // part of the response key per the spec\n if (err.result && err.result.errors && err.result.data) {\n // if we don't call next, the UI can only show networkError\n // because AC didn't get any graphqlErrors this is graphql\n // execution result info (i.e errors and possibly data) this is\n // because there is no formal spec how errors should translate to\n // http status codes. So an auth error (401) could have both data\n // from a public field, errors from a private field, and a status\n // of 401\n // {\n // user { // this will have errors\n // firstName\n // }\n // products { // this is public so will have data\n // cost\n // }\n // }\n //\n // the result of above *could* look like this:\n // {\n // data: { products: [{ cost: \"$10\" }] },\n // errors: [{\n // message: 'your session has timed out',\n // path: []\n // }]\n // }\n // status code of above would be a 401\n // in the UI you want to show data where you can, errors as data where you can\n // and use correct http status codes\n observer.next?.(err.result);\n }\n\n observer.error?.(err);\n}\n\nexport function readJsonBody<T = Record<string, unknown>>(\n response: Response,\n operation: Operation,\n observer: Observer<T>\n) {\n parseAndCheckHttpResponse(operation)(response)\n .then((result) => {\n observer.next?.(result);\n observer.complete?.();\n })\n .catch((err) => handleError(err, observer));\n}\n\nexport function parseAndCheckHttpResponse(operations: Operation | Operation[]) {\n return (response: Response) =>\n response\n .text()\n .then((bodyText) => parseJsonBody(response, bodyText))\n .then((result: any) => {\n if (response.status >= 300) {\n // Network error\n throwServerError(\n response,\n result,\n `Response not successful: Received status code ${response.status}`\n );\n }\n if (\n !Array.isArray(result) &&\n !hasOwnProperty.call(result, \"data\") &&\n !hasOwnProperty.call(result, \"errors\")\n ) {\n // Data error\n throwServerError(\n response,\n result,\n `Server response was missing for query '${\n Array.isArray(operations)\n ? operations.map((op) => op.operationName)\n : operations.operationName\n }'.`\n );\n }\n return result;\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseIterator.d.ts","sourceRoot":"","sources":["../../../src/link/http/responseIterator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AAetD,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,QAAQ,EAAE,QAAQ,GAAG,YAAY,GAChC,qBAAqB,CAAC,CAAC,CAAC,CAwB1B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isAsyncIterableIterator, isBlob, isNodeResponse, isNodeReadableStream, isReadableStream, isStreamableBlob, } from "../../utilities/common/responseIterator.js";
|
|
2
|
+
import asyncIterator from "./iterators/async.js";
|
|
3
|
+
import nodeStreamIterator from "./iterators/nodeStream.js";
|
|
4
|
+
import promiseIterator from "./iterators/promise.js";
|
|
5
|
+
import readerIterator from "./iterators/reader.js";
|
|
6
|
+
export function responseIterator(response) {
|
|
7
|
+
var body = response;
|
|
8
|
+
if (isNodeResponse(response))
|
|
9
|
+
body = response.body;
|
|
10
|
+
if (isAsyncIterableIterator(body))
|
|
11
|
+
return asyncIterator(body);
|
|
12
|
+
if (isReadableStream(body))
|
|
13
|
+
return readerIterator(body.getReader());
|
|
14
|
+
if (isStreamableBlob(body)) {
|
|
15
|
+
return readerIterator(body.stream().getReader());
|
|
16
|
+
}
|
|
17
|
+
if (isBlob(body))
|
|
18
|
+
return promiseIterator(body.arrayBuffer());
|
|
19
|
+
if (isNodeReadableStream(body))
|
|
20
|
+
return nodeStreamIterator(body);
|
|
21
|
+
throw new Error("Unknown body type for responseIterator. Please pass a streamable response.");
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=responseIterator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseIterator.js","sourceRoot":"","sources":["../../../src/link/http/responseIterator.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,aAAa,MAAM,mBAAmB,CAAC;AAC9C,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AACxD,OAAO,eAAe,MAAM,qBAAqB,CAAC;AAClD,OAAO,cAAc,MAAM,oBAAoB,CAAC;AAEhD,MAAM,UAAU,gBAAgB,CAC9B,QAAiC;IAEjC,IAAI,IAAI,GAAY,QAAQ,CAAC;IAE7B,IAAI,cAAc,CAAC,QAAQ,CAAC;QAAE,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAEnD,IAAI,uBAAuB,CAAC,IAAI,CAAC;QAAE,OAAO,aAAa,CAAI,IAAI,CAAC,CAAC;IAEjE,IAAI,gBAAgB,CAAC,IAAI,CAAC;QAAE,OAAO,cAAc,CAAI,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IAIvE,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE;QAC1B,OAAO,cAAc,CAClB,IAAI,CAAC,MAAM,EAAmC,CAAC,SAAS,EAAE,CAC5D,CAAC;KACH;IAED,IAAI,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,eAAe,CAAI,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAEhE,IAAI,oBAAoB,CAAC,IAAI,CAAC;QAAE,OAAO,kBAAkB,CAAI,IAAI,CAAC,CAAC;IAEnE,MAAM,IAAI,KAAK,CACb,4EAA4E,CAC7E,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Original source:\n * https://github.com/kmalakoff/response-iterator/blob/master/src/index.ts\n */\n\nimport { Response as NodeResponse } from \"node-fetch\";\nimport {\n isAsyncIterableIterator,\n isBlob,\n isNodeResponse,\n isNodeReadableStream,\n isReadableStream,\n isStreamableBlob,\n} from \"../../utilities/common/responseIterator\";\n\nimport asyncIterator from \"./iterators/async\";\nimport nodeStreamIterator from \"./iterators/nodeStream\";\nimport promiseIterator from \"./iterators/promise\";\nimport readerIterator from \"./iterators/reader\";\n\nexport function responseIterator<T>(\n response: Response | NodeResponse\n): AsyncIterableIterator<T> {\n let body: unknown = response;\n\n if (isNodeResponse(response)) body = response.body;\n\n if (isAsyncIterableIterator(body)) return asyncIterator<T>(body);\n\n if (isReadableStream(body)) return readerIterator<T>(body.getReader());\n\n // this errors without casting to ReadableStream<T>\n // because Blob.stream() returns a NodeJS ReadableStream\n if (isStreamableBlob(body)) {\n return readerIterator<T>(\n (body.stream() as unknown as ReadableStream<T>).getReader()\n );\n }\n\n if (isBlob(body)) return promiseIterator<T>(body.arrayBuffer());\n\n if (isNodeReadableStream(body)) return nodeStreamIterator<T>(body);\n\n throw new Error(\n \"Unknown body type for responseIterator. Please pass a streamable response.\"\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apollo/client",
|
|
3
|
-
"version": "3.7.0-beta.
|
|
3
|
+
"version": "3.7.0-beta.7",
|
|
4
4
|
"description": "A fully-featured caching GraphQL client.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
33
33
|
"graphql-ws": "^5.5.5",
|
|
34
34
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
35
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
35
36
|
"subscriptions-transport-ws": "^0.9.0 || ^0.11.0"
|
|
36
37
|
},
|
|
37
38
|
"peerDependenciesMeta": {
|
|
@@ -41,67 +42,77 @@
|
|
|
41
42
|
"react": {
|
|
42
43
|
"optional": true
|
|
43
44
|
},
|
|
45
|
+
"react-dom": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
44
48
|
"subscriptions-transport-ws": {
|
|
45
49
|
"optional": true
|
|
46
50
|
}
|
|
47
51
|
},
|
|
48
52
|
"dependencies": {
|
|
49
53
|
"@graphql-typed-document-node/core": "^3.1.1",
|
|
50
|
-
"@wry/context": "^0.
|
|
54
|
+
"@wry/context": "^0.7.0",
|
|
51
55
|
"@wry/equality": "^0.5.0",
|
|
52
56
|
"@wry/trie": "^0.3.0",
|
|
53
57
|
"graphql-tag": "^2.12.6",
|
|
54
58
|
"hoist-non-react-statics": "^3.3.2",
|
|
55
59
|
"optimism": "^0.16.1",
|
|
56
60
|
"prop-types": "^15.7.2",
|
|
61
|
+
"response-iterator": "^0.2.6",
|
|
57
62
|
"symbol-observable": "^4.0.0",
|
|
58
63
|
"ts-invariant": "^0.10.3",
|
|
59
64
|
"tslib": "^2.3.0",
|
|
60
65
|
"zen-observable-ts": "^1.2.5"
|
|
61
66
|
},
|
|
62
67
|
"devDependencies": {
|
|
63
|
-
"@babel/parser": "7.18.
|
|
64
|
-
"@graphql-tools/schema": "8.
|
|
68
|
+
"@babel/parser": "7.18.13",
|
|
69
|
+
"@graphql-tools/schema": "8.5.0",
|
|
65
70
|
"@rollup/plugin-node-resolve": "11.2.1",
|
|
66
|
-
"@testing-library/react": "
|
|
71
|
+
"@testing-library/react": "13.4.0",
|
|
72
|
+
"@testing-library/react-12": "npm:@testing-library/react@^12",
|
|
67
73
|
"@testing-library/react-hooks": "8.0.1",
|
|
68
|
-
"@testing-library/user-event": "14.
|
|
74
|
+
"@testing-library/user-event": "14.4.3",
|
|
69
75
|
"@types/fast-json-stable-stringify": "2.0.0",
|
|
70
76
|
"@types/fetch-mock": "7.3.5",
|
|
71
77
|
"@types/glob": "7.2.0",
|
|
72
78
|
"@types/hoist-non-react-statics": "3.3.1",
|
|
73
|
-
"@types/jest": "
|
|
74
|
-
"@types/lodash": "4.14.
|
|
75
|
-
"@types/node": "16.11.
|
|
76
|
-
"@types/
|
|
77
|
-
"@types/react
|
|
78
|
-
"@types/
|
|
79
|
+
"@types/jest": "28.1.8",
|
|
80
|
+
"@types/lodash": "4.14.184",
|
|
81
|
+
"@types/node": "16.11.45",
|
|
82
|
+
"@types/node-fetch": "2.6.2",
|
|
83
|
+
"@types/react": "18.0.18",
|
|
84
|
+
"@types/react-dom": "18.0.6",
|
|
85
|
+
"@types/use-sync-external-store": "0.0.3",
|
|
79
86
|
"acorn": "8.7.1",
|
|
87
|
+
"blob-polyfill": "7.0.20220408",
|
|
80
88
|
"bundlesize": "0.18.1",
|
|
81
89
|
"cross-fetch": "3.1.5",
|
|
82
|
-
"crypto-hash": "1.3.0",
|
|
83
90
|
"fetch-mock": "9.11.0",
|
|
84
91
|
"glob": "8.0.3",
|
|
85
|
-
"graphql": "16.
|
|
86
|
-
"graphql-ws": "5.
|
|
87
|
-
"jest": "
|
|
88
|
-
"jest-
|
|
89
|
-
"jest-junit": "
|
|
92
|
+
"graphql": "16.6.0",
|
|
93
|
+
"graphql-ws": "5.10.1",
|
|
94
|
+
"jest": "28.1.3",
|
|
95
|
+
"jest-environment-jsdom": "28.1.3",
|
|
96
|
+
"jest-junit": "14.0.1",
|
|
90
97
|
"lodash": "4.17.21",
|
|
91
|
-
"react": "
|
|
92
|
-
"react-
|
|
93
|
-
"
|
|
98
|
+
"react": "18.2.0",
|
|
99
|
+
"react-17": "npm:react@^17",
|
|
100
|
+
"react-dom": "18.2.0",
|
|
101
|
+
"react-dom-17": "npm:react-dom@^17",
|
|
102
|
+
"recast": "0.21.2",
|
|
94
103
|
"resolve": "1.22.1",
|
|
95
104
|
"rimraf": "3.0.2",
|
|
96
|
-
"rollup": "2.
|
|
105
|
+
"rollup": "2.79.0",
|
|
97
106
|
"rollup-plugin-terser": "7.0.2",
|
|
98
|
-
"rxjs": "7.5.
|
|
107
|
+
"rxjs": "7.5.6",
|
|
99
108
|
"subscriptions-transport-ws": "0.11.0",
|
|
100
|
-
"terser": "5.
|
|
101
|
-
"ts-jest": "
|
|
102
|
-
"ts-node": "10.
|
|
103
|
-
"
|
|
109
|
+
"terser": "5.15.0",
|
|
110
|
+
"ts-jest": "28.0.8",
|
|
111
|
+
"ts-node": "10.9.1",
|
|
112
|
+
"typedoc": "0.22.18",
|
|
113
|
+
"typescript": "4.7.4",
|
|
104
114
|
"wait-for-observables": "1.0.3",
|
|
115
|
+
"web-streams-polyfill": "3.2.1",
|
|
105
116
|
"whatwg-fetch": "3.6.2"
|
|
106
117
|
},
|
|
107
118
|
"publishConfig": {
|
package/react/hooks/hooks.cjs
CHANGED
|
@@ -429,7 +429,7 @@ function useMutation(mutation, options) {
|
|
|
429
429
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
430
430
|
var _a = ref.current, client = _a.client, options = _a.options, mutation = _a.mutation;
|
|
431
431
|
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
432
|
-
if (!ref.current.result.loading && !baseOptions.ignoreResults) {
|
|
432
|
+
if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {
|
|
433
433
|
setResult(ref.current.result = {
|
|
434
434
|
loading: true,
|
|
435
435
|
error: void 0,
|
|
@@ -459,8 +459,8 @@ function useMutation(mutation, options) {
|
|
|
459
459
|
setResult(ref.current.result = result_1);
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
|
-
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, response.data);
|
|
463
|
-
(_c = executeOptions.onCompleted) === null || _c === void 0 ? void 0 : _c.call(executeOptions, response.data);
|
|
462
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, response.data, clientOptions);
|
|
463
|
+
(_c = executeOptions.onCompleted) === null || _c === void 0 ? void 0 : _c.call(executeOptions, response.data, clientOptions);
|
|
464
464
|
return response;
|
|
465
465
|
}).catch(function (error) {
|
|
466
466
|
var _a, _b, _c, _d;
|
|
@@ -478,15 +478,17 @@ function useMutation(mutation, options) {
|
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
if (((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) || clientOptions.onError) {
|
|
481
|
-
(_c = (_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onError) === null || _c === void 0 ? void 0 : _c.call(_b, error);
|
|
482
|
-
(_d = executeOptions.onError) === null || _d === void 0 ? void 0 : _d.call(executeOptions, error);
|
|
481
|
+
(_c = (_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onError) === null || _c === void 0 ? void 0 : _c.call(_b, error, clientOptions);
|
|
482
|
+
(_d = executeOptions.onError) === null || _d === void 0 ? void 0 : _d.call(executeOptions, error, clientOptions);
|
|
483
483
|
return { data: void 0, errors: error };
|
|
484
484
|
}
|
|
485
485
|
throw error;
|
|
486
486
|
});
|
|
487
487
|
}, []);
|
|
488
488
|
var reset = React.useCallback(function () {
|
|
489
|
-
|
|
489
|
+
if (ref.current.isMounted) {
|
|
490
|
+
setResult({ called: false, loading: false, client: client });
|
|
491
|
+
}
|
|
490
492
|
}, []);
|
|
491
493
|
React.useEffect(function () {
|
|
492
494
|
ref.current.isMounted = true;
|
|
@@ -619,7 +621,7 @@ function useReactiveVar(rv) {
|
|
|
619
621
|
return value;
|
|
620
622
|
}
|
|
621
623
|
|
|
622
|
-
function
|
|
624
|
+
function useFragment_experimental(options) {
|
|
623
625
|
var cache = useApolloClient().cache;
|
|
624
626
|
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
625
627
|
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
@@ -635,8 +637,11 @@ function useFragment(options) {
|
|
|
635
637
|
immediate = false;
|
|
636
638
|
} }));
|
|
637
639
|
}, function () {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
+
var latestDiffToResult = diffToResult(latestDiff);
|
|
641
|
+
return resultRef.current &&
|
|
642
|
+
equality.equal(resultRef.current.data, latestDiffToResult.data)
|
|
643
|
+
? resultRef.current
|
|
644
|
+
: (resultRef.current = latestDiffToResult);
|
|
640
645
|
});
|
|
641
646
|
}
|
|
642
647
|
function diffToResult(diff) {
|
|
@@ -651,7 +656,7 @@ function diffToResult(diff) {
|
|
|
651
656
|
}
|
|
652
657
|
|
|
653
658
|
exports.useApolloClient = useApolloClient;
|
|
654
|
-
exports.
|
|
659
|
+
exports.useFragment_experimental = useFragment_experimental;
|
|
655
660
|
exports.useLazyQuery = useLazyQuery;
|
|
656
661
|
exports.useMutation = useMutation;
|
|
657
662
|
exports.useQuery = useQuery;
|