@apollo/client 4.0.0-alpha.21 → 4.0.0-alpha.22
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 +103 -0
- package/__cjs/core/ApolloClient.cjs +13 -10
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +7 -8
- package/__cjs/core/ObservableQuery.cjs +5 -5
- package/__cjs/core/QueryManager.cjs +18 -13
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +13 -6
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +1 -1
- package/__cjs/core/types.d.cts +5 -4
- package/__cjs/invariantErrorCodes.cjs +79 -79
- package/__cjs/link/batch-http/batchHttpLink.cjs +14 -14
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -0
- package/__cjs/link/batch-http/index.cjs +2 -1
- package/__cjs/link/batch-http/index.cjs.map +1 -1
- package/__cjs/link/batch-http/index.d.cts +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +45 -0
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -0
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +62 -0
- package/__cjs/link/client-awareness/index.cjs +6 -0
- package/__cjs/link/client-awareness/index.cjs.map +1 -0
- package/__cjs/link/client-awareness/index.d.cts +2 -0
- package/__cjs/link/core/types.d.cts +1 -6
- package/__cjs/link/http/BaseHttpLink.cjs +117 -0
- package/__cjs/link/http/BaseHttpLink.cjs.map +1 -0
- package/__cjs/link/http/BaseHttpLink.d.cts +6 -0
- package/__cjs/link/http/HttpLink.cjs +8 -5
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +16 -4
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/index.cjs +4 -3
- package/__cjs/link/http/index.cjs.map +1 -1
- package/__cjs/link/http/index.d.cts +2 -2
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs +6 -5
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.cjs +9 -7
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +10 -18
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/utils.cjs +3 -3
- package/__cjs/react/context/ApolloConsumer.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +2 -2
- package/__cjs/react/hooks/useApolloClient.cjs +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +2 -2
- package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
- package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
- package/__cjs/testing/core/mocking/mockLink.cjs +4 -4
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +6 -0
- package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
- package/__cjs/utilities/internal/checkDocument.cjs +47 -13
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/checkDocument.d.cts +1 -1
- package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +1 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +2 -2
- package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs +1 -0
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +0 -1
- package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +1 -1
- package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
- package/__cjs/version.cjs +1 -1
- package/core/ApolloClient.d.ts +7 -8
- package/core/ApolloClient.js +14 -11
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +5 -5
- package/core/QueryManager.d.ts +13 -6
- package/core/QueryManager.js +18 -13
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js.map +1 -1
- package/core/types.d.ts +5 -4
- package/invariantErrorCodes.js +79 -79
- package/legacyEntryPoints/link/client-awareness/client-awareness.cjs +1 -0
- package/legacyEntryPoints/link/client-awareness/client-awareness.d.cts +1 -0
- package/legacyEntryPoints/link/client-awareness/index.d.ts +1 -0
- package/legacyEntryPoints/link/client-awareness/index.js +1 -0
- package/link/batch-http/batchHttpLink.d.ts +4 -0
- package/link/batch-http/batchHttpLink.js +11 -12
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +1 -1
- package/link/batch-http/index.js +1 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/client-awareness/ClientAwarenessLink.d.ts +62 -0
- package/link/client-awareness/ClientAwarenessLink.js +41 -0
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -0
- package/link/client-awareness/index.d.ts +2 -0
- package/link/client-awareness/index.js +2 -0
- package/link/client-awareness/index.js.map +1 -0
- package/link/core/types.d.ts +1 -6
- package/link/http/BaseHttpLink.d.ts +6 -0
- package/link/http/BaseHttpLink.js +113 -0
- package/link/http/BaseHttpLink.js.map +1 -0
- package/link/http/HttpLink.d.ts +16 -4
- package/link/http/HttpLink.js +6 -4
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/index.d.ts +2 -2
- package/link/http/index.js +2 -2
- package/link/http/index.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +6 -5
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/persisted-queries/index.js +9 -7
- package/link/persisted-queries/index.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/local-state/LocalState.js +10 -18
- package/local-state/LocalState.js.map +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/utils.js +3 -3
- package/package.json +7 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useLazyQuery.js +2 -2
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/ssr/prerenderStatic.js +2 -2
- package/testing/core/mocking/mockLink.js +4 -4
- package/utilities/caching/sizes.d.ts +6 -0
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/internal/checkDocument.d.ts +1 -1
- package/utilities/internal/checkDocument.js +46 -12
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/getFragmentDefinition.js +3 -3
- package/utilities/internal/getFragmentFromSelection.js +1 -1
- package/utilities/internal/getFragmentQueryDocument.js +2 -2
- package/utilities/internal/getMainDefinition.js +1 -1
- package/utilities/internal/getMemoryInternals.d.ts +0 -1
- package/utilities/internal/getMemoryInternals.js +1 -0
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/getQueryDefinition.js +1 -1
- package/utilities/internal/removeDirectivesFromDocument.js +1 -1
- package/utilities/internal/shouldInclude.js +4 -4
- package/utilities/internal/valueToObjectRepresentation.js +1 -1
- package/version.js +1 -1
- package/__cjs/link/http/createHttpLink.cjs +0 -151
- package/__cjs/link/http/createHttpLink.cjs.map +0 -1
- package/__cjs/link/http/createHttpLink.d.cts +0 -4
- package/link/http/createHttpLink.d.ts +0 -4
- package/link/http/createHttpLink.js +0 -143
- package/link/http/createHttpLink.js.map +0 -1
|
@@ -24,6 +24,10 @@ const QueryInfo_js_1 = require("./QueryInfo.cjs");
|
|
|
24
24
|
class QueryManager {
|
|
25
25
|
defaultOptions;
|
|
26
26
|
client;
|
|
27
|
+
/**
|
|
28
|
+
* The options that were passed to the ApolloClient constructor.
|
|
29
|
+
*/
|
|
30
|
+
clientOptions;
|
|
27
31
|
assumeImmutableResults;
|
|
28
32
|
documentTransform;
|
|
29
33
|
ssrMode;
|
|
@@ -31,7 +35,6 @@ class QueryManager {
|
|
|
31
35
|
dataMasking;
|
|
32
36
|
localState;
|
|
33
37
|
queryDeduplication;
|
|
34
|
-
clientAwareness = {};
|
|
35
38
|
/**
|
|
36
39
|
* Whether to prioritize cache values over network results when
|
|
37
40
|
* `fetchObservableWithInfo` is called.
|
|
@@ -61,7 +64,7 @@ class QueryManager {
|
|
|
61
64
|
this.client = options.client;
|
|
62
65
|
this.defaultOptions = options.defaultOptions;
|
|
63
66
|
this.queryDeduplication = options.queryDeduplication;
|
|
64
|
-
this.
|
|
67
|
+
this.clientOptions = options.clientOptions;
|
|
65
68
|
this.ssrMode = options.ssrMode;
|
|
66
69
|
this.assumeImmutableResults = options.assumeImmutableResults;
|
|
67
70
|
this.dataMasking = options.dataMasking;
|
|
@@ -94,16 +97,13 @@ class QueryManager {
|
|
|
94
97
|
*/
|
|
95
98
|
stop() {
|
|
96
99
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
97
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
100
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(83));
|
|
98
101
|
}
|
|
99
102
|
cancelPendingFetches(error) {
|
|
100
103
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
101
104
|
this.fetchCancelFns.clear();
|
|
102
105
|
}
|
|
103
|
-
async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy
|
|
104
|
-
(0, invariant_1.invariant)(mutation, 82);
|
|
105
|
-
(0, internal_1.checkDocument)(mutation, graphql_1.OperationTypeNode.MUTATION);
|
|
106
|
-
(0, invariant_1.invariant)(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 83);
|
|
106
|
+
async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }) {
|
|
107
107
|
const queryInfo = new QueryInfo_js_1.QueryInfo(this);
|
|
108
108
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
109
109
|
const { hasClientExports } = this.getDocumentInfo(mutation);
|
|
@@ -230,7 +230,10 @@ class QueryManager {
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
fetchQuery(options, networkStatus) {
|
|
233
|
-
|
|
233
|
+
(0, internal_1.checkDocument)(options.query, graphql_1.OperationTypeNode.QUERY);
|
|
234
|
+
// do the rest asynchronously to keep the same rejection timing as
|
|
235
|
+
// checks further in `.mutate`
|
|
236
|
+
return (async () => (0, rxjs_2.lastValueFrom)(this.fetchObservableWithInfo(options, {
|
|
234
237
|
networkStatus,
|
|
235
238
|
}).observable.pipe((0, internal_1.filterMap)((value) => {
|
|
236
239
|
switch (value.kind) {
|
|
@@ -245,7 +248,7 @@ class QueryManager {
|
|
|
245
248
|
// This default is needed when a `standby` fetch policy is used to avoid
|
|
246
249
|
// an EmptyError from rejecting this promise.
|
|
247
250
|
defaultValue: { data: undefined },
|
|
248
|
-
});
|
|
251
|
+
}))();
|
|
249
252
|
}
|
|
250
253
|
transform(document) {
|
|
251
254
|
return this.documentTransform.transformDocument(document);
|
|
@@ -290,7 +293,11 @@ class QueryManager {
|
|
|
290
293
|
};
|
|
291
294
|
transformCache.set(document, cacheEntry);
|
|
292
295
|
}
|
|
293
|
-
|
|
296
|
+
const entry = transformCache.get(document);
|
|
297
|
+
if (entry.violation) {
|
|
298
|
+
throw entry.violation;
|
|
299
|
+
}
|
|
300
|
+
return entry;
|
|
294
301
|
}
|
|
295
302
|
getVariables(document, variables) {
|
|
296
303
|
const defaultVars = this.getDocumentInfo(document).defaultVars;
|
|
@@ -320,7 +327,7 @@ class QueryManager {
|
|
|
320
327
|
});
|
|
321
328
|
return observable;
|
|
322
329
|
}
|
|
323
|
-
|
|
330
|
+
query(options) {
|
|
324
331
|
const query = this.transform(options.query);
|
|
325
332
|
return this.fetchQuery({
|
|
326
333
|
...options,
|
|
@@ -531,7 +538,6 @@ class QueryManager {
|
|
|
531
538
|
...this.defaultContext,
|
|
532
539
|
...context,
|
|
533
540
|
queryDeduplication: deduplication,
|
|
534
|
-
clientAwareness: this.clientAwareness,
|
|
535
541
|
},
|
|
536
542
|
extensions,
|
|
537
543
|
};
|
|
@@ -1109,7 +1115,6 @@ function isFullyUnmaskedOperation(document) {
|
|
|
1109
1115
|
return isUnmasked;
|
|
1110
1116
|
}
|
|
1111
1117
|
function addNonReactiveToNamedFragments(document) {
|
|
1112
|
-
(0, internal_1.checkDocument)(document);
|
|
1113
1118
|
return (0, graphql_1.visit)(document, {
|
|
1114
1119
|
FragmentSpread: (node) => {
|
|
1115
1120
|
// Do not add `@nonreactive` if the fragment is marked with `@unmask`
|