@apollo/client 4.1.0-alpha.0 → 4.1.0-alpha.1
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 +20 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +19 -0
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +3 -0
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +1 -0
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +14 -13
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +12 -0
- package/__cjs/core/ObservableQuery.cjs +6 -6
- package/__cjs/core/QueryManager.cjs +19 -17
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +1 -1
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/invariantErrorCodes.cjs +70 -60
- package/__cjs/link/core/ApolloLink.cjs +3 -3
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/ws/index.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +28 -14
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/local-state/LocalState.d.cts +3 -2
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +19 -0
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +1 -0
- package/cache/inmemory/inMemoryCache.js +3 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +12 -0
- package/core/ApolloClient.js +14 -13
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +6 -6
- package/core/QueryManager.js +19 -17
- package/core/QueryManager.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.js +1 -1
- package/incremental/handlers/notImplemented.js +1 -1
- package/invariantErrorCodes.js +70 -60
- package/link/core/ApolloLink.js +3 -3
- package/link/http/checkFetcher.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/ws/index.js +1 -1
- package/local-state/LocalState.d.ts +3 -2
- package/local-state/LocalState.js +28 -14
- package/local-state/LocalState.js.map +1 -1
- package/package.json +1 -1
- package/version.js +1 -1
|
@@ -99,7 +99,7 @@ class QueryManager {
|
|
|
99
99
|
*/
|
|
100
100
|
stop() {
|
|
101
101
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
102
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
102
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(86));
|
|
103
103
|
}
|
|
104
104
|
cancelPendingFetches(error) {
|
|
105
105
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
@@ -114,7 +114,7 @@ class QueryManager {
|
|
|
114
114
|
if (environment_1.__DEV__) {
|
|
115
115
|
(0, invariant_1.invariant)(
|
|
116
116
|
this.localState,
|
|
117
|
-
|
|
117
|
+
87,
|
|
118
118
|
(0, internal_1.getOperationName)(mutation, "(anonymous)")
|
|
119
119
|
);
|
|
120
120
|
}
|
|
@@ -151,7 +151,7 @@ class QueryManager {
|
|
|
151
151
|
return this.getObservableFromLink(mutation, {
|
|
152
152
|
...context,
|
|
153
153
|
optimisticResponse: isOptimistic ? optimisticResponse : void 0,
|
|
154
|
-
}, variables, {}, false)
|
|
154
|
+
}, variables, fetchPolicy, {}, false)
|
|
155
155
|
.observable.pipe(validateDidEmitValue(), (0, rxjs_2.mergeMap)((result) => {
|
|
156
156
|
const storeResult = { ...result };
|
|
157
157
|
return (0, rxjs_2.from)(queryInfo.markMutationResult(storeResult, {
|
|
@@ -353,7 +353,7 @@ class QueryManager {
|
|
|
353
353
|
// depend on values that previously existed in the data portion of the
|
|
354
354
|
// store. So, we cancel the promises and observers that we have issued
|
|
355
355
|
// so far and not yet resolved (in the case of queries).
|
|
356
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
356
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(88));
|
|
357
357
|
this.obsQueries.forEach((observableQuery) => {
|
|
358
358
|
// Set loading to true so listeners don't trigger unless they want
|
|
359
359
|
// results with partial data.
|
|
@@ -423,10 +423,10 @@ class QueryManager {
|
|
|
423
423
|
if (!included) {
|
|
424
424
|
const queryName = queryNames.get(nameOrQueryString);
|
|
425
425
|
if (queryName) {
|
|
426
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
426
|
+
__DEV__ && invariant_1.invariant.warn(89, queryName);
|
|
427
427
|
}
|
|
428
428
|
else {
|
|
429
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
429
|
+
__DEV__ && invariant_1.invariant.warn(90);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
});
|
|
@@ -447,7 +447,7 @@ class QueryManager {
|
|
|
447
447
|
}
|
|
448
448
|
startGraphQLSubscription(options) {
|
|
449
449
|
let { query, variables } = options;
|
|
450
|
-
const { fetchPolicy, errorPolicy = "none", context = {}, extensions = {}, } = options;
|
|
450
|
+
const { fetchPolicy = "cache-first", errorPolicy = "none", context = {}, extensions = {}, } = options;
|
|
451
451
|
(0, internal_1.checkDocument)(query, graphql_1.OperationTypeNode.SUBSCRIPTION);
|
|
452
452
|
query = this.transform(query);
|
|
453
453
|
variables = this.getVariables(query, variables);
|
|
@@ -455,7 +455,7 @@ class QueryManager {
|
|
|
455
455
|
if (environment_1.__DEV__) {
|
|
456
456
|
(0, invariant_1.invariant)(
|
|
457
457
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
458
|
-
|
|
458
|
+
91,
|
|
459
459
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
460
460
|
);
|
|
461
461
|
}
|
|
@@ -467,7 +467,7 @@ class QueryManager {
|
|
|
467
467
|
context,
|
|
468
468
|
}))
|
|
469
469
|
: (0, rxjs_2.of)(variables)).pipe((0, rxjs_2.mergeMap)((variables) => {
|
|
470
|
-
const { observable, restart: res } = this.getObservableFromLink(query, context, variables, extensions);
|
|
470
|
+
const { observable, restart: res } = this.getObservableFromLink(query, context, variables, fetchPolicy, extensions);
|
|
471
471
|
const queryInfo = new QueryInfo_js_1.QueryInfo(this);
|
|
472
472
|
restart = res;
|
|
473
473
|
return observable.pipe((0, rxjs_2.map)((rawResult) => {
|
|
@@ -520,7 +520,7 @@ class QueryManager {
|
|
|
520
520
|
// Use protected instead of private field so
|
|
521
521
|
// @apollo/experimental-nextjs-app-support can access type info.
|
|
522
522
|
inFlightLinkObservables = new trie_1.Trie(false);
|
|
523
|
-
getObservableFromLink(query, context, variables, extensions,
|
|
523
|
+
getObservableFromLink(query, context, variables, fetchPolicy, extensions,
|
|
524
524
|
// Prefer context.queryDeduplication if specified.
|
|
525
525
|
deduplication = context?.queryDeduplication ??
|
|
526
526
|
this.queryDeduplication) {
|
|
@@ -599,14 +599,14 @@ class QueryManager {
|
|
|
599
599
|
if (environment_1.__DEV__) {
|
|
600
600
|
(0, invariant_1.invariant)(
|
|
601
601
|
this.localState,
|
|
602
|
-
|
|
602
|
+
92,
|
|
603
603
|
operation[0].toUpperCase() + operation.slice(1),
|
|
604
604
|
operationName ?? "(anonymous)"
|
|
605
605
|
);
|
|
606
606
|
}
|
|
607
607
|
(0, invariant_1.invariant)(
|
|
608
608
|
!hasIncrementalDirective,
|
|
609
|
-
|
|
609
|
+
93,
|
|
610
610
|
operation[0].toUpperCase() + operation.slice(1),
|
|
611
611
|
operationName ?? "(anonymous)"
|
|
612
612
|
);
|
|
@@ -617,6 +617,7 @@ class QueryManager {
|
|
|
617
617
|
remoteResult: result,
|
|
618
618
|
context,
|
|
619
619
|
variables,
|
|
620
|
+
fetchPolicy,
|
|
620
621
|
}));
|
|
621
622
|
}));
|
|
622
623
|
}
|
|
@@ -636,7 +637,7 @@ class QueryManager {
|
|
|
636
637
|
// missing fragment definitions (for example) before sending this document
|
|
637
638
|
// through the link chain.
|
|
638
639
|
const linkDocument = this.cache.transformForLink(options.query);
|
|
639
|
-
return this.getObservableFromLink(linkDocument, options.context, options.variables).observable.pipe((0, rxjs_2.map)((incoming) => {
|
|
640
|
+
return this.getObservableFromLink(linkDocument, options.context, options.variables, options.fetchPolicy).observable.pipe((0, rxjs_2.map)((incoming) => {
|
|
640
641
|
// Use linkDocument rather than queryInfo.document so the
|
|
641
642
|
// operation/fragments used to write the result are the same as the
|
|
642
643
|
// ones used to obtain it from the link.
|
|
@@ -775,7 +776,7 @@ class QueryManager {
|
|
|
775
776
|
if (environment_1.__DEV__) {
|
|
776
777
|
(0, invariant_1.invariant)(
|
|
777
778
|
this.localState,
|
|
778
|
-
|
|
779
|
+
94,
|
|
779
780
|
(0, internal_1.getOperationName)(normalized.query, "(anonymous)")
|
|
780
781
|
);
|
|
781
782
|
}
|
|
@@ -951,7 +952,7 @@ class QueryManager {
|
|
|
951
952
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
952
953
|
this.noCacheWarningsByCause.add(cause);
|
|
953
954
|
__DEV__ && invariant_1.invariant.warn(
|
|
954
|
-
|
|
955
|
+
95,
|
|
955
956
|
(0, internal_1.getOperationName)(document, `Unnamed ${operationType ?? "operation"}`)
|
|
956
957
|
);
|
|
957
958
|
}
|
|
@@ -1013,7 +1014,7 @@ class QueryManager {
|
|
|
1013
1014
|
if (environment_1.__DEV__) {
|
|
1014
1015
|
(0, invariant_1.invariant)(
|
|
1015
1016
|
this.localState,
|
|
1016
|
-
|
|
1017
|
+
96,
|
|
1017
1018
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
1018
1019
|
);
|
|
1019
1020
|
}
|
|
@@ -1026,6 +1027,7 @@ class QueryManager {
|
|
|
1026
1027
|
variables,
|
|
1027
1028
|
onlyRunForcedResolvers: true,
|
|
1028
1029
|
returnPartialData: true,
|
|
1030
|
+
fetchPolicy,
|
|
1029
1031
|
}).then((resolved) => ({
|
|
1030
1032
|
kind: "N",
|
|
1031
1033
|
value: toResult(resolved.data || void 0),
|
|
@@ -1107,7 +1109,7 @@ function validateDidEmitValue() {
|
|
|
1107
1109
|
didEmitValue = true;
|
|
1108
1110
|
},
|
|
1109
1111
|
complete() {
|
|
1110
|
-
(0, invariant_1.invariant)(didEmitValue,
|
|
1112
|
+
(0, invariant_1.invariant)(didEmitValue, 97);
|
|
1111
1113
|
},
|
|
1112
1114
|
});
|
|
1113
1115
|
}
|