@apollo/client 4.0.0-alpha.20 → 4.0.0-alpha.21
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/CHANGELOG.md +10 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +10 -10
- package/__cjs/core/ObservableQuery.cjs +15 -11
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -2
- package/__cjs/core/QueryInfo.cjs +223 -34
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +34 -24
- package/__cjs/core/QueryManager.cjs +75 -256
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +4 -36
- package/__cjs/core/networkStatus.cjs +7 -1
- package/__cjs/core/networkStatus.cjs.map +1 -1
- package/__cjs/core/networkStatus.d.cts +7 -1
- package/__cjs/invariantErrorCodes.cjs +64 -69
- package/__cjs/link/core/ApolloLink.cjs +2 -2
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +10 -10
- package/__cjs/masking/maskDefinition.cjs.map +1 -1
- package/__cjs/masking/maskFragment.cjs +0 -8
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/masking/maskOperation.cjs +0 -8
- package/__cjs/masking/maskOperation.cjs.map +1 -1
- package/__cjs/masking/utils.cjs +3 -11
- package/__cjs/masking/utils.cjs.map +1 -1
- package/__cjs/masking/utils.d.cts +0 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -2
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +0 -8
- package/__cjs/utilities/index.cjs +1 -16
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +0 -13
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.js +10 -10
- package/core/ObservableQuery.d.ts +1 -2
- package/core/ObservableQuery.js +15 -11
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +34 -24
- package/core/QueryInfo.js +221 -34
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +4 -36
- package/core/QueryManager.js +77 -258
- package/core/QueryManager.js.map +1 -1
- package/core/networkStatus.d.ts +7 -1
- package/core/networkStatus.js +7 -1
- package/core/networkStatus.js.map +1 -1
- package/invariantErrorCodes.js +64 -69
- package/link/core/ApolloLink.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/local-state/LocalState.js +10 -10
- package/masking/maskDefinition.js.map +1 -1
- package/masking/maskFragment.js +0 -8
- package/masking/maskFragment.js.map +1 -1
- package/masking/maskOperation.js +0 -8
- package/masking/maskOperation.js.map +1 -1
- package/masking/utils.d.ts +0 -1
- package/masking/utils.js +3 -10
- package/masking/utils.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useLazyQuery.d.ts +0 -8
- package/react/hooks/useLazyQuery.js +1 -2
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/utilities/index.d.ts +0 -13
- package/utilities/index.js +0 -12
- package/utilities/index.js.map +1 -1
- package/version.js +1 -1
|
@@ -198,7 +198,7 @@ class StoreReader {
|
|
|
198
198
|
else {
|
|
199
199
|
const fragment = (0, internal_1.getFragmentFromSelection)(selection, context.lookupFragment);
|
|
200
200
|
if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
201
|
-
throw (0, invariant_1.newInvariantError)(
|
|
201
|
+
throw (0, invariant_1.newInvariantError)(102, selection.name.value);
|
|
202
202
|
}
|
|
203
203
|
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
204
204
|
fragment.selectionSet.selections.forEach(workSet.add, workSet);
|
|
@@ -282,7 +282,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
282
282
|
if ((0, internal_1.isNonNullObject)(value)) {
|
|
283
283
|
(0, invariant_1.invariant)(
|
|
284
284
|
!(0, utilities_1.isReference)(value),
|
|
285
|
-
|
|
285
|
+
103,
|
|
286
286
|
(0, helpers_js_1.getTypenameFromStoreObject)(store, value),
|
|
287
287
|
field.name.value
|
|
288
288
|
);
|
|
@@ -73,7 +73,7 @@ class StoreWriter {
|
|
|
73
73
|
context,
|
|
74
74
|
});
|
|
75
75
|
if (!(0, utilities_1.isReference)(ref)) {
|
|
76
|
-
throw (0, invariant_1.newInvariantError)(
|
|
76
|
+
throw (0, invariant_1.newInvariantError)(104, result);
|
|
77
77
|
}
|
|
78
78
|
// So far, the store has not been modified, so now it's time to process
|
|
79
79
|
// context.incomingById and merge those incoming fields into context.store.
|
|
@@ -223,7 +223,7 @@ class StoreWriter {
|
|
|
223
223
|
// provide a default value, so its absence from the written data should
|
|
224
224
|
// not be cause for alarm.
|
|
225
225
|
!policies.getReadFunction(typename, field.name.value)) {
|
|
226
|
-
__DEV__ && invariant_1.invariant.error(
|
|
226
|
+
__DEV__ && invariant_1.invariant.error(105, (0, internal_1.resultKeyNameFromField)(field), result);
|
|
227
227
|
}
|
|
228
228
|
});
|
|
229
229
|
// Identify the result object, even if dataId was already provided,
|
|
@@ -370,7 +370,7 @@ class StoreWriter {
|
|
|
370
370
|
else {
|
|
371
371
|
const fragment = (0, internal_1.getFragmentFromSelection)(selection, context.lookupFragment);
|
|
372
372
|
if (!fragment && selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
373
|
-
throw (0, invariant_1.newInvariantError)(
|
|
373
|
+
throw (0, invariant_1.newInvariantError)(106, selection.name.value);
|
|
374
374
|
}
|
|
375
375
|
if (fragment &&
|
|
376
376
|
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
@@ -543,7 +543,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
543
543
|
}
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
546
|
+
__DEV__ && invariant_1.invariant.warn(107, fieldName, parentType, childTypenames.length ?
|
|
547
547
|
"either ensure all objects of type " +
|
|
548
548
|
childTypenames.join(" and ") +
|
|
549
549
|
" have an ID or a custom merge function, or "
|
|
@@ -76,8 +76,8 @@ class ApolloClient {
|
|
|
76
76
|
*/
|
|
77
77
|
constructor(options) {
|
|
78
78
|
if (environment_1.__DEV__) {
|
|
79
|
-
(0, invariant_1.invariant)(options.cache,
|
|
80
|
-
(0, invariant_1.invariant)(options.link,
|
|
79
|
+
(0, invariant_1.invariant)(options.cache, 66);
|
|
80
|
+
(0, invariant_1.invariant)(options.link, 67);
|
|
81
81
|
}
|
|
82
82
|
const { cache, documentTransform, ssrMode = false, ssrForceFetchDelay = 0,
|
|
83
83
|
// Expose the client instance as window.__APOLLO_CLIENT__ and call
|
|
@@ -239,13 +239,13 @@ class ApolloClient {
|
|
|
239
239
|
options = (0, internal_1.mergeOptions)(this.defaultOptions.query, options);
|
|
240
240
|
}
|
|
241
241
|
if (environment_1.__DEV__) {
|
|
242
|
-
(0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network",
|
|
243
|
-
(0, invariant_1.invariant)(options.fetchPolicy !== "standby",
|
|
244
|
-
(0, invariant_1.invariant)(options.query,
|
|
245
|
-
(0, invariant_1.invariant)(options.query.kind === "Document",
|
|
246
|
-
(0, invariant_1.invariant)(!options.returnPartialData,
|
|
247
|
-
(0, invariant_1.invariant)(!options.pollInterval,
|
|
248
|
-
(0, invariant_1.invariant)(!options.notifyOnNetworkStatusChange,
|
|
242
|
+
(0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network", 68);
|
|
243
|
+
(0, invariant_1.invariant)(options.fetchPolicy !== "standby", 69);
|
|
244
|
+
(0, invariant_1.invariant)(options.query, 70);
|
|
245
|
+
(0, invariant_1.invariant)(options.query.kind === "Document", 71);
|
|
246
|
+
(0, invariant_1.invariant)(!options.returnPartialData, 72);
|
|
247
|
+
(0, invariant_1.invariant)(!options.pollInterval, 73);
|
|
248
|
+
(0, invariant_1.invariant)(!options.notifyOnNetworkStatusChange, 74);
|
|
249
249
|
(0, internal_1.checkDocument)(options.query, graphql_1.OperationTypeNode.QUERY);
|
|
250
250
|
}
|
|
251
251
|
return this.queryManager.query(options);
|
|
@@ -469,7 +469,7 @@ class ApolloClient {
|
|
|
469
469
|
// result.queries and result.results instead, you shouldn't have to worry
|
|
470
470
|
// about preventing uncaught rejections for the Promise.all result.
|
|
471
471
|
result.catch((error) => {
|
|
472
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
472
|
+
__DEV__ && invariant_1.invariant.debug(75, error);
|
|
473
473
|
});
|
|
474
474
|
return result;
|
|
475
475
|
}
|
|
@@ -13,7 +13,6 @@ const internal_1 = require("@apollo/client/utilities/internal");
|
|
|
13
13
|
const invariant_1 = require("@apollo/client/utilities/invariant");
|
|
14
14
|
const equalByQuery_js_1 = require("./equalByQuery.cjs");
|
|
15
15
|
const networkStatus_js_1 = require("./networkStatus.cjs");
|
|
16
|
-
const QueryInfo_js_1 = require("./QueryInfo.cjs");
|
|
17
16
|
const { assign, hasOwnProperty } = Object;
|
|
18
17
|
const uninitialized = {
|
|
19
18
|
loading: true,
|
|
@@ -354,7 +353,7 @@ class ObservableQuery {
|
|
|
354
353
|
const queryDef = (0, internal_1.getQueryDefinition)(this.query);
|
|
355
354
|
const vars = queryDef.variableDefinitions;
|
|
356
355
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
357
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
356
|
+
__DEV__ && invariant_1.invariant.warn(76, variables, queryDef.name?.value || queryDef);
|
|
358
357
|
}
|
|
359
358
|
}
|
|
360
359
|
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
@@ -403,7 +402,7 @@ class ObservableQuery {
|
|
|
403
402
|
const updateQuery = fetchMoreOptions?.updateQuery;
|
|
404
403
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
405
404
|
if (!isCached) {
|
|
406
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
405
|
+
(0, invariant_1.invariant)(updateQuery, 77);
|
|
407
406
|
}
|
|
408
407
|
const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
|
|
409
408
|
pushNotification({
|
|
@@ -536,7 +535,7 @@ class ObservableQuery {
|
|
|
536
535
|
onError(error);
|
|
537
536
|
}
|
|
538
537
|
else {
|
|
539
|
-
__DEV__ && invariant_1.invariant.error(
|
|
538
|
+
__DEV__ && invariant_1.invariant.error(78, error);
|
|
540
539
|
}
|
|
541
540
|
return;
|
|
542
541
|
}
|
|
@@ -675,10 +674,6 @@ class ObservableQuery {
|
|
|
675
674
|
// TODO Make sure we update the networkStatus (and infer fetchVariables)
|
|
676
675
|
// before actually committing to the fetch.
|
|
677
676
|
const initialFetchPolicy = this.options.fetchPolicy;
|
|
678
|
-
const queryInfo = new QueryInfo_js_1.QueryInfo({
|
|
679
|
-
queryManager: this.queryManager,
|
|
680
|
-
observableQuery: this,
|
|
681
|
-
});
|
|
682
677
|
options.context ??= {};
|
|
683
678
|
let synchronouslyEmitted = false;
|
|
684
679
|
const onCacheHit = () => {
|
|
@@ -724,7 +719,13 @@ class ObservableQuery {
|
|
|
724
719
|
}
|
|
725
720
|
}
|
|
726
721
|
});
|
|
727
|
-
let { observable, fromLink } = this.queryManager.fetchObservableWithInfo(
|
|
722
|
+
let { observable, fromLink } = this.queryManager.fetchObservableWithInfo(options, {
|
|
723
|
+
networkStatus,
|
|
724
|
+
query: fetchQuery,
|
|
725
|
+
onCacheHit,
|
|
726
|
+
fetchQueryOperator,
|
|
727
|
+
observableQuery: this,
|
|
728
|
+
});
|
|
728
729
|
// track query and variables from the start of the operation
|
|
729
730
|
const { query, variables } = this;
|
|
730
731
|
const operation = {
|
|
@@ -780,7 +781,7 @@ class ObservableQuery {
|
|
|
780
781
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
781
782
|
return;
|
|
782
783
|
}
|
|
783
|
-
(0, invariant_1.invariant)(pollInterval,
|
|
784
|
+
(0, invariant_1.invariant)(pollInterval, 79);
|
|
784
785
|
const info = pollingInfo || (this.pollingInfo = {});
|
|
785
786
|
info.interval = pollInterval;
|
|
786
787
|
const maybeFetch = () => {
|
|
@@ -1116,6 +1117,9 @@ class ObservableQuery {
|
|
|
1116
1117
|
};
|
|
1117
1118
|
}
|
|
1118
1119
|
calculateNetworkStatus(baseNetworkStatus) {
|
|
1120
|
+
if (baseNetworkStatus === networkStatus_js_1.NetworkStatus.streaming) {
|
|
1121
|
+
return baseNetworkStatus;
|
|
1122
|
+
}
|
|
1119
1123
|
// in the future, this could be more complex logic, e.g. "refetch" and
|
|
1120
1124
|
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1121
1125
|
// as for now we just take the "latest" operation that is still active,
|
|
@@ -1264,7 +1268,7 @@ class ObservableQuery {
|
|
|
1264
1268
|
exports.ObservableQuery = ObservableQuery;
|
|
1265
1269
|
function logMissingFieldErrors(missing) {
|
|
1266
1270
|
if (environment_1.__DEV__ && missing) {
|
|
1267
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1271
|
+
__DEV__ && invariant_1.invariant.debug(80, missing);
|
|
1268
1272
|
}
|
|
1269
1273
|
}
|
|
1270
1274
|
function isEqualQuery(a, b) {
|