@apollo/client 3.6.0-beta.2 → 3.6.0-beta.6
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/apollo-client.cjs +323 -274
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +36 -35
- package/cache/cache.cjs.map +1 -1
- package/cache/inmemory/helpers.d.ts +1 -0
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +4 -3
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/key-extractor.js +7 -7
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +2 -1
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts +1 -1
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +9 -9
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +6 -6
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.js +13 -13
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.js +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +1 -1
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +8 -5
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +1 -1
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +12 -9
- package/core/core.cjs.map +1 -1
- package/errors/errors.cjs +2 -2
- package/errors/errors.cjs.map +1 -1
- package/errors/index.js +2 -2
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +27 -27
- package/link/batch/batch.cjs +48 -38
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batching.d.ts +2 -6
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +48 -38
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +1 -1
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batchHttpLink.js +2 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/http/createHttpLink.js +2 -2
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +24 -13
- package/link/http/http.cjs.map +1 -1
- package/link/http/index.d.ts +1 -1
- package/link/http/index.d.ts.map +1 -1
- package/link/http/index.js +1 -1
- package/link/http/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +3 -3
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/rewriteURIForGET.js +1 -1
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +5 -1
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +19 -8
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/subscriptions/index.d.ts +9 -0
- package/link/subscriptions/index.d.ts.map +1 -0
- package/link/subscriptions/index.js +39 -0
- package/link/subscriptions/index.js.map +1 -0
- package/link/subscriptions/package.json +8 -0
- package/link/subscriptions/subscriptions.cjs +45 -0
- package/link/subscriptions/subscriptions.cjs.map +1 -0
- package/link/utils/utils.cjs +1 -1
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/link/utils/validateOperation.js.map +1 -1
- package/package.json +22 -21
- package/react/hoc/hoc.cjs +5 -5
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/mutation-hoc.js +2 -2
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.js +1 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.js +1 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.js +1 -1
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +225 -191
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/useApolloClient.js +2 -2
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +20 -27
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +59 -68
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +137 -88
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +10 -8
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/parser/index.js +7 -7
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +7 -7
- package/react/parser/parser.cjs.map +1 -1
- package/react/ssr/RenderPromises.d.ts +2 -2
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js +7 -5
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/ssr.cjs +7 -5
- package/react/ssr/ssr.cjs.map +1 -1
- package/react/types/types.d.ts +1 -1
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +2 -2
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/mocking/mockFetch.js +1 -1
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.js +2 -2
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/observableToPromise.js +1 -1
- package/testing/core/observableToPromise.js.map +1 -1
- package/utilities/common/makeUniqueId.js +1 -1
- package/utilities/common/makeUniqueId.js.map +1 -1
- package/utilities/globals/global.d.ts +2 -8
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js +1 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.js +2 -2
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.js +5 -5
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/utilities.cjs +15 -15
- package/utilities/utilities.cjs.map +1 -1
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -13,7 +13,6 @@ var context = require('@wry/context');
|
|
|
13
13
|
var trie = require('@wry/trie');
|
|
14
14
|
var graphqlTag = require('graphql-tag');
|
|
15
15
|
var React = require('react');
|
|
16
|
-
var shim = require('use-sync-external-store/shim');
|
|
17
16
|
|
|
18
17
|
function _interopNamespace(e) {
|
|
19
18
|
if (e && e.__esModule) return e;
|
|
@@ -46,7 +45,7 @@ function shouldInclude(_a, variables) {
|
|
|
46
45
|
var evaledValue = false;
|
|
47
46
|
if (ifArgument.value.kind === 'Variable') {
|
|
48
47
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
49
|
-
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @"
|
|
48
|
+
__DEV__ ? tsInvariant.invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : tsInvariant.invariant(evaledValue !== void 0, 37);
|
|
50
49
|
}
|
|
51
50
|
else {
|
|
52
51
|
evaledValue = ifArgument.value.value;
|
|
@@ -83,12 +82,12 @@ function getInclusionDirectives(directives) {
|
|
|
83
82
|
return;
|
|
84
83
|
var directiveArguments = directive.arguments;
|
|
85
84
|
var directiveName = directive.name.value;
|
|
86
|
-
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @"
|
|
85
|
+
__DEV__ ? tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(directiveArguments && directiveArguments.length === 1, 38);
|
|
87
86
|
var ifArgument = directiveArguments[0];
|
|
88
|
-
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @"
|
|
87
|
+
__DEV__ ? tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : tsInvariant.invariant(ifArgument.name && ifArgument.name.value === 'if', 39);
|
|
89
88
|
var ifValue = ifArgument.value;
|
|
90
89
|
__DEV__ ? tsInvariant.invariant(ifValue &&
|
|
91
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @"
|
|
90
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : tsInvariant.invariant(ifValue &&
|
|
92
91
|
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 40);
|
|
93
92
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
94
93
|
});
|
|
@@ -101,7 +100,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
101
100
|
var fragments = [];
|
|
102
101
|
document.definitions.forEach(function (definition) {
|
|
103
102
|
if (definition.kind === 'OperationDefinition') {
|
|
104
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Found a "
|
|
103
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
|
|
105
104
|
'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new tsInvariant.InvariantError(41);
|
|
106
105
|
}
|
|
107
106
|
if (definition.kind === 'FragmentDefinition') {
|
|
@@ -109,7 +108,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
109
108
|
}
|
|
110
109
|
});
|
|
111
110
|
if (typeof actualFragmentName === 'undefined') {
|
|
112
|
-
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found "
|
|
111
|
+
__DEV__ ? tsInvariant.invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : tsInvariant.invariant(fragments.length === 1, 42);
|
|
113
112
|
actualFragmentName = fragments[0].name.value;
|
|
114
113
|
}
|
|
115
114
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -146,7 +145,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
146
145
|
return selection;
|
|
147
146
|
case 'FragmentSpread': {
|
|
148
147
|
var fragment = fragmentMap && fragmentMap[selection.name.value];
|
|
149
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named "
|
|
148
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(selection.name.value, ".")) : tsInvariant.invariant(fragment, 43);
|
|
150
149
|
return fragment;
|
|
151
150
|
}
|
|
152
151
|
default:
|
|
@@ -228,7 +227,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
228
227
|
argObj[name.value] = null;
|
|
229
228
|
}
|
|
230
229
|
else {
|
|
231
|
-
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \""
|
|
230
|
+
throw __DEV__ ? new tsInvariant.InvariantError("The inline argument \"".concat(name.value, "\" of kind \"").concat(value.kind, "\"") +
|
|
232
231
|
'is not supported. Use variables instead of inline arguments to ' +
|
|
233
232
|
'overcome this limitation.') : new tsInvariant.InvariantError(52);
|
|
234
233
|
}
|
|
@@ -280,7 +279,7 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
|
280
279
|
filterKeys.forEach(function (key) {
|
|
281
280
|
filteredArgs_1[key] = args[key];
|
|
282
281
|
});
|
|
283
|
-
return directives['connection']['key']
|
|
282
|
+
return "".concat(directives['connection']['key'], "(").concat(stringify(filteredArgs_1), ")");
|
|
284
283
|
}
|
|
285
284
|
else {
|
|
286
285
|
return directives['connection']['key'];
|
|
@@ -289,17 +288,17 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
|
289
288
|
var completeFieldName = fieldName;
|
|
290
289
|
if (args) {
|
|
291
290
|
var stringifiedArgs = stringify(args);
|
|
292
|
-
completeFieldName += "("
|
|
291
|
+
completeFieldName += "(".concat(stringifiedArgs, ")");
|
|
293
292
|
}
|
|
294
293
|
if (directives) {
|
|
295
294
|
Object.keys(directives).forEach(function (key) {
|
|
296
295
|
if (KNOWN_DIRECTIVES.indexOf(key) !== -1)
|
|
297
296
|
return;
|
|
298
297
|
if (directives[key] && Object.keys(directives[key]).length) {
|
|
299
|
-
completeFieldName += "@"
|
|
298
|
+
completeFieldName += "@".concat(key, "(").concat(stringify(directives[key]), ")");
|
|
300
299
|
}
|
|
301
300
|
else {
|
|
302
|
-
completeFieldName += "@"
|
|
301
|
+
completeFieldName += "@".concat(key);
|
|
303
302
|
}
|
|
304
303
|
});
|
|
305
304
|
}
|
|
@@ -369,11 +368,11 @@ function checkDocument(doc) {
|
|
|
369
368
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
370
369
|
.map(function (definition) {
|
|
371
370
|
if (definition.kind !== 'OperationDefinition') {
|
|
372
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \""
|
|
371
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Schema type definitions not allowed in queries. Found: \"".concat(definition.kind, "\"")) : new tsInvariant.InvariantError(45);
|
|
373
372
|
}
|
|
374
373
|
return definition;
|
|
375
374
|
});
|
|
376
|
-
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains "
|
|
375
|
+
__DEV__ ? tsInvariant.invariant(operations.length <= 1, "Ambiguous GraphQL document: contains ".concat(operations.length, " operations")) : tsInvariant.invariant(operations.length <= 1, 46);
|
|
377
376
|
return doc;
|
|
378
377
|
}
|
|
379
378
|
function getOperationDefinition(doc) {
|
|
@@ -1078,7 +1077,7 @@ var prefixCounts = new Map();
|
|
|
1078
1077
|
function makeUniqueId(prefix) {
|
|
1079
1078
|
var count = prefixCounts.get(prefix) || 1;
|
|
1080
1079
|
prefixCounts.set(prefix, count + 1);
|
|
1081
|
-
return prefix
|
|
1080
|
+
return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
|
|
1082
1081
|
}
|
|
1083
1082
|
|
|
1084
1083
|
function stringifyForDisplay(value) {
|
|
@@ -1143,7 +1142,7 @@ function validateOperation(operation) {
|
|
|
1143
1142
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1144
1143
|
var key = _a[_i];
|
|
1145
1144
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1146
|
-
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: "
|
|
1145
|
+
throw __DEV__ ? new tsInvariant.InvariantError("illegal argument: ".concat(key)) : new tsInvariant.InvariantError(24);
|
|
1147
1146
|
}
|
|
1148
1147
|
}
|
|
1149
1148
|
return operation;
|
|
@@ -1292,7 +1291,7 @@ var concat = ApolloLink.concat;
|
|
|
1292
1291
|
|
|
1293
1292
|
var execute = ApolloLink.execute;
|
|
1294
1293
|
|
|
1295
|
-
var version = '3.6.0-beta.
|
|
1294
|
+
var version = '3.6.0-beta.6';
|
|
1296
1295
|
|
|
1297
1296
|
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1298
1297
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -1313,14 +1312,14 @@ function parseAndCheckHttpResponse(operations) {
|
|
|
1313
1312
|
})
|
|
1314
1313
|
.then(function (result) {
|
|
1315
1314
|
if (response.status >= 300) {
|
|
1316
|
-
throwServerError(response, result, "Response not successful: Received status code "
|
|
1315
|
+
throwServerError(response, result, "Response not successful: Received status code ".concat(response.status));
|
|
1317
1316
|
}
|
|
1318
1317
|
if (!Array.isArray(result) &&
|
|
1319
1318
|
!hasOwnProperty$2.call(result, 'data') &&
|
|
1320
1319
|
!hasOwnProperty$2.call(result, 'errors')) {
|
|
1321
|
-
throwServerError(response, result, "Server response was missing for query '"
|
|
1320
|
+
throwServerError(response, result, "Server response was missing for query '".concat(Array.isArray(operations)
|
|
1322
1321
|
? operations.map(function (op) { return op.operationName; })
|
|
1323
|
-
: operations.operationName
|
|
1322
|
+
: operations.operationName, "'."));
|
|
1324
1323
|
}
|
|
1325
1324
|
return result;
|
|
1326
1325
|
}); };
|
|
@@ -1332,7 +1331,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
1332
1331
|
serialized = JSON.stringify(p);
|
|
1333
1332
|
}
|
|
1334
1333
|
catch (e) {
|
|
1335
|
-
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. "
|
|
1334
|
+
var parseError = __DEV__ ? new tsInvariant.InvariantError("Network request failed. ".concat(label, " is not serializable: ").concat(e.message)) : new tsInvariant.InvariantError(21);
|
|
1336
1335
|
parseError.parseError = e;
|
|
1337
1336
|
throw parseError;
|
|
1338
1337
|
}
|
|
@@ -1356,17 +1355,27 @@ var fallbackHttpConfig = {
|
|
|
1356
1355
|
options: defaultOptions,
|
|
1357
1356
|
};
|
|
1358
1357
|
var defaultPrinter = function (ast, printer) { return printer(ast); };
|
|
1359
|
-
|
|
1358
|
+
function selectHttpOptionsAndBody(operation, fallbackConfig) {
|
|
1360
1359
|
var configs = [];
|
|
1361
|
-
for (var _i =
|
|
1362
|
-
configs[_i -
|
|
1360
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1361
|
+
configs[_i - 2] = arguments[_i];
|
|
1363
1362
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1363
|
+
configs.unshift(fallbackConfig);
|
|
1364
|
+
return selectHttpOptionsAndBodyInternal.apply(void 0, tslib.__spreadArray([operation,
|
|
1365
|
+
defaultPrinter], configs, false));
|
|
1366
|
+
}
|
|
1367
|
+
function selectHttpOptionsAndBodyInternal(operation, printer) {
|
|
1368
|
+
var configs = [];
|
|
1369
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
1370
|
+
configs[_i - 2] = arguments[_i];
|
|
1371
|
+
}
|
|
1372
|
+
var options = {};
|
|
1373
|
+
var http = {};
|
|
1366
1374
|
configs.forEach(function (config) {
|
|
1367
1375
|
options = tslib.__assign(tslib.__assign(tslib.__assign({}, options), config.options), { headers: tslib.__assign(tslib.__assign({}, options.headers), headersToLowerCase(config.headers)) });
|
|
1368
|
-
if (config.credentials)
|
|
1376
|
+
if (config.credentials) {
|
|
1369
1377
|
options.credentials = config.credentials;
|
|
1378
|
+
}
|
|
1370
1379
|
http = tslib.__assign(tslib.__assign({}, http), config.http);
|
|
1371
1380
|
});
|
|
1372
1381
|
var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
|
|
@@ -1379,7 +1388,7 @@ var selectHttpOptionsAndBody = function (operation, printer, fallbackConfig) {
|
|
|
1379
1388
|
options: options,
|
|
1380
1389
|
body: body,
|
|
1381
1390
|
};
|
|
1382
|
-
}
|
|
1391
|
+
}
|
|
1383
1392
|
function headersToLowerCase(headers) {
|
|
1384
1393
|
if (headers) {
|
|
1385
1394
|
var normalized_1 = Object.create(null);
|
|
@@ -1422,7 +1431,7 @@ var selectURI = function (operation, fallbackURI) {
|
|
|
1422
1431
|
function rewriteURIForGET(chosenURI, body) {
|
|
1423
1432
|
var queryParams = [];
|
|
1424
1433
|
var addQueryParam = function (key, value) {
|
|
1425
|
-
queryParams.push(key
|
|
1434
|
+
queryParams.push("".concat(key, "=").concat(encodeURIComponent(value)));
|
|
1426
1435
|
};
|
|
1427
1436
|
if ('query' in body) {
|
|
1428
1437
|
addQueryParam('query', body.query);
|
|
@@ -1494,7 +1503,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
1494
1503
|
credentials: context.credentials,
|
|
1495
1504
|
headers: contextHeaders,
|
|
1496
1505
|
};
|
|
1497
|
-
var _b =
|
|
1506
|
+
var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
|
|
1498
1507
|
if (body.variables && !includeUnusedVariables) {
|
|
1499
1508
|
var unusedNames_1 = new Set(Object.keys(body.variables));
|
|
1500
1509
|
graphql.visit(operation.query, {
|
|
@@ -1687,7 +1696,7 @@ function defaultDataIdFromObject(_a, context) {
|
|
|
1687
1696
|
if (id === void 0)
|
|
1688
1697
|
id = _id;
|
|
1689
1698
|
if (id !== void 0) {
|
|
1690
|
-
return __typename
|
|
1699
|
+
return "".concat(__typename, ":").concat((typeof id === "number" ||
|
|
1691
1700
|
typeof id === "string") ? id : JSON.stringify(id));
|
|
1692
1701
|
}
|
|
1693
1702
|
}
|
|
@@ -1717,7 +1726,7 @@ function fieldNameFromStoreName(storeFieldName) {
|
|
|
1717
1726
|
}
|
|
1718
1727
|
function selectionSetMatchesResult(selectionSet, result, variables) {
|
|
1719
1728
|
if (isNonNullObject(result)) {
|
|
1720
|
-
return
|
|
1729
|
+
return isArray(result)
|
|
1721
1730
|
? result.every(function (item) { return selectionSetMatchesResult(selectionSet, item, variables); })
|
|
1722
1731
|
: selectionSet.selections.every(function (field) {
|
|
1723
1732
|
if (isField(field) && shouldInclude(field, variables)) {
|
|
@@ -1734,11 +1743,12 @@ function selectionSetMatchesResult(selectionSet, result, variables) {
|
|
|
1734
1743
|
function storeValueIsStoreObject(value) {
|
|
1735
1744
|
return isNonNullObject(value) &&
|
|
1736
1745
|
!isReference(value) &&
|
|
1737
|
-
!
|
|
1746
|
+
!isArray(value);
|
|
1738
1747
|
}
|
|
1739
1748
|
function makeProcessedFieldsMerger() {
|
|
1740
1749
|
return new DeepMerger;
|
|
1741
1750
|
}
|
|
1751
|
+
var isArray = function (a) { return Array.isArray(a); };
|
|
1742
1752
|
|
|
1743
1753
|
var DELETE = Object.create(null);
|
|
1744
1754
|
var delModifier = function () { return DELETE; };
|
|
@@ -2201,7 +2211,7 @@ function supportsResultCaching(store) {
|
|
|
2201
2211
|
|
|
2202
2212
|
function shallowCopy(value) {
|
|
2203
2213
|
if (isNonNullObject(value)) {
|
|
2204
|
-
return
|
|
2214
|
+
return isArray(value)
|
|
2205
2215
|
? value.slice(0)
|
|
2206
2216
|
: tslib.__assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
2207
2217
|
}
|
|
@@ -2423,7 +2433,7 @@ var StoreReader = (function () {
|
|
|
2423
2433
|
!context.store.has(objectOrReference.__ref)) {
|
|
2424
2434
|
return {
|
|
2425
2435
|
result: this.canon.empty,
|
|
2426
|
-
missing: "Dangling reference to missing "
|
|
2436
|
+
missing: "Dangling reference to missing ".concat(objectOrReference.__ref, " object"),
|
|
2427
2437
|
};
|
|
2428
2438
|
}
|
|
2429
2439
|
var variables = context.variables, policies = context.policies, store = context.store;
|
|
@@ -2458,13 +2468,13 @@ var StoreReader = (function () {
|
|
|
2458
2468
|
if (fieldValue === void 0) {
|
|
2459
2469
|
if (!addTypenameToDocument.added(selection)) {
|
|
2460
2470
|
missing = context.merge(missing, (_a = {},
|
|
2461
|
-
_a[resultName] = "Can't find field '"
|
|
2471
|
+
_a[resultName] = "Can't find field '".concat(selection.name.value, "' on ").concat(isReference(objectOrReference)
|
|
2462
2472
|
? objectOrReference.__ref + " object"
|
|
2463
2473
|
: "object " + JSON.stringify(objectOrReference, null, 2)),
|
|
2464
2474
|
_a));
|
|
2465
2475
|
}
|
|
2466
2476
|
}
|
|
2467
|
-
else if (
|
|
2477
|
+
else if (isArray(fieldValue)) {
|
|
2468
2478
|
fieldValue = handleMissing(_this.executeSubSelectedArray({
|
|
2469
2479
|
field: selection,
|
|
2470
2480
|
array: fieldValue,
|
|
@@ -2523,7 +2533,7 @@ var StoreReader = (function () {
|
|
|
2523
2533
|
if (item === null) {
|
|
2524
2534
|
return null;
|
|
2525
2535
|
}
|
|
2526
|
-
if (
|
|
2536
|
+
if (isArray(item)) {
|
|
2527
2537
|
return handleMissing(_this.executeSubSelectedArray({
|
|
2528
2538
|
field: field,
|
|
2529
2539
|
array: item,
|
|
@@ -2568,7 +2578,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
2568
2578
|
var workSet_1 = new Set([fieldValue]);
|
|
2569
2579
|
workSet_1.forEach(function (value) {
|
|
2570
2580
|
if (isNonNullObject(value)) {
|
|
2571
|
-
__DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type "
|
|
2581
|
+
__DEV__ ? tsInvariant.invariant(!isReference(value), "Missing selection set for object of type ".concat(getTypenameFromStoreObject(store, value), " returned for query field ").concat(field.name.value)) : tsInvariant.invariant(!isReference(value), 5);
|
|
2572
2582
|
Object.values(value).forEach(workSet_1.add, workSet_1);
|
|
2573
2583
|
}
|
|
2574
2584
|
});
|
|
@@ -2655,10 +2665,10 @@ function keyFieldsFnFromSpecifier(specifier) {
|
|
|
2655
2665
|
hasOwn.call(object, schemaKeyPath[0])) {
|
|
2656
2666
|
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
2657
2667
|
}
|
|
2658
|
-
__DEV__ ? tsInvariant.invariant(extracted !== void 0, "Missing field '"
|
|
2668
|
+
__DEV__ ? tsInvariant.invariant(extracted !== void 0, "Missing field '".concat(schemaKeyPath.join('.'), "' while extracting keyFields from ").concat(JSON.stringify(object))) : tsInvariant.invariant(extracted !== void 0, 2);
|
|
2659
2669
|
return extracted;
|
|
2660
2670
|
});
|
|
2661
|
-
return context.typename
|
|
2671
|
+
return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
|
|
2662
2672
|
});
|
|
2663
2673
|
}
|
|
2664
2674
|
function keyArgsFnFromSpecifier(specifier) {
|
|
@@ -2717,13 +2727,13 @@ function getSpecifierPaths(spec) {
|
|
|
2717
2727
|
var paths_1 = info.paths = [];
|
|
2718
2728
|
var currentPath_1 = [];
|
|
2719
2729
|
spec.forEach(function (s, i) {
|
|
2720
|
-
if (
|
|
2730
|
+
if (isArray(s)) {
|
|
2721
2731
|
getSpecifierPaths(s).forEach(function (p) { return paths_1.push(currentPath_1.concat(p)); });
|
|
2722
2732
|
currentPath_1.length = 0;
|
|
2723
2733
|
}
|
|
2724
2734
|
else {
|
|
2725
2735
|
currentPath_1.push(s);
|
|
2726
|
-
if (!
|
|
2736
|
+
if (!isArray(spec[i + 1])) {
|
|
2727
2737
|
paths_1.push(currentPath_1.slice(0));
|
|
2728
2738
|
currentPath_1.length = 0;
|
|
2729
2739
|
}
|
|
@@ -2738,14 +2748,14 @@ function extractKey(object, key) {
|
|
|
2738
2748
|
function extractKeyPath(object, path, extract) {
|
|
2739
2749
|
extract = extract || extractKey;
|
|
2740
2750
|
return normalize(path.reduce(function reducer(obj, key) {
|
|
2741
|
-
return
|
|
2751
|
+
return isArray(obj)
|
|
2742
2752
|
? obj.map(function (child) { return reducer(child, key); })
|
|
2743
2753
|
: obj && extract(obj, key);
|
|
2744
2754
|
}, object));
|
|
2745
2755
|
}
|
|
2746
2756
|
function normalize(value) {
|
|
2747
2757
|
if (isNonNullObject(value)) {
|
|
2748
|
-
if (
|
|
2758
|
+
if (isArray(value)) {
|
|
2749
2759
|
return value.map(normalize);
|
|
2750
2760
|
}
|
|
2751
2761
|
return collectSpecifierPaths(Object.keys(value).sort(), function (path) { return extractKeyPath(value, path); });
|
|
@@ -2808,7 +2818,7 @@ var Policies = (function () {
|
|
|
2808
2818
|
var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
|
|
2809
2819
|
while (keyFn) {
|
|
2810
2820
|
var specifierOrId = keyFn(object, context);
|
|
2811
|
-
if (
|
|
2821
|
+
if (isArray(specifierOrId)) {
|
|
2812
2822
|
keyFn = keyFieldsFnFromSpecifier(specifierOrId);
|
|
2813
2823
|
}
|
|
2814
2824
|
else {
|
|
@@ -2851,7 +2861,7 @@ var Policies = (function () {
|
|
|
2851
2861
|
setMerge(existing, incoming.merge);
|
|
2852
2862
|
existing.keyFn =
|
|
2853
2863
|
keyFields === false ? nullKeyFieldsFn :
|
|
2854
|
-
|
|
2864
|
+
isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields) :
|
|
2855
2865
|
typeof keyFields === "function" ? keyFields :
|
|
2856
2866
|
existing.keyFn;
|
|
2857
2867
|
if (fields) {
|
|
@@ -2865,7 +2875,7 @@ var Policies = (function () {
|
|
|
2865
2875
|
var keyArgs = incoming.keyArgs, read = incoming.read, merge = incoming.merge;
|
|
2866
2876
|
existing.keyFn =
|
|
2867
2877
|
keyArgs === false ? simpleKeyArgsFn :
|
|
2868
|
-
|
|
2878
|
+
isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) :
|
|
2869
2879
|
typeof keyArgs === "function" ? keyArgs :
|
|
2870
2880
|
existing.keyFn;
|
|
2871
2881
|
if (typeof read === "function") {
|
|
@@ -2884,7 +2894,7 @@ var Policies = (function () {
|
|
|
2884
2894
|
var rootId = "ROOT_" + which.toUpperCase();
|
|
2885
2895
|
var old = this.rootTypenamesById[rootId];
|
|
2886
2896
|
if (typename !== old) {
|
|
2887
|
-
__DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root "
|
|
2897
|
+
__DEV__ ? tsInvariant.invariant(!old || old === which, "Cannot change root ".concat(which, " __typename more than once")) : tsInvariant.invariant(!old || old === which, 3);
|
|
2888
2898
|
if (old)
|
|
2889
2899
|
delete this.rootIdsByTypename[old];
|
|
2890
2900
|
this.rootIdsByTypename[typename] = rootId;
|
|
@@ -2968,7 +2978,7 @@ var Policies = (function () {
|
|
|
2968
2978
|
if (supertypeSet.has(supertype)) {
|
|
2969
2979
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
2970
2980
|
if (checkingFuzzySubtypes) {
|
|
2971
|
-
__DEV__ && tsInvariant.invariant.warn("Inferring subtype "
|
|
2981
|
+
__DEV__ && tsInvariant.invariant.warn("Inferring subtype ".concat(typename, " of supertype ").concat(supertype));
|
|
2972
2982
|
}
|
|
2973
2983
|
typenameSupertypeSet.add(supertype);
|
|
2974
2984
|
}
|
|
@@ -3010,7 +3020,7 @@ var Policies = (function () {
|
|
|
3010
3020
|
var args = argsFromFieldSpecifier(fieldSpec);
|
|
3011
3021
|
while (keyFn) {
|
|
3012
3022
|
var specifierOrString = keyFn(args, context);
|
|
3013
|
-
if (
|
|
3023
|
+
if (isArray(specifierOrString)) {
|
|
3014
3024
|
keyFn = keyArgsFnFromSpecifier(specifierOrString);
|
|
3015
3025
|
}
|
|
3016
3026
|
else {
|
|
@@ -3122,7 +3132,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
3122
3132
|
}
|
|
3123
3133
|
}
|
|
3124
3134
|
if (__DEV__ && options.from === void 0) {
|
|
3125
|
-
__DEV__ && tsInvariant.invariant.warn("Undefined 'from' passed to readField with arguments "
|
|
3135
|
+
__DEV__ && tsInvariant.invariant.warn("Undefined 'from' passed to readField with arguments ".concat(stringifyForDisplay(Array.from(readFieldArgs))));
|
|
3126
3136
|
}
|
|
3127
3137
|
if (void 0 === options.variables) {
|
|
3128
3138
|
options.variables = variables;
|
|
@@ -3131,7 +3141,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
3131
3141
|
}
|
|
3132
3142
|
function makeMergeObjectsFunction(store) {
|
|
3133
3143
|
return function mergeObjects(existing, incoming) {
|
|
3134
|
-
if (
|
|
3144
|
+
if (isArray(existing) || isArray(incoming)) {
|
|
3135
3145
|
throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(4);
|
|
3136
3146
|
}
|
|
3137
3147
|
if (isNonNullObject(existing) &&
|
|
@@ -3162,7 +3172,7 @@ function makeMergeObjectsFunction(store) {
|
|
|
3162
3172
|
}
|
|
3163
3173
|
|
|
3164
3174
|
function getContextFlavor(context, clientOnly, deferred) {
|
|
3165
|
-
var key = ""
|
|
3175
|
+
var key = "".concat(clientOnly).concat(deferred);
|
|
3166
3176
|
var flavored = context.flavors.get(key);
|
|
3167
3177
|
if (!flavored) {
|
|
3168
3178
|
context.flavors.set(key, flavored = (context.clientOnly === clientOnly &&
|
|
@@ -3204,7 +3214,7 @@ var StoreWriter = (function () {
|
|
|
3204
3214
|
context: context,
|
|
3205
3215
|
});
|
|
3206
3216
|
if (!isReference(ref)) {
|
|
3207
|
-
throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object "
|
|
3217
|
+
throw __DEV__ ? new tsInvariant.InvariantError("Could not identify object ".concat(JSON.stringify(result))) : new tsInvariant.InvariantError(6);
|
|
3208
3218
|
}
|
|
3209
3219
|
context.incomingById.forEach(function (_a, dataId) {
|
|
3210
3220
|
var storeObject = _a.storeObject, mergeTree = _a.mergeTree, fieldNodeSet = _a.fieldNodeSet;
|
|
@@ -3309,7 +3319,7 @@ var StoreWriter = (function () {
|
|
|
3309
3319
|
!context.deferred &&
|
|
3310
3320
|
!addTypenameToDocument.added(field) &&
|
|
3311
3321
|
!policies.getReadFunction(typename, field.name.value)) {
|
|
3312
|
-
__DEV__ && tsInvariant.invariant.error(
|
|
3322
|
+
__DEV__ && tsInvariant.invariant.error("Missing field '".concat(resultKeyNameFromField(field), "' while writing result ").concat(JSON.stringify(result, null, 2)).substring(0, 1000));
|
|
3313
3323
|
}
|
|
3314
3324
|
});
|
|
3315
3325
|
try {
|
|
@@ -3360,7 +3370,7 @@ var StoreWriter = (function () {
|
|
|
3360
3370
|
if (!field.selectionSet || value === null) {
|
|
3361
3371
|
return __DEV__ ? cloneDeep(value) : value;
|
|
3362
3372
|
}
|
|
3363
|
-
if (
|
|
3373
|
+
if (isArray(value)) {
|
|
3364
3374
|
return value.map(function (item, i) {
|
|
3365
3375
|
var value = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
|
|
3366
3376
|
maybeRecycleChildMergeTree(mergeTree, i);
|
|
@@ -3425,7 +3435,7 @@ var StoreWriter = (function () {
|
|
|
3425
3435
|
var _a;
|
|
3426
3436
|
var _this = this;
|
|
3427
3437
|
if (mergeTree.map.size && !isReference(incoming)) {
|
|
3428
|
-
var e_1 = (!
|
|
3438
|
+
var e_1 = (!isArray(incoming) &&
|
|
3429
3439
|
(isReference(existing) || storeValueIsStoreObject(existing))) ? existing : void 0;
|
|
3430
3440
|
var i_1 = incoming;
|
|
3431
3441
|
if (e_1 && !getStorageArgs) {
|
|
@@ -3433,7 +3443,7 @@ var StoreWriter = (function () {
|
|
|
3433
3443
|
}
|
|
3434
3444
|
var changedFields_1;
|
|
3435
3445
|
var getValue_1 = function (from, name) {
|
|
3436
|
-
return
|
|
3446
|
+
return isArray(from)
|
|
3437
3447
|
? (typeof name === "number" ? from[name] : void 0)
|
|
3438
3448
|
: context.store.getFieldValue(from, String(name));
|
|
3439
3449
|
};
|
|
@@ -3455,7 +3465,7 @@ var StoreWriter = (function () {
|
|
|
3455
3465
|
}
|
|
3456
3466
|
});
|
|
3457
3467
|
if (changedFields_1) {
|
|
3458
|
-
incoming = (
|
|
3468
|
+
incoming = (isArray(i_1) ? i_1.slice(0) : tslib.__assign({}, i_1));
|
|
3459
3469
|
changedFields_1.forEach(function (value, name) {
|
|
3460
3470
|
incoming[name] = value;
|
|
3461
3471
|
});
|
|
@@ -3531,13 +3541,13 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
3531
3541
|
var parentType = store.getFieldValue(existingRef, "__typename") ||
|
|
3532
3542
|
store.getFieldValue(incomingObj, "__typename");
|
|
3533
3543
|
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
3534
|
-
var typeDotName = parentType
|
|
3544
|
+
var typeDotName = "".concat(parentType, ".").concat(fieldName);
|
|
3535
3545
|
if (warnings.has(typeDotName))
|
|
3536
3546
|
return;
|
|
3537
3547
|
warnings.add(typeDotName);
|
|
3538
3548
|
var childTypenames = [];
|
|
3539
|
-
if (!
|
|
3540
|
-
!
|
|
3549
|
+
if (!isArray(existing) &&
|
|
3550
|
+
!isArray(incoming)) {
|
|
3541
3551
|
[existing, incoming].forEach(function (child) {
|
|
3542
3552
|
var typename = store.getFieldValue(child, "__typename");
|
|
3543
3553
|
if (typeof typename === "string" &&
|
|
@@ -3546,10 +3556,10 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
3546
3556
|
}
|
|
3547
3557
|
});
|
|
3548
3558
|
}
|
|
3549
|
-
__DEV__ && tsInvariant.invariant.warn("Cache data may be lost when replacing the "
|
|
3559
|
+
__DEV__ && tsInvariant.invariant.warn("Cache data may be lost when replacing the ".concat(fieldName, " field of a ").concat(parentType, " object.\n\nTo address this problem (which is not a bug in Apollo Client), ").concat(childTypenames.length
|
|
3550
3560
|
? "either ensure all objects of type " +
|
|
3551
3561
|
childTypenames.join(" and ") + " have an ID or a custom merge function, or "
|
|
3552
|
-
: ""
|
|
3562
|
+
: "", "define a custom merge function for the ").concat(typeDotName, " field, so InMemoryCache can safely merge these objects:\n\n existing: ").concat(JSON.stringify(existing).slice(0, 1000), "\n incoming: ").concat(JSON.stringify(incoming).slice(0, 1000), "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n"));
|
|
3553
3563
|
}
|
|
3554
3564
|
|
|
3555
3565
|
var InMemoryCache = (function (_super) {
|
|
@@ -3856,11 +3866,11 @@ var generateErrorMessage = function (err) {
|
|
|
3856
3866
|
var errorMessage = error
|
|
3857
3867
|
? error.message
|
|
3858
3868
|
: 'Error message not found.';
|
|
3859
|
-
message += errorMessage
|
|
3869
|
+
message += "".concat(errorMessage, "\n");
|
|
3860
3870
|
});
|
|
3861
3871
|
}
|
|
3862
3872
|
if (err.networkError) {
|
|
3863
|
-
message += err.networkError.message
|
|
3873
|
+
message += "".concat(err.networkError.message, "\n");
|
|
3864
3874
|
}
|
|
3865
3875
|
message = message.replace(/\n$/, '');
|
|
3866
3876
|
return message;
|
|
@@ -4042,7 +4052,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4042
4052
|
pollInterval: 0,
|
|
4043
4053
|
};
|
|
4044
4054
|
var fetchPolicy = this.options.fetchPolicy;
|
|
4045
|
-
if (fetchPolicy === '
|
|
4055
|
+
if (fetchPolicy === 'cache-and-network') {
|
|
4046
4056
|
reobserveOptions.fetchPolicy = fetchPolicy;
|
|
4047
4057
|
}
|
|
4048
4058
|
else if (fetchPolicy === 'no-cache') {
|
|
@@ -4055,7 +4065,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4055
4065
|
var queryDef = getQueryDefinition(this.options.query);
|
|
4056
4066
|
var vars = queryDef.variableDefinitions;
|
|
4057
4067
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
4058
|
-
__DEV__ && tsInvariant.invariant.warn("Called refetch("
|
|
4068
|
+
__DEV__ && tsInvariant.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef), ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"));
|
|
4059
4069
|
}
|
|
4060
4070
|
}
|
|
4061
4071
|
if (variables && !equality.equal(this.options.variables, variables)) {
|
|
@@ -4282,8 +4292,11 @@ var ObservableQuery = (function (_super) {
|
|
|
4282
4292
|
this.reportResult(this.getCurrentResult(false), this.variables);
|
|
4283
4293
|
};
|
|
4284
4294
|
ObservableQuery.prototype.reportResult = function (result, variables) {
|
|
4285
|
-
|
|
4286
|
-
|
|
4295
|
+
var lastError = this.getLastError();
|
|
4296
|
+
if (lastError || this.isDifferentFromLastResult(result)) {
|
|
4297
|
+
if (lastError || !result.partial || this.options.returnPartialData) {
|
|
4298
|
+
this.updateLastResult(result, variables);
|
|
4299
|
+
}
|
|
4287
4300
|
iterateObserversSafely(this.observers, 'next', result);
|
|
4288
4301
|
}
|
|
4289
4302
|
};
|
|
@@ -4318,7 +4331,7 @@ function defaultSubscriptionObserverErrorCallback(error) {
|
|
|
4318
4331
|
}
|
|
4319
4332
|
function logMissingFieldErrors(missing) {
|
|
4320
4333
|
if (__DEV__ && missing) {
|
|
4321
|
-
__DEV__ && tsInvariant.invariant.debug("Missing cache result fields: "
|
|
4334
|
+
__DEV__ && tsInvariant.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
|
|
4322
4335
|
}
|
|
4323
4336
|
}
|
|
4324
4337
|
function applyNextFetchPolicy(options) {
|
|
@@ -4499,7 +4512,7 @@ var LocalState = (function () {
|
|
|
4499
4512
|
}
|
|
4500
4513
|
else {
|
|
4501
4514
|
fragment = fragmentMap[selection.name.value];
|
|
4502
|
-
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named "
|
|
4515
|
+
__DEV__ ? tsInvariant.invariant(fragment, "No fragment named ".concat(selection.name.value)) : tsInvariant.invariant(fragment, 9);
|
|
4503
4516
|
}
|
|
4504
4517
|
if (fragment && fragment.typeCondition) {
|
|
4505
4518
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -5290,7 +5303,7 @@ var QueryManager = (function () {
|
|
|
5290
5303
|
if (__DEV__ && queryNamesAndDocs.size) {
|
|
5291
5304
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
5292
5305
|
if (!included) {
|
|
5293
|
-
__DEV__ && tsInvariant.invariant.warn("Unknown query "
|
|
5306
|
+
__DEV__ && tsInvariant.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
|
|
5294
5307
|
}
|
|
5295
5308
|
});
|
|
5296
5309
|
}
|
|
@@ -5881,7 +5894,7 @@ var ApolloClient = (function () {
|
|
|
5881
5894
|
result.queries = queries;
|
|
5882
5895
|
result.results = results;
|
|
5883
5896
|
result.catch(function (error) {
|
|
5884
|
-
__DEV__ && tsInvariant.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error "
|
|
5897
|
+
__DEV__ && tsInvariant.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
|
|
5885
5898
|
});
|
|
5886
5899
|
return result;
|
|
5887
5900
|
};
|
|
@@ -5957,8 +5970,8 @@ function useApolloClient(override) {
|
|
|
5957
5970
|
var context = React.useContext(getApolloContext());
|
|
5958
5971
|
var client = override || context.client;
|
|
5959
5972
|
__DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
|
|
5960
|
-
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient' +
|
|
5961
|
-
'
|
|
5973
|
+
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
|
|
5974
|
+
'instance in via options.') : tsInvariant.invariant(!!client, 29);
|
|
5962
5975
|
return client;
|
|
5963
5976
|
}
|
|
5964
5977
|
|
|
@@ -5989,7 +6002,7 @@ function parser(document) {
|
|
|
5989
6002
|
if (cached)
|
|
5990
6003
|
return cached;
|
|
5991
6004
|
var variables, type, name;
|
|
5992
|
-
__DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of "
|
|
6005
|
+
__DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
|
|
5993
6006
|
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
5994
6007
|
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 30);
|
|
5995
6008
|
var fragments = document.definitions.filter(function (x) { return x.kind === 'FragmentDefinition'; });
|
|
@@ -6007,8 +6020,8 @@ function parser(document) {
|
|
|
6007
6020
|
"You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
|
|
6008
6021
|
(queries.length || mutations.length || subscriptions.length), 31);
|
|
6009
6022
|
__DEV__ ? tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, "react-apollo only supports a query, subscription, or a mutation per HOC. " +
|
|
6010
|
-
(document
|
|
6011
|
-
|
|
6023
|
+
"".concat(document, " had ").concat(queries.length, " queries, ").concat(subscriptions.length, " ") +
|
|
6024
|
+
"subscriptions and ".concat(mutations.length, " mutations. ") +
|
|
6012
6025
|
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(queries.length + mutations.length + subscriptions.length <= 1, 32);
|
|
6013
6026
|
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
6014
6027
|
if (!queries.length && !mutations.length)
|
|
@@ -6018,8 +6031,8 @@ function parser(document) {
|
|
|
6018
6031
|
: mutations.length
|
|
6019
6032
|
? mutations
|
|
6020
6033
|
: subscriptions;
|
|
6021
|
-
__DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. "
|
|
6022
|
-
(definitions.length
|
|
6034
|
+
__DEV__ ? tsInvariant.invariant(definitions.length === 1, "react-apollo only supports one definition per HOC. ".concat(document, " had ") +
|
|
6035
|
+
"".concat(definitions.length, " definitions. ") +
|
|
6023
6036
|
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 33);
|
|
6024
6037
|
var definition = definitions[0];
|
|
6025
6038
|
variables = definition.variableDefinitions || [];
|
|
@@ -6037,23 +6050,18 @@ function verifyDocumentType(document, type) {
|
|
|
6037
6050
|
var operation = parser(document);
|
|
6038
6051
|
var requiredOperationName = operationName(type);
|
|
6039
6052
|
var usedOperationName = operationName(operation.type);
|
|
6040
|
-
__DEV__ ? tsInvariant.invariant(operation.type === type, "Running a "
|
|
6041
|
-
(requiredOperationName
|
|
6053
|
+
__DEV__ ? tsInvariant.invariant(operation.type === type, "Running a ".concat(requiredOperationName, " requires a graphql ") +
|
|
6054
|
+
"".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type, 34);
|
|
6042
6055
|
}
|
|
6043
6056
|
|
|
6044
6057
|
function useQuery(query, options) {
|
|
6045
6058
|
var _a;
|
|
6046
6059
|
var context = React.useContext(getApolloContext());
|
|
6047
6060
|
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
6061
|
+
var defaultWatchQueryOptions = client.defaultOptions.watchQuery;
|
|
6048
6062
|
verifyDocumentType(query, exports.DocumentType.Query);
|
|
6049
|
-
var ref = React.useRef({
|
|
6050
|
-
client: client,
|
|
6051
|
-
query: query,
|
|
6052
|
-
options: options,
|
|
6053
|
-
watchQueryOptions: createWatchQueryOptions(query, options),
|
|
6054
|
-
});
|
|
6055
6063
|
var _b = React.useState(function () {
|
|
6056
|
-
var watchQueryOptions = createWatchQueryOptions(query, options);
|
|
6064
|
+
var watchQueryOptions = createWatchQueryOptions(query, options, defaultWatchQueryOptions);
|
|
6057
6065
|
var obsQuery = null;
|
|
6058
6066
|
if (context.renderPromises) {
|
|
6059
6067
|
obsQuery = context.renderPromises.getSSRObservable(watchQueryOptions);
|
|
@@ -6069,7 +6077,7 @@ function useQuery(query, options) {
|
|
|
6069
6077
|
!(options === null || options === void 0 ? void 0 : options.skip) &&
|
|
6070
6078
|
obsQuery.getCurrentResult().loading) {
|
|
6071
6079
|
context.renderPromises.addQueryPromise({
|
|
6072
|
-
getOptions: function () { return createWatchQueryOptions(query, options); },
|
|
6080
|
+
getOptions: function () { return createWatchQueryOptions(query, options, defaultWatchQueryOptions); },
|
|
6073
6081
|
fetchData: function () { return new Promise(function (resolve) {
|
|
6074
6082
|
var sub = obsQuery.subscribe({
|
|
6075
6083
|
next: function (result) {
|
|
@@ -6091,96 +6099,112 @@ function useQuery(query, options) {
|
|
|
6091
6099
|
}
|
|
6092
6100
|
return obsQuery;
|
|
6093
6101
|
}), obsQuery = _b[0], setObsQuery = _b[1];
|
|
6102
|
+
var _c = React.useState(function () {
|
|
6103
|
+
var _a, _b;
|
|
6104
|
+
var result = obsQuery.getCurrentResult();
|
|
6105
|
+
if (!result.loading && options) {
|
|
6106
|
+
if (result.error) {
|
|
6107
|
+
(_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, result.error);
|
|
6108
|
+
}
|
|
6109
|
+
else if (result.data) {
|
|
6110
|
+
(_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, result.data);
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
return result;
|
|
6114
|
+
}), result = _c[0], setResult = _c[1];
|
|
6115
|
+
var ref = React.useRef({
|
|
6116
|
+
client: client,
|
|
6117
|
+
query: query,
|
|
6118
|
+
options: options,
|
|
6119
|
+
result: result,
|
|
6120
|
+
previousData: void 0,
|
|
6121
|
+
watchQueryOptions: createWatchQueryOptions(query, options, defaultWatchQueryOptions),
|
|
6122
|
+
});
|
|
6094
6123
|
React.useEffect(function () {
|
|
6095
|
-
var
|
|
6124
|
+
var _a, _b;
|
|
6125
|
+
var watchQueryOptions = createWatchQueryOptions(query, options, defaultWatchQueryOptions);
|
|
6126
|
+
var nextResult;
|
|
6096
6127
|
if (ref.current.client !== client || !equality.equal(ref.current.query, query)) {
|
|
6097
6128
|
var obsQuery_1 = client.watchQuery(watchQueryOptions);
|
|
6098
6129
|
setObsQuery(obsQuery_1);
|
|
6130
|
+
nextResult = obsQuery_1.getCurrentResult();
|
|
6099
6131
|
}
|
|
6100
6132
|
else if (!equality.equal(ref.current.watchQueryOptions, watchQueryOptions)) {
|
|
6101
|
-
obsQuery.setOptions(watchQueryOptions);
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
var subscription = obsQuery.subscribe(forceUpdate, onError);
|
|
6115
|
-
function onError(error) {
|
|
6116
|
-
forceUpdate();
|
|
6117
|
-
subscription.unsubscribe();
|
|
6118
|
-
var last = obsQuery["last"];
|
|
6119
|
-
obsQuery.resetLastResults();
|
|
6120
|
-
obsQuery.subscribe(forceUpdate, onError);
|
|
6121
|
-
obsQuery["last"] = last;
|
|
6122
|
-
if (!error.hasOwnProperty('graphQLErrors')) {
|
|
6123
|
-
throw error;
|
|
6133
|
+
obsQuery.setOptions(watchQueryOptions).catch(function () { });
|
|
6134
|
+
nextResult = obsQuery.getCurrentResult();
|
|
6135
|
+
ref.current.watchQueryOptions = watchQueryOptions;
|
|
6136
|
+
}
|
|
6137
|
+
if (nextResult) {
|
|
6138
|
+
var previousResult = ref.current.result;
|
|
6139
|
+
if (previousResult.data) {
|
|
6140
|
+
ref.current.previousData = previousResult.data;
|
|
6141
|
+
}
|
|
6142
|
+
setResult(ref.current.result = nextResult);
|
|
6143
|
+
if (!nextResult.loading && options) {
|
|
6144
|
+
if (nextResult.error) {
|
|
6145
|
+
(_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, nextResult.error);
|
|
6124
6146
|
}
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
subscription.unsubscribe();
|
|
6128
|
-
};
|
|
6129
|
-
};
|
|
6130
|
-
var getSnapshot = function () {
|
|
6131
|
-
var result = obsQuery.getCurrentResult();
|
|
6132
|
-
if (result.errors && result.errors.length) {
|
|
6133
|
-
result = tslib.__assign(tslib.__assign({}, result), { error: result.error || new ApolloError({ graphQLErrors: result.errors }) });
|
|
6134
|
-
}
|
|
6135
|
-
if (!previousResult ||
|
|
6136
|
-
previousResult.loading !== result.loading ||
|
|
6137
|
-
previousResult.networkStatus !== result.networkStatus ||
|
|
6138
|
-
!equality.equal(previousResult.data, result.data) ||
|
|
6139
|
-
!equality.equal(previousResult.error, result.error)) {
|
|
6140
|
-
if (previousResult) {
|
|
6141
|
-
result = tslib.__assign(tslib.__assign({}, result), { previousData: previousResult.data || previousResult.previousData });
|
|
6147
|
+
else if (nextResult.data) {
|
|
6148
|
+
(_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, nextResult.data);
|
|
6142
6149
|
}
|
|
6143
|
-
previousResult = result;
|
|
6144
6150
|
}
|
|
6145
|
-
|
|
6146
|
-
};
|
|
6147
|
-
|
|
6148
|
-
}, [obsQuery]), subscribe = _c[0], getSnapshot = _c[1];
|
|
6149
|
-
var obsQueryMethods = React.useMemo(function () { return ({
|
|
6150
|
-
refetch: obsQuery.refetch.bind(obsQuery),
|
|
6151
|
-
fetchMore: obsQuery.fetchMore.bind(obsQuery),
|
|
6152
|
-
updateQuery: obsQuery.updateQuery.bind(obsQuery),
|
|
6153
|
-
startPolling: obsQuery.startPolling.bind(obsQuery),
|
|
6154
|
-
stopPolling: obsQuery.stopPolling.bind(obsQuery),
|
|
6155
|
-
subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
|
|
6156
|
-
}); }, [obsQuery]);
|
|
6157
|
-
var result = shim.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
6151
|
+
}
|
|
6152
|
+
Object.assign(ref.current, { client: client, query: query });
|
|
6153
|
+
}, [obsQuery, client, query, options]);
|
|
6158
6154
|
React.useEffect(function () {
|
|
6159
|
-
|
|
6160
|
-
if (((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip) ||
|
|
6161
|
-
((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) === 'standby') {
|
|
6155
|
+
if (context.renderPromises) {
|
|
6162
6156
|
return;
|
|
6163
6157
|
}
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6158
|
+
var subscription = obsQuery.subscribe(onNext, onError);
|
|
6159
|
+
function onNext() {
|
|
6160
|
+
var _a, _b;
|
|
6161
|
+
var previousResult = ref.current.result;
|
|
6162
|
+
var result = obsQuery.getCurrentResult();
|
|
6163
|
+
if (previousResult &&
|
|
6164
|
+
previousResult.loading === result.loading &&
|
|
6165
|
+
previousResult.networkStatus === result.networkStatus &&
|
|
6166
|
+
equality.equal(previousResult.data, result.data)) {
|
|
6167
|
+
return;
|
|
6167
6168
|
}
|
|
6168
|
-
|
|
6169
|
-
|
|
6169
|
+
if (previousResult.data) {
|
|
6170
|
+
ref.current.previousData = previousResult.data;
|
|
6171
|
+
}
|
|
6172
|
+
setResult(ref.current.result = result);
|
|
6173
|
+
if (!result.loading) {
|
|
6174
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onCompleted) === null || _b === void 0 ? void 0 : _b.call(_a, result.data);
|
|
6175
|
+
}
|
|
6176
|
+
}
|
|
6177
|
+
function onError(error) {
|
|
6178
|
+
var _a, _b;
|
|
6179
|
+
var last = obsQuery["last"];
|
|
6180
|
+
subscription.unsubscribe();
|
|
6181
|
+
try {
|
|
6182
|
+
obsQuery.resetLastResults();
|
|
6183
|
+
subscription = obsQuery.subscribe(onNext, onError);
|
|
6184
|
+
}
|
|
6185
|
+
finally {
|
|
6186
|
+
obsQuery["last"] = last;
|
|
6187
|
+
}
|
|
6188
|
+
if (!error.hasOwnProperty('graphQLErrors')) {
|
|
6189
|
+
throw error;
|
|
6190
|
+
}
|
|
6191
|
+
var previousResult = ref.current.result;
|
|
6192
|
+
if ((previousResult && previousResult.loading) ||
|
|
6193
|
+
!equality.equal(error, previousResult.error)) {
|
|
6194
|
+
setResult(ref.current.result = {
|
|
6195
|
+
data: previousResult.data,
|
|
6196
|
+
error: error,
|
|
6197
|
+
loading: false,
|
|
6198
|
+
networkStatus: exports.NetworkStatus.error,
|
|
6199
|
+
});
|
|
6200
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
6170
6201
|
}
|
|
6171
6202
|
}
|
|
6172
|
-
|
|
6203
|
+
return function () { return subscription.unsubscribe(); };
|
|
6204
|
+
}, [obsQuery, context.renderPromises, client.disableNetworkFetches]);
|
|
6173
6205
|
var partial;
|
|
6174
6206
|
(_a = result, partial = _a.partial, result = tslib.__rest(_a, ["partial"]));
|
|
6175
|
-
|
|
6176
|
-
result = {
|
|
6177
|
-
loading: false,
|
|
6178
|
-
data: void 0,
|
|
6179
|
-
error: void 0,
|
|
6180
|
-
networkStatus: exports.NetworkStatus.ready,
|
|
6181
|
-
};
|
|
6182
|
-
}
|
|
6183
|
-
else {
|
|
6207
|
+
{
|
|
6184
6208
|
if (partial &&
|
|
6185
6209
|
(options === null || options === void 0 ? void 0 : options.partialRefetch) &&
|
|
6186
6210
|
!result.loading &&
|
|
@@ -6189,17 +6213,52 @@ function useQuery(query, options) {
|
|
|
6189
6213
|
result = tslib.__assign(tslib.__assign({}, result), { loading: true, networkStatus: exports.NetworkStatus.refetch });
|
|
6190
6214
|
obsQuery.refetch();
|
|
6191
6215
|
}
|
|
6192
|
-
if (context.renderPromises &&
|
|
6193
|
-
|
|
6194
|
-
|
|
6216
|
+
if (context.renderPromises &&
|
|
6217
|
+
(options === null || options === void 0 ? void 0 : options.ssr) !== false &&
|
|
6218
|
+
!(options === null || options === void 0 ? void 0 : options.skip) &&
|
|
6219
|
+
result.loading) {
|
|
6220
|
+
obsQuery.setOptions(createWatchQueryOptions(query, options, defaultWatchQueryOptions)).catch(function () { });
|
|
6195
6221
|
}
|
|
6222
|
+
Object.assign(ref.current, { options: options });
|
|
6196
6223
|
}
|
|
6197
|
-
|
|
6224
|
+
if ((context.renderPromises || client.disableNetworkFetches) &&
|
|
6225
|
+
(options === null || options === void 0 ? void 0 : options.ssr) === false) {
|
|
6226
|
+
result = ref.current.result = {
|
|
6227
|
+
loading: true,
|
|
6228
|
+
data: void 0,
|
|
6229
|
+
error: void 0,
|
|
6230
|
+
networkStatus: exports.NetworkStatus.loading,
|
|
6231
|
+
};
|
|
6232
|
+
}
|
|
6233
|
+
else if ((options === null || options === void 0 ? void 0 : options.skip) || (options === null || options === void 0 ? void 0 : options.fetchPolicy) === 'standby') {
|
|
6234
|
+
result = {
|
|
6235
|
+
loading: false,
|
|
6236
|
+
data: void 0,
|
|
6237
|
+
error: void 0,
|
|
6238
|
+
networkStatus: exports.NetworkStatus.ready,
|
|
6239
|
+
};
|
|
6240
|
+
}
|
|
6241
|
+
if (result.errors && result.errors.length) {
|
|
6242
|
+
result = tslib.__assign(tslib.__assign({}, result), { error: result.error || new ApolloError({ graphQLErrors: result.errors }) });
|
|
6243
|
+
}
|
|
6244
|
+
var obsQueryFields = React.useMemo(function () { return ({
|
|
6245
|
+
refetch: obsQuery.refetch.bind(obsQuery),
|
|
6246
|
+
fetchMore: obsQuery.fetchMore.bind(obsQuery),
|
|
6247
|
+
updateQuery: obsQuery.updateQuery.bind(obsQuery),
|
|
6248
|
+
startPolling: obsQuery.startPolling.bind(obsQuery),
|
|
6249
|
+
stopPolling: obsQuery.stopPolling.bind(obsQuery),
|
|
6250
|
+
subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
|
|
6251
|
+
}); }, [obsQuery]);
|
|
6252
|
+
return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: createWatchQueryOptions(query, options, defaultWatchQueryOptions).variables, client: client, called: true, previousData: ref.current.previousData }), result);
|
|
6198
6253
|
}
|
|
6199
|
-
function createWatchQueryOptions(query, options) {
|
|
6254
|
+
function createWatchQueryOptions(query, options, defaultOptions) {
|
|
6200
6255
|
var _a;
|
|
6201
6256
|
if (options === void 0) { options = {}; }
|
|
6202
|
-
var skip = options.skip; options.ssr; options.onCompleted; options.onError; options.displayName; var
|
|
6257
|
+
var skip = options.skip; options.ssr; options.onCompleted; options.onError; options.displayName; var otherOptions = tslib.__rest(options, ["skip", "ssr", "onCompleted", "onError", "displayName"]);
|
|
6258
|
+
var watchQueryOptions = tslib.__assign({ query: query }, otherOptions);
|
|
6259
|
+
if (defaultOptions) {
|
|
6260
|
+
watchQueryOptions = mergeOptions(defaultOptions, watchQueryOptions);
|
|
6261
|
+
}
|
|
6203
6262
|
if (skip) {
|
|
6204
6263
|
watchQueryOptions.fetchPolicy = 'standby';
|
|
6205
6264
|
}
|
|
@@ -6211,7 +6270,10 @@ function createWatchQueryOptions(query, options) {
|
|
|
6211
6270
|
else if (!watchQueryOptions.fetchPolicy) {
|
|
6212
6271
|
watchQueryOptions.fetchPolicy = 'cache-first';
|
|
6213
6272
|
}
|
|
6214
|
-
|
|
6273
|
+
if (!watchQueryOptions.variables) {
|
|
6274
|
+
watchQueryOptions.variables = {};
|
|
6275
|
+
}
|
|
6276
|
+
return watchQueryOptions;
|
|
6215
6277
|
}
|
|
6216
6278
|
|
|
6217
6279
|
var EAGER_METHODS = [
|
|
@@ -6224,36 +6286,16 @@ var EAGER_METHODS = [
|
|
|
6224
6286
|
function useLazyQuery(query, options) {
|
|
6225
6287
|
var _a = React.useState({
|
|
6226
6288
|
called: false,
|
|
6227
|
-
resolves: [],
|
|
6228
6289
|
}), execution = _a[0], setExecution = _a[1];
|
|
6229
|
-
var execute = React.useCallback(function (executeOptions) {
|
|
6230
|
-
var resolve;
|
|
6231
|
-
var promise = new Promise(function (resolve1) { return (resolve = resolve1); });
|
|
6232
|
-
setExecution(function (execution) {
|
|
6233
|
-
if (execution.called) {
|
|
6234
|
-
result && result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables);
|
|
6235
|
-
}
|
|
6236
|
-
return {
|
|
6237
|
-
called: true,
|
|
6238
|
-
resolves: tslib.__spreadArray(tslib.__spreadArray([], execution.resolves, true), [resolve], false),
|
|
6239
|
-
options: executeOptions,
|
|
6240
|
-
};
|
|
6241
|
-
});
|
|
6242
|
-
return promise;
|
|
6243
|
-
}, []);
|
|
6244
6290
|
var result = useQuery(query, tslib.__assign(tslib.__assign(tslib.__assign({}, options), execution.options), { fetchPolicy: execution.called ? options === null || options === void 0 ? void 0 : options.fetchPolicy : 'standby', skip: undefined }));
|
|
6245
|
-
React.useEffect(function () {
|
|
6246
|
-
var resolves = execution.resolves;
|
|
6247
|
-
if (!result.loading && resolves.length) {
|
|
6248
|
-
setExecution(function (execution) { return (tslib.__assign(tslib.__assign({}, execution), { resolves: [] })); });
|
|
6249
|
-
resolves.forEach(function (resolve) { return resolve(result); });
|
|
6250
|
-
}
|
|
6251
|
-
}, [result, execution]);
|
|
6252
6291
|
if (!execution.called) {
|
|
6253
6292
|
result = tslib.__assign(tslib.__assign({}, result), { loading: false, data: void 0, error: void 0, called: false });
|
|
6293
|
+
}
|
|
6294
|
+
var eagerMethods = React.useMemo(function () {
|
|
6295
|
+
var eagerMethods = {};
|
|
6254
6296
|
var _loop_1 = function (key) {
|
|
6255
6297
|
var method = result[key];
|
|
6256
|
-
|
|
6298
|
+
eagerMethods[key] = function () {
|
|
6257
6299
|
var args = [];
|
|
6258
6300
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6259
6301
|
args[_i] = arguments[_i];
|
|
@@ -6266,7 +6308,20 @@ function useLazyQuery(query, options) {
|
|
|
6266
6308
|
var key = EAGER_METHODS_1[_i];
|
|
6267
6309
|
_loop_1(key);
|
|
6268
6310
|
}
|
|
6269
|
-
|
|
6311
|
+
return eagerMethods;
|
|
6312
|
+
}, []);
|
|
6313
|
+
result.error = result.error || void 0;
|
|
6314
|
+
Object.assign(result, eagerMethods);
|
|
6315
|
+
var execute = React.useCallback(function (executeOptions) {
|
|
6316
|
+
setExecution({ called: true, options: executeOptions });
|
|
6317
|
+
var promise = result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables).then(function (result1) {
|
|
6318
|
+
var result2 = tslib.__assign(tslib.__assign({}, result), { data: result1.data, error: result1.error, called: true, loading: false });
|
|
6319
|
+
Object.assign(result2, eagerMethods);
|
|
6320
|
+
return result2;
|
|
6321
|
+
});
|
|
6322
|
+
promise.catch(function () { });
|
|
6323
|
+
return promise;
|
|
6324
|
+
}, []);
|
|
6270
6325
|
return [execute, result];
|
|
6271
6326
|
}
|
|
6272
6327
|
|
|
@@ -6282,82 +6337,73 @@ function useMutation(mutation, options) {
|
|
|
6282
6337
|
result: result,
|
|
6283
6338
|
mutationId: 0,
|
|
6284
6339
|
isMounted: true,
|
|
6285
|
-
execute: null,
|
|
6286
6340
|
client: client,
|
|
6287
6341
|
mutation: mutation,
|
|
6288
6342
|
options: options,
|
|
6289
6343
|
});
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
}
|
|
6297
|
-
ref.current.
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6344
|
+
{
|
|
6345
|
+
Object.assign(ref.current, { client: client, options: options, mutation: mutation });
|
|
6346
|
+
}
|
|
6347
|
+
var execute = React.useCallback(function (executeOptions) {
|
|
6348
|
+
if (executeOptions === void 0) { executeOptions = {}; }
|
|
6349
|
+
var _a = ref.current, client = _a.client, options = _a.options, mutation = _a.mutation;
|
|
6350
|
+
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
6351
|
+
if (!ref.current.result.loading && !baseOptions.ignoreResults) {
|
|
6352
|
+
setResult(ref.current.result = {
|
|
6353
|
+
loading: true,
|
|
6354
|
+
error: void 0,
|
|
6355
|
+
data: void 0,
|
|
6356
|
+
called: true,
|
|
6357
|
+
client: client,
|
|
6358
|
+
});
|
|
6359
|
+
}
|
|
6360
|
+
var mutationId = ++ref.current.mutationId;
|
|
6361
|
+
var clientOptions = mergeOptions(baseOptions, executeOptions);
|
|
6362
|
+
return client.mutate(clientOptions).then(function (response) {
|
|
6363
|
+
var _a, _b;
|
|
6364
|
+
var data = response.data, errors = response.errors;
|
|
6365
|
+
var error = errors && errors.length > 0
|
|
6366
|
+
? new ApolloError({ graphQLErrors: errors })
|
|
6367
|
+
: void 0;
|
|
6368
|
+
if (mutationId === ref.current.mutationId &&
|
|
6369
|
+
!clientOptions.ignoreResults) {
|
|
6370
|
+
var result_1 = {
|
|
6308
6371
|
called: true,
|
|
6372
|
+
loading: false,
|
|
6373
|
+
data: data,
|
|
6374
|
+
error: error,
|
|
6309
6375
|
client: client,
|
|
6310
|
-
}
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
var clientOptions = mergeOptions(baseOptions, executeOptions);
|
|
6314
|
-
return client.mutate(clientOptions).then(function (response) {
|
|
6315
|
-
var _a, _b;
|
|
6316
|
-
var data = response.data, errors = response.errors;
|
|
6317
|
-
var error = errors && errors.length > 0
|
|
6318
|
-
? new ApolloError({ graphQLErrors: errors })
|
|
6319
|
-
: void 0;
|
|
6320
|
-
if (mutationId === ref.current.mutationId &&
|
|
6321
|
-
!clientOptions.ignoreResults) {
|
|
6322
|
-
var result_1 = {
|
|
6323
|
-
called: true,
|
|
6324
|
-
loading: false,
|
|
6325
|
-
data: data,
|
|
6326
|
-
error: error,
|
|
6327
|
-
client: client,
|
|
6328
|
-
};
|
|
6329
|
-
if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
|
|
6330
|
-
setResult(ref.current.result = result_1);
|
|
6331
|
-
}
|
|
6332
|
-
}
|
|
6333
|
-
(_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
|
|
6334
|
-
(_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
|
|
6335
|
-
return response;
|
|
6336
|
-
}).catch(function (error) {
|
|
6337
|
-
var _a, _b;
|
|
6338
|
-
if (mutationId === ref.current.mutationId &&
|
|
6339
|
-
ref.current.isMounted) {
|
|
6340
|
-
var result_2 = {
|
|
6341
|
-
loading: false,
|
|
6342
|
-
error: error,
|
|
6343
|
-
data: void 0,
|
|
6344
|
-
called: true,
|
|
6345
|
-
client: client,
|
|
6346
|
-
};
|
|
6347
|
-
if (!equality.equal(ref.current.result, result_2)) {
|
|
6348
|
-
setResult(ref.current.result = result_2);
|
|
6349
|
-
}
|
|
6376
|
+
};
|
|
6377
|
+
if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
|
|
6378
|
+
setResult(ref.current.result = result_1);
|
|
6350
6379
|
}
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6380
|
+
}
|
|
6381
|
+
(_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
|
|
6382
|
+
(_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
|
|
6383
|
+
return response;
|
|
6384
|
+
}).catch(function (error) {
|
|
6385
|
+
var _a, _b;
|
|
6386
|
+
if (mutationId === ref.current.mutationId &&
|
|
6387
|
+
ref.current.isMounted) {
|
|
6388
|
+
var result_2 = {
|
|
6389
|
+
loading: false,
|
|
6390
|
+
error: error,
|
|
6391
|
+
data: void 0,
|
|
6392
|
+
called: true,
|
|
6393
|
+
client: client,
|
|
6394
|
+
};
|
|
6395
|
+
if (!equality.equal(ref.current.result, result_2)) {
|
|
6396
|
+
setResult(ref.current.result = result_2);
|
|
6355
6397
|
}
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6398
|
+
}
|
|
6399
|
+
if (baseOptions.onError || clientOptions.onError) {
|
|
6400
|
+
(_a = baseOptions.onError) === null || _a === void 0 ? void 0 : _a.call(baseOptions, error);
|
|
6401
|
+
(_b = executeOptions.onError) === null || _b === void 0 ? void 0 : _b.call(executeOptions, error);
|
|
6402
|
+
return { data: void 0, errors: error };
|
|
6403
|
+
}
|
|
6404
|
+
throw error;
|
|
6405
|
+
});
|
|
6406
|
+
}, []);
|
|
6361
6407
|
var reset = React.useCallback(function () {
|
|
6362
6408
|
setResult({ called: false, loading: false, client: client });
|
|
6363
6409
|
}, []);
|
|
@@ -6394,14 +6440,16 @@ function useSubscription(subscription, options) {
|
|
|
6394
6440
|
if (typeof shouldResubscribe === 'function') {
|
|
6395
6441
|
shouldResubscribe = !!shouldResubscribe(options);
|
|
6396
6442
|
}
|
|
6397
|
-
if (
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6443
|
+
if (options === null || options === void 0 ? void 0 : options.skip) {
|
|
6444
|
+
if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
|
|
6445
|
+
setResult({
|
|
6446
|
+
loading: false,
|
|
6447
|
+
data: void 0,
|
|
6448
|
+
error: void 0,
|
|
6449
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
6450
|
+
});
|
|
6451
|
+
setObservable(null);
|
|
6452
|
+
}
|
|
6405
6453
|
}
|
|
6406
6454
|
else if (shouldResubscribe !== false && (client !== ref.current.client ||
|
|
6407
6455
|
subscription !== ref.current.subscription ||
|
|
@@ -6519,6 +6567,7 @@ exports.parser = parser;
|
|
|
6519
6567
|
exports.resetApolloContext = getApolloContext;
|
|
6520
6568
|
exports.rewriteURIForGET = rewriteURIForGET;
|
|
6521
6569
|
exports.selectHttpOptionsAndBody = selectHttpOptionsAndBody;
|
|
6570
|
+
exports.selectHttpOptionsAndBodyInternal = selectHttpOptionsAndBodyInternal;
|
|
6522
6571
|
exports.selectURI = selectURI;
|
|
6523
6572
|
exports.serializeFetchParameter = serializeFetchParameter;
|
|
6524
6573
|
exports.split = split;
|