@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
|
@@ -27,7 +27,7 @@ class LocalState {
|
|
|
27
27
|
}
|
|
28
28
|
async execute({ document, client, context, remoteResult, variables = {}, onlyRunForcedResolvers = false, returnPartialData = false, }) {
|
|
29
29
|
if (environment_1.__DEV__) {
|
|
30
|
-
(0, invariant_1.invariant)((0, internal_1.hasDirectives)(["client"], document),
|
|
30
|
+
(0, invariant_1.invariant)((0, internal_1.hasDirectives)(["client"], document), 48);
|
|
31
31
|
validateCacheImplementation(client.cache);
|
|
32
32
|
}
|
|
33
33
|
// note: if `remoteResult` is `undefined`, we will execute resolvers since
|
|
@@ -80,7 +80,7 @@ class LocalState {
|
|
|
80
80
|
}
|
|
81
81
|
async getExportedVariables({ document, client, context, variables, }) {
|
|
82
82
|
if (environment_1.__DEV__) {
|
|
83
|
-
(0, invariant_1.invariant)((0, internal_1.hasDirectives)(["client"], document),
|
|
83
|
+
(0, invariant_1.invariant)((0, internal_1.hasDirectives)(["client"], document), 49);
|
|
84
84
|
validateCacheImplementation(client.cache);
|
|
85
85
|
}
|
|
86
86
|
const { exportsToResolve, exportedVariableDefs, fragmentMap, operationDefinition, } = this.collectQueryDetail(document);
|
|
@@ -138,9 +138,6 @@ class LocalState {
|
|
|
138
138
|
const isClientField = isClientFieldDescendant ||
|
|
139
139
|
(selection.directives?.some((d) => d.name.value === "client") ??
|
|
140
140
|
false);
|
|
141
|
-
if (isClientField && hasAliasedTypename(selectionSet)) {
|
|
142
|
-
throw new errors_1.LocalStateError(`'__typename' is a forbidden field alias name in the selection set for field '${path.at(-1)}' when using local resolvers.`, { path });
|
|
143
|
-
}
|
|
144
141
|
const fieldResult = isClientField ?
|
|
145
142
|
await this.resolveClientField(selection, isClientFieldDescendant, rootValue, execContext, selectionSet, path.concat(selection.name.value))
|
|
146
143
|
: await this.resolveServerField(selection, rootValue, execContext, path.concat(selection.name.value));
|
|
@@ -165,7 +162,7 @@ class LocalState {
|
|
|
165
162
|
}
|
|
166
163
|
if (selection.kind === graphql_1.Kind.FRAGMENT_SPREAD) {
|
|
167
164
|
const fragment = fragmentMap[selection.name.value];
|
|
168
|
-
(0, invariant_1.invariant)(fragment,
|
|
165
|
+
(0, invariant_1.invariant)(fragment, 50, selection.name.value);
|
|
169
166
|
const typename = rootValue?.__typename;
|
|
170
167
|
const typeCondition = fragment.typeCondition.name.value;
|
|
171
168
|
const matches = typename === typeCondition ||
|
|
@@ -229,7 +226,7 @@ class LocalState {
|
|
|
229
226
|
}
|
|
230
227
|
if (!returnPartialData) {
|
|
231
228
|
if (environment_1.__DEV__) {
|
|
232
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
229
|
+
__DEV__ && invariant_1.invariant.warn(51, resolverName);
|
|
233
230
|
}
|
|
234
231
|
return null;
|
|
235
232
|
}
|
|
@@ -296,13 +293,13 @@ class LocalState {
|
|
|
296
293
|
if (result === undefined && !returnPartialData) {
|
|
297
294
|
if (environment_1.__DEV__ && phase === "resolve") {
|
|
298
295
|
if (resolver && !onlyRunForcedResolvers) {
|
|
299
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
296
|
+
__DEV__ && invariant_1.invariant.warn(52, resolverName);
|
|
300
297
|
}
|
|
301
298
|
else if (onlyRunForcedResolvers) {
|
|
302
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
299
|
+
__DEV__ && invariant_1.invariant.warn(53, resolverName);
|
|
303
300
|
}
|
|
304
301
|
else {
|
|
305
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
302
|
+
__DEV__ && invariant_1.invariant.warn(54, fieldName, rootValue);
|
|
306
303
|
}
|
|
307
304
|
}
|
|
308
305
|
result = null;
|
|
@@ -314,7 +311,7 @@ class LocalState {
|
|
|
314
311
|
return this.resolveSubSelectedArray(field, true, result, execContext, path);
|
|
315
312
|
}
|
|
316
313
|
if (phase === "resolve" && !result.__typename) {
|
|
317
|
-
this.addError((0, invariant_1.newInvariantError)(
|
|
314
|
+
this.addError((0, invariant_1.newInvariantError)(55, result, resolverName), path, execContext, { resolver: resolverName });
|
|
318
315
|
return null;
|
|
319
316
|
}
|
|
320
317
|
return this.resolveSelectionSet(field.selectionSet, true, result, execContext, path);
|
|
@@ -425,7 +422,7 @@ class LocalState {
|
|
|
425
422
|
},
|
|
426
423
|
FragmentSpread(spread, _, __, ___, ancestors) {
|
|
427
424
|
const fragment = fragmentMap[spread.name.value];
|
|
428
|
-
(0, invariant_1.invariant)(fragment,
|
|
425
|
+
(0, invariant_1.invariant)(fragment, 56, spread.name.value);
|
|
429
426
|
const { selectionsToResolve: fragmentSelections } = traverse(fragment);
|
|
430
427
|
if (fragmentSelections.size > 0) {
|
|
431
428
|
// Fragment for this spread contains @client directive (either directly or transitively)
|
|
@@ -485,7 +482,7 @@ function getExportedVariableName(directive) {
|
|
|
485
482
|
}
|
|
486
483
|
}
|
|
487
484
|
function validateCacheImplementation(cache) {
|
|
488
|
-
(0, invariant_1.invariant)(cache.fragmentMatches,
|
|
485
|
+
(0, invariant_1.invariant)(cache.fragmentMatches, 57);
|
|
489
486
|
}
|
|
490
487
|
function getCacheResultAtPath(diff, path) {
|
|
491
488
|
if (diff.result === null) {
|
|
@@ -527,9 +524,4 @@ function toQueryOperation(document) {
|
|
|
527
524
|
});
|
|
528
525
|
return modifiedDoc;
|
|
529
526
|
}
|
|
530
|
-
function hasAliasedTypename(selectionSet) {
|
|
531
|
-
return selectionSet.selections.some((selection) => selection.kind === graphql_1.Kind.FIELD &&
|
|
532
|
-
selection.alias &&
|
|
533
|
-
selection.name.value === "__typename");
|
|
534
|
-
}
|
|
535
527
|
//# sourceMappingURL=LocalState.cjs.map
|