@apollo/client 4.1.0-alpha.0 → 4.1.0-alpha.2
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 +47 -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/incremental/handlers/notImplemented.cjs.map +1 -1
- package/__cjs/invariantErrorCodes.cjs +72 -62
- 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/react/hooks/useMutation.cjs +7 -1
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +13 -1
- 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/incremental/handlers/notImplemented.js.map +1 -1
- package/invariantErrorCodes.js +72 -62
- 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/react/hooks/useMutation.d.ts +13 -1
- package/react/hooks/useMutation.js +7 -1
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +13 -1
- package/react/hooks-compiled/useMutation.js +5 -1
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/version.js +1 -1
package/core/QueryManager.js
CHANGED
|
@@ -92,7 +92,7 @@ export class QueryManager {
|
|
|
92
92
|
*/
|
|
93
93
|
stop() {
|
|
94
94
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
95
|
-
this.cancelPendingFetches(newInvariantError(
|
|
95
|
+
this.cancelPendingFetches(newInvariantError(86));
|
|
96
96
|
}
|
|
97
97
|
cancelPendingFetches(error) {
|
|
98
98
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
@@ -105,7 +105,7 @@ export class QueryManager {
|
|
|
105
105
|
variables = this.getVariables(mutation, variables);
|
|
106
106
|
if (hasClientExports) {
|
|
107
107
|
if (__DEV__) {
|
|
108
|
-
invariant(this.localState,
|
|
108
|
+
invariant(this.localState, 87, getOperationName(mutation, "(anonymous)"));
|
|
109
109
|
}
|
|
110
110
|
variables = await this.localState.getExportedVariables({
|
|
111
111
|
client: this.client,
|
|
@@ -140,7 +140,7 @@ export class QueryManager {
|
|
|
140
140
|
return this.getObservableFromLink(mutation, {
|
|
141
141
|
...context,
|
|
142
142
|
optimisticResponse: isOptimistic ? optimisticResponse : void 0,
|
|
143
|
-
}, variables, {}, false)
|
|
143
|
+
}, variables, fetchPolicy, {}, false)
|
|
144
144
|
.observable.pipe(validateDidEmitValue(), mergeMap((result) => {
|
|
145
145
|
const storeResult = { ...result };
|
|
146
146
|
return from(queryInfo.markMutationResult(storeResult, {
|
|
@@ -342,7 +342,7 @@ export class QueryManager {
|
|
|
342
342
|
// depend on values that previously existed in the data portion of the
|
|
343
343
|
// store. So, we cancel the promises and observers that we have issued
|
|
344
344
|
// so far and not yet resolved (in the case of queries).
|
|
345
|
-
this.cancelPendingFetches(newInvariantError(
|
|
345
|
+
this.cancelPendingFetches(newInvariantError(88));
|
|
346
346
|
this.obsQueries.forEach((observableQuery) => {
|
|
347
347
|
// Set loading to true so listeners don't trigger unless they want
|
|
348
348
|
// results with partial data.
|
|
@@ -412,10 +412,10 @@ export class QueryManager {
|
|
|
412
412
|
if (!included) {
|
|
413
413
|
const queryName = queryNames.get(nameOrQueryString);
|
|
414
414
|
if (queryName) {
|
|
415
|
-
__DEV__ && invariant.warn(
|
|
415
|
+
__DEV__ && invariant.warn(89, queryName);
|
|
416
416
|
}
|
|
417
417
|
else {
|
|
418
|
-
__DEV__ && invariant.warn(
|
|
418
|
+
__DEV__ && invariant.warn(90);
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
});
|
|
@@ -436,7 +436,7 @@ export class QueryManager {
|
|
|
436
436
|
}
|
|
437
437
|
startGraphQLSubscription(options) {
|
|
438
438
|
let { query, variables } = options;
|
|
439
|
-
const { fetchPolicy, errorPolicy = "none", context = {}, extensions = {}, } = options;
|
|
439
|
+
const { fetchPolicy = "cache-first", errorPolicy = "none", context = {}, extensions = {}, } = options;
|
|
440
440
|
checkDocument(query, OperationTypeNode.SUBSCRIPTION);
|
|
441
441
|
query = this.transform(query);
|
|
442
442
|
variables = this.getVariables(query, variables);
|
|
@@ -444,7 +444,7 @@ export class QueryManager {
|
|
|
444
444
|
if (__DEV__) {
|
|
445
445
|
invariant(
|
|
446
446
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
447
|
-
|
|
447
|
+
91,
|
|
448
448
|
getOperationName(query, "(anonymous)")
|
|
449
449
|
);
|
|
450
450
|
}
|
|
@@ -456,7 +456,7 @@ export class QueryManager {
|
|
|
456
456
|
context,
|
|
457
457
|
}))
|
|
458
458
|
: of(variables)).pipe(mergeMap((variables) => {
|
|
459
|
-
const { observable, restart: res } = this.getObservableFromLink(query, context, variables, extensions);
|
|
459
|
+
const { observable, restart: res } = this.getObservableFromLink(query, context, variables, fetchPolicy, extensions);
|
|
460
460
|
const queryInfo = new QueryInfo(this);
|
|
461
461
|
restart = res;
|
|
462
462
|
return observable.pipe(map((rawResult) => {
|
|
@@ -509,7 +509,7 @@ export class QueryManager {
|
|
|
509
509
|
// Use protected instead of private field so
|
|
510
510
|
// @apollo/experimental-nextjs-app-support can access type info.
|
|
511
511
|
inFlightLinkObservables = new Trie(false);
|
|
512
|
-
getObservableFromLink(query, context, variables, extensions,
|
|
512
|
+
getObservableFromLink(query, context, variables, fetchPolicy, extensions,
|
|
513
513
|
// Prefer context.queryDeduplication if specified.
|
|
514
514
|
deduplication = context?.queryDeduplication ??
|
|
515
515
|
this.queryDeduplication) {
|
|
@@ -588,14 +588,14 @@ export class QueryManager {
|
|
|
588
588
|
if (__DEV__) {
|
|
589
589
|
invariant(
|
|
590
590
|
this.localState,
|
|
591
|
-
|
|
591
|
+
92,
|
|
592
592
|
operation[0].toUpperCase() + operation.slice(1),
|
|
593
593
|
operationName ?? "(anonymous)"
|
|
594
594
|
);
|
|
595
595
|
}
|
|
596
596
|
invariant(
|
|
597
597
|
!hasIncrementalDirective,
|
|
598
|
-
|
|
598
|
+
93,
|
|
599
599
|
operation[0].toUpperCase() + operation.slice(1),
|
|
600
600
|
operationName ?? "(anonymous)"
|
|
601
601
|
);
|
|
@@ -606,6 +606,7 @@ export class QueryManager {
|
|
|
606
606
|
remoteResult: result,
|
|
607
607
|
context,
|
|
608
608
|
variables,
|
|
609
|
+
fetchPolicy,
|
|
609
610
|
}));
|
|
610
611
|
}));
|
|
611
612
|
}
|
|
@@ -625,7 +626,7 @@ export class QueryManager {
|
|
|
625
626
|
// missing fragment definitions (for example) before sending this document
|
|
626
627
|
// through the link chain.
|
|
627
628
|
const linkDocument = this.cache.transformForLink(options.query);
|
|
628
|
-
return this.getObservableFromLink(linkDocument, options.context, options.variables).observable.pipe(map((incoming) => {
|
|
629
|
+
return this.getObservableFromLink(linkDocument, options.context, options.variables, options.fetchPolicy).observable.pipe(map((incoming) => {
|
|
629
630
|
// Use linkDocument rather than queryInfo.document so the
|
|
630
631
|
// operation/fragments used to write the result are the same as the
|
|
631
632
|
// ones used to obtain it from the link.
|
|
@@ -762,7 +763,7 @@ export class QueryManager {
|
|
|
762
763
|
// we deprecated and removed LocalState.
|
|
763
764
|
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
764
765
|
if (__DEV__) {
|
|
765
|
-
invariant(this.localState,
|
|
766
|
+
invariant(this.localState, 94, getOperationName(normalized.query, "(anonymous)"));
|
|
766
767
|
}
|
|
767
768
|
observable = from(this.localState.getExportedVariables({
|
|
768
769
|
client: this.client,
|
|
@@ -935,7 +936,7 @@ export class QueryManager {
|
|
|
935
936
|
!isFullyUnmaskedOperation(document) &&
|
|
936
937
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
937
938
|
this.noCacheWarningsByCause.add(cause);
|
|
938
|
-
__DEV__ && invariant.warn(
|
|
939
|
+
__DEV__ && invariant.warn(95, getOperationName(document, `Unnamed ${operationType ?? "operation"}`));
|
|
939
940
|
}
|
|
940
941
|
}
|
|
941
942
|
return (this.dataMasking ?
|
|
@@ -993,7 +994,7 @@ export class QueryManager {
|
|
|
993
994
|
(diff.complete || returnPartialData) &&
|
|
994
995
|
this.getDocumentInfo(query).hasForcedResolvers) {
|
|
995
996
|
if (__DEV__) {
|
|
996
|
-
invariant(this.localState,
|
|
997
|
+
invariant(this.localState, 96, getOperationName(query, "(anonymous)"));
|
|
997
998
|
}
|
|
998
999
|
onCacheHit();
|
|
999
1000
|
return from(this.localState.execute({
|
|
@@ -1004,6 +1005,7 @@ export class QueryManager {
|
|
|
1004
1005
|
variables,
|
|
1005
1006
|
onlyRunForcedResolvers: true,
|
|
1006
1007
|
returnPartialData: true,
|
|
1008
|
+
fetchPolicy,
|
|
1007
1009
|
}).then((resolved) => ({
|
|
1008
1010
|
kind: "N",
|
|
1009
1011
|
value: toResult(resolved.data || void 0),
|
|
@@ -1084,7 +1086,7 @@ function validateDidEmitValue() {
|
|
|
1084
1086
|
didEmitValue = true;
|
|
1085
1087
|
},
|
|
1086
1088
|
complete() {
|
|
1087
|
-
invariant(didEmitValue,
|
|
1089
|
+
invariant(didEmitValue, 97);
|
|
1088
1090
|
},
|
|
1089
1091
|
});
|
|
1090
1092
|
}
|