@apollo/client 4.0.0-alpha.10 → 4.0.0-alpha.11
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/.changeset/afraid-grapes-call.md +5 -0
- package/.changeset/gentle-waves-cough.md +5 -0
- package/.changeset/lucky-sheep-explain.md +34 -0
- package/.changeset/orange-suits-laugh.md +5 -0
- package/.changeset/perfect-ducks-reflect.md +12 -0
- package/.changeset/pre.json +7 -0
- package/.changeset/seven-schools-carry.md +5 -0
- package/.changeset/small-poems-rest.md +5 -0
- package/CHANGELOG.md +59 -0
- package/__cjs/core/ApolloClient.cjs +3 -4
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +2 -2
- package/__cjs/core/LocalState.cjs +0 -1
- package/__cjs/core/LocalState.cjs.map +1 -1
- package/__cjs/core/LocalState.d.cts +0 -1
- package/__cjs/core/ObservableQuery.cjs +6 -6
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +25 -24
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +9 -11
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +3 -3
- package/__cjs/core/types.d.cts +5 -0
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +3 -2
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +2 -3
- package/__cjs/link/core/ApolloLink.cjs +2 -2
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +2 -2
- package/__cjs/link/core/index.cjs.map +1 -1
- package/__cjs/link/core/index.d.cts +1 -1
- package/__cjs/link/core/types.d.cts +15 -4
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +128 -3
- package/__cjs/link/http/createHttpLink.cjs.map +1 -1
- package/__cjs/link/http/createHttpLink.d.cts +2 -2
- package/__cjs/link/http/index.cjs.map +1 -1
- package/__cjs/link/http/index.d.cts +0 -1
- package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
- package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +7 -82
- package/__cjs/link/utils/createOperation.cjs +5 -1
- package/__cjs/link/utils/createOperation.cjs.map +1 -1
- package/__cjs/link/utils/createOperation.d.cts +2 -2
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +41 -8
- package/__cjs/react/index.cjs +3 -1
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +1 -0
- package/__cjs/react/types/deprecated.d.cts +3 -3
- package/__cjs/testing/internal/index.cjs +4 -1
- package/__cjs/testing/internal/index.cjs.map +1 -1
- package/__cjs/testing/internal/index.d.cts +1 -0
- package/__cjs/testing/internal/link.cjs +16 -0
- package/__cjs/testing/internal/link.cjs.map +1 -0
- package/__cjs/testing/internal/link.d.cts +5 -0
- package/__cjs/testing/matchers/isSameClient.cjs +19 -0
- package/__cjs/testing/matchers/isSameClient.cjs.map +1 -0
- package/__cjs/testing/matchers/isSameClient.d.cts +3 -0
- package/__cjs/testing/matchers/isSameObservableQuery.cjs +19 -0
- package/__cjs/testing/matchers/isSameObservableQuery.cjs.map +1 -0
- package/__cjs/testing/matchers/isSameObservableQuery.d.cts +3 -0
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs +9 -3
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs.map +1 -1
- package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +6 -1
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +3 -2
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -1
- package/__cjs/testing/matchers/utils/getSerializableProperties.d.cts +3 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/core/ApolloClient.d.ts +2 -2
- package/core/ApolloClient.js +3 -4
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +0 -1
- package/core/LocalState.js +0 -1
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.js +6 -6
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +9 -11
- package/core/QueryManager.js +25 -24
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +3 -3
- package/core/index.js.map +1 -1
- package/core/types.d.ts +5 -0
- package/link/batch-http/batchHttpLink.d.ts +3 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/index.d.ts +2 -3
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +2 -2
- package/link/core/ApolloLink.js +2 -2
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/index.d.ts +1 -1
- package/link/core/index.js.map +1 -1
- package/link/core/types.d.ts +15 -4
- package/link/http/HttpLink.d.ts +128 -3
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/createHttpLink.d.ts +2 -2
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/index.d.ts +0 -1
- package/link/http/index.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +2 -2
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +7 -82
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/utils/createOperation.d.ts +2 -2
- package/link/utils/createOperation.js +5 -1
- package/link/utils/createOperation.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useMutation.d.ts +41 -8
- package/react/hooks/useMutation.js.map +1 -1
- package/react/index.d.ts +1 -0
- package/react/index.js +1 -0
- package/react/index.js.map +1 -1
- package/react/types/deprecated.d.ts +3 -3
- package/testing/internal/index.d.ts +1 -0
- package/testing/internal/index.js +1 -0
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/link.d.ts +5 -0
- package/testing/internal/link.js +12 -0
- package/testing/internal/link.js.map +1 -0
- package/testing/matchers/isSameClient.d.ts +3 -0
- package/testing/matchers/isSameClient.js +15 -0
- package/testing/matchers/isSameClient.js.map +1 -0
- package/testing/matchers/isSameObservableQuery.d.ts +3 -0
- package/testing/matchers/isSameObservableQuery.js +15 -0
- package/testing/matchers/isSameObservableQuery.js.map +1 -0
- package/testing/matchers/toStrictEqualTyped.d.ts +6 -1
- package/testing/matchers/toStrictEqualTyped.js +9 -3
- package/testing/matchers/toStrictEqualTyped.js.map +1 -1
- package/testing/matchers/utils/getSerializableProperties.d.ts +3 -1
- package/testing/matchers/utils/getSerializableProperties.js +3 -2
- package/testing/matchers/utils/getSerializableProperties.js.map +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.js +1 -1
|
@@ -27,9 +27,8 @@ const QueryInfo_js_1 = require("./QueryInfo.cjs");
|
|
|
27
27
|
const { hasOwnProperty } = Object.prototype;
|
|
28
28
|
const IGNORE = {};
|
|
29
29
|
class QueryManager {
|
|
30
|
-
cache;
|
|
31
|
-
link;
|
|
32
30
|
defaultOptions;
|
|
31
|
+
client;
|
|
33
32
|
assumeImmutableResults;
|
|
34
33
|
documentTransform;
|
|
35
34
|
ssrMode;
|
|
@@ -63,8 +62,7 @@ class QueryManager {
|
|
|
63
62
|
const defaultDocumentTransform = new utilities_4.DocumentTransform((document) => this.cache.transformDocument(document),
|
|
64
63
|
// Allow the apollo cache to manage its own transform caches
|
|
65
64
|
{ cache: false });
|
|
66
|
-
this.
|
|
67
|
-
this.link = options.link;
|
|
65
|
+
this.client = options.client;
|
|
68
66
|
this.defaultOptions = options.defaultOptions;
|
|
69
67
|
this.queryDeduplication = options.queryDeduplication;
|
|
70
68
|
this.clientAwareness = options.clientAwareness;
|
|
@@ -88,6 +86,12 @@ class QueryManager {
|
|
|
88
86
|
this.mutationStore = {};
|
|
89
87
|
}
|
|
90
88
|
}
|
|
89
|
+
get link() {
|
|
90
|
+
return this.client.link;
|
|
91
|
+
}
|
|
92
|
+
get cache() {
|
|
93
|
+
return this.client.cache;
|
|
94
|
+
}
|
|
91
95
|
/**
|
|
92
96
|
* Call this method to terminate any active query processes, making it safe
|
|
93
97
|
* to dispose of this QueryManager instance.
|
|
@@ -503,7 +507,7 @@ class QueryManager {
|
|
|
503
507
|
id: queryId,
|
|
504
508
|
}),
|
|
505
509
|
}))
|
|
506
|
-
.finally(() => this.
|
|
510
|
+
.finally(() => this.removeQuery(queryId));
|
|
507
511
|
}
|
|
508
512
|
queryIdCounter = 1;
|
|
509
513
|
generateQueryId() {
|
|
@@ -697,10 +701,6 @@ class QueryManager {
|
|
|
697
701
|
}
|
|
698
702
|
return makeObservable(variables);
|
|
699
703
|
}
|
|
700
|
-
stopQuery(queryId) {
|
|
701
|
-
this.removeQuery(queryId);
|
|
702
|
-
this.broadcastQueries();
|
|
703
|
-
}
|
|
704
704
|
removeQuery(queryId) {
|
|
705
705
|
// teardown all links
|
|
706
706
|
// Both `QueryManager.fetchRequest` and `QueryManager.query` create separate promises
|
|
@@ -730,16 +730,25 @@ class QueryManager {
|
|
|
730
730
|
this.queryDeduplication) {
|
|
731
731
|
let observable;
|
|
732
732
|
const { serverQuery, clientQuery } = this.getDocumentInfo(query);
|
|
733
|
+
const prepareContext = (context = {}) => {
|
|
734
|
+
const newContext = this.localState.prepareContext(context);
|
|
735
|
+
return {
|
|
736
|
+
...this.defaultContext,
|
|
737
|
+
...newContext,
|
|
738
|
+
queryDeduplication: deduplication,
|
|
739
|
+
clientAwareness: this.clientAwareness,
|
|
740
|
+
};
|
|
741
|
+
};
|
|
742
|
+
const executeContext = {
|
|
743
|
+
client: this.client,
|
|
744
|
+
};
|
|
733
745
|
if (serverQuery) {
|
|
734
746
|
const { inFlightLinkObservables, link } = this;
|
|
735
747
|
const operation = {
|
|
736
748
|
query: serverQuery,
|
|
737
749
|
variables,
|
|
738
750
|
operationName: (0, utilities_4.getOperationName)(serverQuery) || void 0,
|
|
739
|
-
context:
|
|
740
|
-
...context,
|
|
741
|
-
forceFetch: !deduplication,
|
|
742
|
-
}),
|
|
751
|
+
context: prepareContext(context),
|
|
743
752
|
extensions,
|
|
744
753
|
};
|
|
745
754
|
context = operation.context;
|
|
@@ -749,7 +758,7 @@ class QueryManager {
|
|
|
749
758
|
const entry = inFlightLinkObservables.lookup(printedServerQuery, varJson);
|
|
750
759
|
observable = entry.observable;
|
|
751
760
|
if (!observable) {
|
|
752
|
-
observable = entry.observable = (0, core_1.execute)(link, operation).pipe((0, internal_1.onAnyEvent)((event) => {
|
|
761
|
+
observable = entry.observable = (0, core_1.execute)(link, operation, executeContext).pipe((0, internal_1.onAnyEvent)((event) => {
|
|
753
762
|
if ((event.type !== "next" ||
|
|
754
763
|
!("hasNext" in event.value) ||
|
|
755
764
|
!event.value.hasNext) &&
|
|
@@ -761,12 +770,12 @@ class QueryManager {
|
|
|
761
770
|
}
|
|
762
771
|
}
|
|
763
772
|
else {
|
|
764
|
-
observable = (0, core_1.execute)(link, operation);
|
|
773
|
+
observable = (0, core_1.execute)(link, operation, executeContext);
|
|
765
774
|
}
|
|
766
775
|
}
|
|
767
776
|
else {
|
|
768
777
|
observable = (0, rxjs_1.of)({ data: {} });
|
|
769
|
-
context =
|
|
778
|
+
context = prepareContext(context);
|
|
770
779
|
}
|
|
771
780
|
if (clientQuery) {
|
|
772
781
|
observable = observable.pipe((0, rxjs_1.mergeMap)((result) => {
|
|
@@ -1208,14 +1217,6 @@ class QueryManager {
|
|
|
1208
1217
|
}
|
|
1209
1218
|
return this.queries.get(queryId);
|
|
1210
1219
|
}
|
|
1211
|
-
prepareContext(context = {}) {
|
|
1212
|
-
const newContext = this.localState.prepareContext(context);
|
|
1213
|
-
return {
|
|
1214
|
-
...this.defaultContext,
|
|
1215
|
-
...newContext,
|
|
1216
|
-
clientAwareness: this.clientAwareness,
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
1220
|
}
|
|
1220
1221
|
exports.QueryManager = QueryManager;
|
|
1221
1222
|
function validateDidEmitValue() {
|