@apollo/client 4.3.8 → 4.4.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 +76 -3
- package/__cjs/cache/core/cache.cjs +50 -15
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +22 -4
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +4 -4
- package/__cjs/cache/inmemory/helpers.cjs +12 -0
- package/__cjs/cache/inmemory/helpers.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.d.cts +10 -5
- package/__cjs/cache/inmemory/inMemoryCache.cjs +13 -2
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +19 -4
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +9 -9
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +112 -19
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +12 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +53 -23
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +8 -4
- package/__cjs/core/ApolloClient.cjs +19 -15
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +1 -0
- package/__cjs/core/ObservableQuery.cjs +8 -8
- package/__cjs/core/QueryInfo.cjs +1 -1
- package/__cjs/core/QueryManager.cjs +12 -12
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/errors/CombinedGraphQLErrors.cjs +3 -7
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +2 -2
- package/__cjs/errors/CombinedProtocolErrors.cjs +3 -8
- package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedProtocolErrors.d.cts +2 -2
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +2 -2
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/invariantErrorCodes.cjs +125 -120
- package/__cjs/link/batch-http/BaseBatchHttpLink.cjs +9 -18
- package/__cjs/link/batch-http/BaseBatchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/BaseBatchHttpLink.d.cts +0 -7
- 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 -16
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/masking/maskDefinition.cjs +20 -2
- package/__cjs/masking/maskDefinition.cjs.map +1 -1
- 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/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/useFragment.cjs +8 -2
- package/__cjs/react/hooks/useFragment.cjs.map +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/useSuspenseFragment.cjs +10 -4
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs +2 -2
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +4 -5
- package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.cjs +3 -3
- package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.d.cts +4 -5
- package/__cjs/react/internal/cache/types.d.cts +0 -5
- package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
- package/__cjs/testing/core/mocking/mockLink.cjs +4 -4
- package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
- package/__cjs/utilities/internal/DeepMerger.cjs +6 -2
- package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
- package/__cjs/utilities/internal/DeepMerger.d.cts +13 -3
- package/__cjs/utilities/internal/argumentsObjectFromField.cjs.map +1 -1
- package/__cjs/utilities/internal/argumentsObjectFromField.d.cts +2 -2
- package/__cjs/utilities/internal/constants.cjs +33 -1
- package/__cjs/utilities/internal/constants.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.d.cts +32 -0
- package/__cjs/utilities/internal/createArgumentNode.cjs +14 -0
- package/__cjs/utilities/internal/createArgumentNode.cjs.map +1 -0
- package/__cjs/utilities/internal/createArgumentNode.d.cts +3 -0
- package/__cjs/utilities/internal/createDirectiveNode.cjs +14 -0
- package/__cjs/utilities/internal/createDirectiveNode.cjs.map +1 -0
- package/__cjs/utilities/internal/createDirectiveNode.d.cts +3 -0
- package/__cjs/utilities/internal/createFragmentArgumentNode.cjs +13 -0
- package/__cjs/utilities/internal/createFragmentArgumentNode.cjs.map +1 -0
- package/__cjs/utilities/internal/createFragmentArgumentNode.d.cts +3 -0
- package/__cjs/utilities/internal/createFragmentSpreadNode.cjs +20 -0
- package/__cjs/utilities/internal/createFragmentSpreadNode.cjs.map +1 -0
- package/__cjs/utilities/internal/createFragmentSpreadNode.d.cts +6 -0
- package/__cjs/utilities/internal/createNameNode.cjs +8 -0
- package/__cjs/utilities/internal/createNameNode.cjs.map +1 -0
- package/__cjs/utilities/internal/createNameNode.d.cts +3 -0
- package/__cjs/utilities/internal/createValueNode.cjs +27 -0
- package/__cjs/utilities/internal/createValueNode.cjs.map +1 -0
- package/__cjs/utilities/internal/createValueNode.d.cts +12 -0
- package/__cjs/utilities/internal/createVariableNode.cjs +9 -0
- package/__cjs/utilities/internal/createVariableNode.cjs.map +1 -0
- package/__cjs/utilities/internal/createVariableNode.d.cts +3 -0
- package/__cjs/utilities/internal/equalByQuery.cjs +16 -3
- package/__cjs/utilities/internal/equalByQuery.cjs.map +1 -1
- package/__cjs/utilities/internal/equalByQuery.d.cts +2 -3
- package/__cjs/utilities/internal/getDefaultValues.cjs.map +1 -1
- package/__cjs/utilities/internal/getDefaultValues.d.cts +2 -2
- package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
- package/__cjs/utilities/internal/getFragmentDefinition.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +1 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +20 -9
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentScope.cjs +23 -0
- package/__cjs/utilities/internal/getFragmentScope.cjs.map +1 -0
- package/__cjs/utilities/internal/getFragmentScope.d.cts +13 -0
- package/__cjs/utilities/internal/getFragmentVariables.cjs +33 -0
- package/__cjs/utilities/internal/getFragmentVariables.cjs.map +1 -0
- package/__cjs/utilities/internal/getFragmentVariables.d.cts +12 -0
- package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
- package/__cjs/utilities/internal/index.cjs +11 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +6 -1
- package/__cjs/utilities/internal/isNonEmptyObject.cjs +13 -0
- package/__cjs/utilities/internal/isNonEmptyObject.cjs.map +1 -0
- package/__cjs/utilities/internal/isNonEmptyObject.d.cts +7 -0
- package/__cjs/utilities/internal/isNonNullObject.cjs.map +1 -1
- package/__cjs/utilities/internal/isNonNullObject.d.cts +1 -1
- package/__cjs/utilities/internal/mapObservableFragment.cjs +14 -9
- package/__cjs/utilities/internal/mapObservableFragment.cjs.map +1 -1
- package/__cjs/utilities/internal/mapObservableFragment.d.cts +5 -1
- package/__cjs/utilities/internal/mergeDeepArray.cjs +2 -2
- package/__cjs/utilities/internal/mergeDeepArray.cjs.map +1 -1
- package/__cjs/utilities/internal/mergeDeepArray.d.cts +2 -1
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +121 -62
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/removeFragmentSpreads.cjs +55 -2
- package/__cjs/utilities/internal/removeFragmentSpreads.cjs.map +1 -1
- package/__cjs/utilities/internal/removeFragmentSpreads.d.cts +17 -1
- package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
- package/__cjs/utilities/internal/types/FragmentInfo.cjs +3 -0
- package/__cjs/utilities/internal/types/FragmentInfo.cjs.map +1 -0
- package/__cjs/utilities/internal/types/FragmentInfo.d.cts +14 -0
- package/__cjs/utilities/internal/types/Mutable.cjs +3 -0
- package/__cjs/utilities/internal/types/Mutable.cjs.map +1 -0
- package/__cjs/utilities/internal/types/Mutable.d.cts +4 -0
- package/__cjs/utilities/internal/types/ObjectWithFragmentInfo.cjs +3 -0
- package/__cjs/utilities/internal/types/ObjectWithFragmentInfo.cjs.map +1 -0
- package/__cjs/utilities/internal/types/ObjectWithFragmentInfo.d.cts +13 -0
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/core/cache.d.ts +22 -4
- package/cache/core/cache.js +51 -16
- package/cache/core/cache.js.map +1 -1
- package/cache/index.d.ts +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +4 -4
- package/cache/inmemory/helpers.d.ts +10 -5
- package/cache/inmemory/helpers.js +12 -1
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +19 -4
- package/cache/inmemory/inMemoryCache.js +14 -3
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.d.ts +1 -1
- package/cache/inmemory/policies.js +9 -9
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +115 -22
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +12 -1
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +8 -4
- package/cache/inmemory/writeToStore.js +56 -26
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +1 -0
- package/core/ApolloClient.js +20 -16
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +8 -8
- package/core/QueryInfo.js +1 -1
- package/core/QueryManager.js +12 -12
- package/core/RefetchEventManager.js +3 -3
- package/errors/CombinedGraphQLErrors.d.ts +2 -2
- package/errors/CombinedGraphQLErrors.js +3 -7
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/CombinedProtocolErrors.d.ts +2 -2
- package/errors/CombinedProtocolErrors.js +3 -8
- package/errors/CombinedProtocolErrors.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.js +2 -2
- package/incremental/handlers/notImplemented.js +1 -1
- package/invariantErrorCodes.js +125 -120
- package/link/batch-http/BaseBatchHttpLink.d.ts +0 -7
- package/link/batch-http/BaseBatchHttpLink.js +9 -18
- package/link/batch-http/BaseBatchHttpLink.js.map +1 -1
- 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.js +29 -17
- package/local-state/LocalState.js.map +1 -1
- package/masking/maskDefinition.js +21 -3
- package/masking/maskDefinition.js.map +1 -1
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/utils.js +3 -3
- package/package.json +2 -2
- 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/useFragment.js +8 -2
- package/react/hooks/useFragment.js.map +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/useSuspenseFragment.js +10 -4
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/hooks-compiled/internal/validateSuspenseHookOptions.js +2 -2
- package/react/hooks-compiled/useApolloClient.js +1 -1
- package/react/hooks-compiled/useFragment.js +56 -32
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.js +2 -2
- package/react/hooks-compiled/useLoadableQuery.js +2 -2
- package/react/hooks-compiled/useSubscription.js +1 -1
- package/react/hooks-compiled/useSuspenseFragment.js +10 -4
- package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js +1 -1
- package/react/internal/cache/FragmentReference.d.ts +4 -5
- package/react/internal/cache/FragmentReference.js +2 -2
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +4 -5
- package/react/internal/cache/SuspenseCache.js +3 -3
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/cache/types.d.ts +0 -5
- package/react/internal/cache/types.js.map +1 -1
- package/react/ssr/prerenderStatic.js +2 -2
- package/testing/core/mocking/mockLink.js +4 -4
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/internal/DeepMerger.d.ts +13 -3
- package/utilities/internal/DeepMerger.js +6 -2
- package/utilities/internal/DeepMerger.js.map +1 -1
- package/utilities/internal/argumentsObjectFromField.d.ts +2 -2
- package/utilities/internal/argumentsObjectFromField.js.map +1 -1
- package/utilities/internal/constants.d.ts +32 -0
- package/utilities/internal/constants.js +32 -0
- package/utilities/internal/constants.js.map +1 -1
- package/utilities/internal/createArgumentNode.d.ts +3 -0
- package/utilities/internal/createArgumentNode.js +11 -0
- package/utilities/internal/createArgumentNode.js.map +1 -0
- package/utilities/internal/createDirectiveNode.d.ts +3 -0
- package/utilities/internal/createDirectiveNode.js +11 -0
- package/utilities/internal/createDirectiveNode.js.map +1 -0
- package/utilities/internal/createFragmentArgumentNode.d.ts +3 -0
- package/utilities/internal/createFragmentArgumentNode.js +10 -0
- package/utilities/internal/createFragmentArgumentNode.js.map +1 -0
- package/utilities/internal/createFragmentSpreadNode.d.ts +6 -0
- package/utilities/internal/createFragmentSpreadNode.js +17 -0
- package/utilities/internal/createFragmentSpreadNode.js.map +1 -0
- package/utilities/internal/createNameNode.d.ts +3 -0
- package/utilities/internal/createNameNode.js +5 -0
- package/utilities/internal/createNameNode.js.map +1 -0
- package/utilities/internal/createValueNode.d.ts +12 -0
- package/utilities/internal/createValueNode.js +24 -0
- package/utilities/internal/createValueNode.js.map +1 -0
- package/utilities/internal/createVariableNode.d.ts +3 -0
- package/utilities/internal/createVariableNode.js +6 -0
- package/utilities/internal/createVariableNode.js.map +1 -0
- package/utilities/internal/equalByQuery.d.ts +2 -3
- package/utilities/internal/equalByQuery.js +16 -3
- package/utilities/internal/equalByQuery.js.map +1 -1
- package/utilities/internal/getDefaultValues.d.ts +2 -2
- package/utilities/internal/getDefaultValues.js.map +1 -1
- package/utilities/internal/getFragmentDefinition.js +3 -3
- package/utilities/internal/getFragmentDefinition.js.map +1 -1
- package/utilities/internal/getFragmentFromSelection.js +1 -1
- package/utilities/internal/getFragmentQueryDocument.js +20 -9
- package/utilities/internal/getFragmentQueryDocument.js.map +1 -1
- package/utilities/internal/getFragmentScope.d.ts +13 -0
- package/utilities/internal/getFragmentScope.js +20 -0
- package/utilities/internal/getFragmentScope.js.map +1 -0
- package/utilities/internal/getFragmentVariables.d.ts +12 -0
- package/utilities/internal/getFragmentVariables.js +30 -0
- package/utilities/internal/getFragmentVariables.js.map +1 -0
- package/utilities/internal/getMainDefinition.js +1 -1
- package/utilities/internal/getQueryDefinition.js +1 -1
- package/utilities/internal/index.d.ts +6 -1
- package/utilities/internal/index.js +4 -1
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isNonEmptyObject.d.ts +7 -0
- package/utilities/internal/isNonEmptyObject.js +10 -0
- package/utilities/internal/isNonEmptyObject.js.map +1 -0
- package/utilities/internal/isNonNullObject.d.ts +1 -1
- package/utilities/internal/isNonNullObject.js.map +1 -1
- package/utilities/internal/mapObservableFragment.d.ts +5 -1
- package/utilities/internal/mapObservableFragment.js +14 -9
- package/utilities/internal/mapObservableFragment.js.map +1 -1
- package/utilities/internal/mergeDeepArray.d.ts +2 -1
- package/utilities/internal/mergeDeepArray.js +2 -2
- package/utilities/internal/mergeDeepArray.js.map +1 -1
- package/utilities/internal/removeDirectivesFromDocument.js +121 -62
- package/utilities/internal/removeDirectivesFromDocument.js.map +1 -1
- package/utilities/internal/removeFragmentSpreads.d.ts +18 -2
- package/utilities/internal/removeFragmentSpreads.js +56 -3
- package/utilities/internal/removeFragmentSpreads.js.map +1 -1
- package/utilities/internal/shouldInclude.js +4 -4
- package/utilities/internal/types/FragmentInfo.d.ts +14 -0
- package/utilities/internal/types/FragmentInfo.js +2 -0
- package/utilities/internal/types/FragmentInfo.js.map +1 -0
- package/utilities/internal/types/Mutable.d.ts +4 -0
- package/utilities/internal/types/Mutable.js +2 -0
- package/utilities/internal/types/Mutable.js.map +1 -0
- package/utilities/internal/types/ObjectWithFragmentInfo.d.ts +13 -0
- package/utilities/internal/types/ObjectWithFragmentInfo.js +2 -0
- package/utilities/internal/types/ObjectWithFragmentInfo.js.map +1 -0
- package/utilities/internal/valueToObjectRepresentation.js +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
package/core/ObservableQuery.js
CHANGED
|
@@ -102,7 +102,7 @@ export class ObservableQuery {
|
|
|
102
102
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
103
103
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
104
104
|
if (options[variablesUnknownSymbol]) {
|
|
105
|
-
invariant(fetchPolicy === "standby",
|
|
105
|
+
invariant(fetchPolicy === "standby", 86);
|
|
106
106
|
this.variablesUnknown = true;
|
|
107
107
|
}
|
|
108
108
|
this.lastQuery = transformedQuery;
|
|
@@ -411,7 +411,7 @@ export class ObservableQuery {
|
|
|
411
411
|
const queryDef = getQueryDefinition(this.query);
|
|
412
412
|
const vars = queryDef.variableDefinitions;
|
|
413
413
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
414
|
-
__DEV__ && invariant.warn(
|
|
414
|
+
__DEV__ && invariant.warn(87, variables, queryDef.name?.value || queryDef);
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
417
|
if (variables && !equal(this.variables, variables)) {
|
|
@@ -426,7 +426,7 @@ export class ObservableQuery {
|
|
|
426
426
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
427
427
|
invariant(
|
|
428
428
|
this.options.fetchPolicy !== "cache-only",
|
|
429
|
-
|
|
429
|
+
88,
|
|
430
430
|
getOperationName(this.query, "(anonymous)")
|
|
431
431
|
);
|
|
432
432
|
const combinedOptions = {
|
|
@@ -460,7 +460,7 @@ export class ObservableQuery {
|
|
|
460
460
|
let wasUpdated = false;
|
|
461
461
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
462
462
|
if (!isCached) {
|
|
463
|
-
invariant(updateQuery,
|
|
463
|
+
invariant(updateQuery, 89);
|
|
464
464
|
}
|
|
465
465
|
const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
|
|
466
466
|
pushNotification({
|
|
@@ -634,7 +634,7 @@ export class ObservableQuery {
|
|
|
634
634
|
onError(error);
|
|
635
635
|
}
|
|
636
636
|
else {
|
|
637
|
-
invariant.error(
|
|
637
|
+
invariant.error(90, error);
|
|
638
638
|
}
|
|
639
639
|
return;
|
|
640
640
|
}
|
|
@@ -885,7 +885,7 @@ export class ObservableQuery {
|
|
|
885
885
|
if (!this.didWarnCacheOnlyPolling &&
|
|
886
886
|
pollInterval &&
|
|
887
887
|
fetchPolicy === "cache-only") {
|
|
888
|
-
__DEV__ && invariant.warn(
|
|
888
|
+
__DEV__ && invariant.warn(91, getOperationName(this.query, "(anonymous)"));
|
|
889
889
|
this.didWarnCacheOnlyPolling = true;
|
|
890
890
|
}
|
|
891
891
|
}
|
|
@@ -1511,7 +1511,7 @@ export class ObservableQuery {
|
|
|
1511
1511
|
}
|
|
1512
1512
|
export function logMissingFieldErrors(missing) {
|
|
1513
1513
|
if (__DEV__ && missing) {
|
|
1514
|
-
__DEV__ && invariant.debug(
|
|
1514
|
+
__DEV__ && invariant.debug(92, missing);
|
|
1515
1515
|
}
|
|
1516
1516
|
}
|
|
1517
1517
|
function isEqualQuery(a, b) {
|
|
@@ -1555,6 +1555,6 @@ function getTrackingOperatorPromise(defaultValue) {
|
|
|
1555
1555
|
return { promise, operator };
|
|
1556
1556
|
}
|
|
1557
1557
|
function warnOnFeud(query, diff) {
|
|
1558
|
-
__DEV__ && invariant.warn(
|
|
1558
|
+
__DEV__ && invariant.warn(93, getOperationName(query, "(anonymous)"), diff.missing?.missing);
|
|
1559
1559
|
}
|
|
1560
1560
|
//# sourceMappingURL=ObservableQuery.js.map
|
package/core/QueryInfo.js
CHANGED
package/core/QueryManager.js
CHANGED
|
@@ -99,7 +99,7 @@ export class QueryManager {
|
|
|
99
99
|
*/
|
|
100
100
|
stop() {
|
|
101
101
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
102
|
-
this.cancelPendingFetches(newInvariantError(
|
|
102
|
+
this.cancelPendingFetches(newInvariantError(95));
|
|
103
103
|
}
|
|
104
104
|
cancelPendingFetches(error) {
|
|
105
105
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
@@ -112,7 +112,7 @@ export class QueryManager {
|
|
|
112
112
|
variables = this.getVariables(mutation, variables);
|
|
113
113
|
if (hasClientExports) {
|
|
114
114
|
if (__DEV__) {
|
|
115
|
-
invariant(this.localState,
|
|
115
|
+
invariant(this.localState, 96, getOperationName(mutation, "(anonymous)"));
|
|
116
116
|
}
|
|
117
117
|
variables = await this.localState.getExportedVariables({
|
|
118
118
|
client: this.client,
|
|
@@ -345,7 +345,7 @@ export class QueryManager {
|
|
|
345
345
|
// depend on values that previously existed in the data portion of the
|
|
346
346
|
// store. So, we cancel the promises and observers that we have issued
|
|
347
347
|
// so far and not yet resolved (in the case of queries).
|
|
348
|
-
this.cancelPendingFetches(newInvariantError(
|
|
348
|
+
this.cancelPendingFetches(newInvariantError(97));
|
|
349
349
|
this.obsQueries.forEach((observableQuery) => {
|
|
350
350
|
// Set loading to true so listeners don't trigger unless they want
|
|
351
351
|
// results with partial data.
|
|
@@ -415,10 +415,10 @@ export class QueryManager {
|
|
|
415
415
|
if (!included) {
|
|
416
416
|
const queryName = queryNames.get(nameOrQueryString);
|
|
417
417
|
if (queryName) {
|
|
418
|
-
__DEV__ && invariant.warn(
|
|
418
|
+
__DEV__ && invariant.warn(98, queryName);
|
|
419
419
|
}
|
|
420
420
|
else {
|
|
421
|
-
__DEV__ && invariant.warn(
|
|
421
|
+
__DEV__ && invariant.warn(99);
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
});
|
|
@@ -447,7 +447,7 @@ export class QueryManager {
|
|
|
447
447
|
if (__DEV__) {
|
|
448
448
|
invariant(
|
|
449
449
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
450
|
-
|
|
450
|
+
100,
|
|
451
451
|
getOperationName(query, "(anonymous)")
|
|
452
452
|
);
|
|
453
453
|
}
|
|
@@ -599,14 +599,14 @@ export class QueryManager {
|
|
|
599
599
|
if (__DEV__) {
|
|
600
600
|
invariant(
|
|
601
601
|
this.localState,
|
|
602
|
-
|
|
602
|
+
101,
|
|
603
603
|
operation[0].toUpperCase() + operation.slice(1),
|
|
604
604
|
operationName ?? "(anonymous)"
|
|
605
605
|
);
|
|
606
606
|
}
|
|
607
607
|
invariant(
|
|
608
608
|
!hasIncrementalDirective,
|
|
609
|
-
|
|
609
|
+
102,
|
|
610
610
|
operation[0].toUpperCase() + operation.slice(1),
|
|
611
611
|
operationName ?? "(anonymous)"
|
|
612
612
|
);
|
|
@@ -774,7 +774,7 @@ export class QueryManager {
|
|
|
774
774
|
// we deprecated and removed LocalState.
|
|
775
775
|
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
776
776
|
if (__DEV__) {
|
|
777
|
-
invariant(this.localState,
|
|
777
|
+
invariant(this.localState, 103, getOperationName(normalized.query, "(anonymous)"));
|
|
778
778
|
}
|
|
779
779
|
observable = from(this.localState.getExportedVariables({
|
|
780
780
|
client: this.client,
|
|
@@ -947,7 +947,7 @@ export class QueryManager {
|
|
|
947
947
|
!isFullyUnmaskedOperation(document) &&
|
|
948
948
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
949
949
|
this.noCacheWarningsByCause.add(cause);
|
|
950
|
-
__DEV__ && invariant.warn(
|
|
950
|
+
__DEV__ && invariant.warn(104, getOperationName(document, `Unnamed ${operationType ?? "operation"}`));
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
953
|
return (this.dataMasking ?
|
|
@@ -1010,7 +1010,7 @@ export class QueryManager {
|
|
|
1010
1010
|
(diff.complete || returnPartialData) &&
|
|
1011
1011
|
this.getDocumentInfo(query).hasForcedResolvers) {
|
|
1012
1012
|
if (__DEV__) {
|
|
1013
|
-
invariant(this.localState,
|
|
1013
|
+
invariant(this.localState, 105, getOperationName(query, "(anonymous)"));
|
|
1014
1014
|
}
|
|
1015
1015
|
onCacheHit();
|
|
1016
1016
|
return from(this.localState.execute({
|
|
@@ -1131,7 +1131,7 @@ function validateDidEmitValue() {
|
|
|
1131
1131
|
didEmitValue = true;
|
|
1132
1132
|
},
|
|
1133
1133
|
complete() {
|
|
1134
|
-
invariant(didEmitValue,
|
|
1134
|
+
invariant(didEmitValue, 106);
|
|
1135
1135
|
},
|
|
1136
1136
|
});
|
|
1137
1137
|
}
|
|
@@ -27,7 +27,7 @@ export class RefetchEventManager {
|
|
|
27
27
|
}
|
|
28
28
|
if (this.client) {
|
|
29
29
|
if (__DEV__) {
|
|
30
|
-
__DEV__ && invariant.warn(
|
|
30
|
+
__DEV__ && invariant.warn(107);
|
|
31
31
|
}
|
|
32
32
|
this.disconnect();
|
|
33
33
|
}
|
|
@@ -96,13 +96,13 @@ export class RefetchEventManager {
|
|
|
96
96
|
const [payload] = args;
|
|
97
97
|
if (!this.client) {
|
|
98
98
|
if (__DEV__) {
|
|
99
|
-
__DEV__ && invariant.warn(
|
|
99
|
+
__DEV__ && invariant.warn(108, source);
|
|
100
100
|
}
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
if (!this.hasSource(source)) {
|
|
104
104
|
if (__DEV__) {
|
|
105
|
-
__DEV__ && invariant.warn(
|
|
105
|
+
__DEV__ && invariant.warn(109, source);
|
|
106
106
|
}
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
@@ -141,7 +141,7 @@ export declare namespace CombinedGraphQLErrors {
|
|
|
141
141
|
* }
|
|
142
142
|
* ```
|
|
143
143
|
*/
|
|
144
|
-
export declare class CombinedGraphQLErrors extends
|
|
144
|
+
export declare class CombinedGraphQLErrors extends AggregateError {
|
|
145
145
|
/**
|
|
146
146
|
* A method that determines whether an error is a `CombinedGraphQLErrors`
|
|
147
147
|
* object. This method enables TypeScript to narrow the error type.
|
|
@@ -176,7 +176,7 @@ export declare class CombinedGraphQLErrors extends Error {
|
|
|
176
176
|
/**
|
|
177
177
|
* The raw list of GraphQL errors returned by the `errors` field in the GraphQL response.
|
|
178
178
|
*/
|
|
179
|
-
|
|
179
|
+
errors: Array<GraphQLFormattedError>;
|
|
180
180
|
/**
|
|
181
181
|
* Partial data returned in the `data` field of the GraphQL response.
|
|
182
182
|
*/
|
|
@@ -39,7 +39,7 @@ function defaultFormatMessage(errors) {
|
|
|
39
39
|
* }
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
export class CombinedGraphQLErrors extends
|
|
42
|
+
export class CombinedGraphQLErrors extends AggregateError {
|
|
43
43
|
/**
|
|
44
44
|
* A method that determines whether an error is a `CombinedGraphQLErrors`
|
|
45
45
|
* object. This method enables TypeScript to narrow the error type.
|
|
@@ -74,10 +74,6 @@ export class CombinedGraphQLErrors extends Error {
|
|
|
74
74
|
*/
|
|
75
75
|
static formatMessage = defaultFormatMessage;
|
|
76
76
|
/**
|
|
77
|
-
* The raw list of GraphQL errors returned by the `errors` field in the GraphQL response.
|
|
78
|
-
*/
|
|
79
|
-
errors;
|
|
80
|
-
/**
|
|
81
77
|
* Partial data returned in the `data` field of the GraphQL response.
|
|
82
78
|
*/
|
|
83
79
|
data;
|
|
@@ -86,11 +82,11 @@ export class CombinedGraphQLErrors extends Error {
|
|
|
86
82
|
*/
|
|
87
83
|
extensions;
|
|
88
84
|
constructor(result, errors = result.errors || []) {
|
|
89
|
-
super(CombinedGraphQLErrors.formatMessage(errors, {
|
|
85
|
+
super(errors, CombinedGraphQLErrors.formatMessage(errors, {
|
|
90
86
|
result,
|
|
91
87
|
defaultFormatMessage,
|
|
92
88
|
}));
|
|
93
|
-
this
|
|
89
|
+
Object.defineProperty(this, "errors", { enumerable: true });
|
|
94
90
|
this.data = result.data;
|
|
95
91
|
this.extensions = result.extensions;
|
|
96
92
|
this.name = "CombinedGraphQLErrors";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CombinedGraphQLErrors.js","sources":["../../src/errors/CombinedGraphQLErrors.ts"],"sourcesContent":["import type { FormattedExecutionResult, GraphQLFormattedError } from \"graphql\";\n\nimport type { ApolloLink } from \"@apollo/client/link\";\n\nimport { brand, isBranded } from \"./utils.js\";\n\nexport declare namespace CombinedGraphQLErrors {\n export interface MessageFormatterOptions {\n /**\n * The raw result returned from the server.\n */\n result: ApolloLink.Result<unknown>;\n\n /**\n * The default message formatter. Call this to get a string with the default\n * formatted message.\n *\n * @remarks\n * To format part of the message using the default message formatter, call\n * the `defaultFormatMessage` function provided to the `options` argument of\n * your message formatter.\n *\n * @example\n *\n * The following example prepends a string to the message and uses the\n * default message formatter to format the error messages.\n *\n * ```ts\n * CombinedGraphQLErrors.formatMessage = (errors, { defaultFormatMessage }) => {\n * return `[GraphQL errors]: ${defaultFormatMessage(errors)}`;\n * };\n * ```\n */\n defaultFormatMessage: (\n errors: ReadonlyArray<GraphQLFormattedError>\n ) => string;\n }\n\n /**\n * By default, `CombinedGraphQLErrors` formats the `message` property by\n * joining each error's `message` field with a newline. To customize the\n * format of the `message`, such as changing the delimiter or adding a message\n * prefix, override the static `formatMessage` method.\n *\n * @example\n *\n * The following example demonstrates how to format the error message by\n * joining each error with a comma.\n *\n * ```ts\n * import { CombinedGraphQLErrors } from \"@apollo/client/errors\";\n *\n * CombinedGraphQLErrors.formatMessage = (errors) => {\n * return errors.map((error) => error.message).join(\", \");\n * };\n * ```\n *\n * @remarks\n *\n * See the [`formatMessage`](https://www.apollographql.com/docs/react/api/errors/CombinedGraphQLErrors#formatmessage) docs for details about the parameters provided to the `formatMessage` function.\n *\n * > [!NOTE]\n * > The message formatter needs to be configured before any operation is executed by Apollo Client, otherwise the default message formatter is used. We recommend configuring the message formatter before initializing your `ApolloClient` instance.\n *\n * @param errors - The array of GraphQL errors returned from the server in the\n * `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n export type MessageFormatter = (\n errors: ReadonlyArray<GraphQLFormattedError>,\n options: MessageFormatterOptions\n ) => string;\n\n namespace DocumentationTypes {\n /**\n * A function that formats the error message used for the error's `message`\n * property. Override this method to provide your own formatting.\n *\n * @remarks\n *\n * The `formatMessage` function is called by the `CombinedGraphQLErrors`\n * constructor to provide a formatted message as the `message` property of the\n * `CombinedGraphQLErrors` object. Follow the [\"Providing a custom message\n * formatter\"](https://www.apollographql.com/docs/react/api/errors/CombinedGraphQLErrors#providing-a-custom-message-formatter) guide to learn how to modify the message format.\n *\n * @param errors - The array of GraphQL errors returned from the server in\n * the `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n function formatMessage(\n errors: ReadonlyArray<GraphQLFormattedError>,\n options: MessageFormatterOptions\n ): string;\n\n interface InstanceProperties {\n /**\n * The raw list of GraphQL errors returned by the `errors` field in the GraphQL response.\n */\n readonly errors: ReadonlyArray<GraphQLFormattedError>;\n\n /**\n * Partial data returned in the `data` field of the GraphQL response.\n */\n readonly data: Record<string, unknown> | null | undefined;\n\n /**\n * Extensions returned by the `extensions` field in the GraphQL response.\n */\n readonly extensions: Record<string, unknown> | undefined;\n }\n\n /**\n * A method that determines whether an error is a `{{errorClass}}`\n * object. This method enables TypeScript to narrow the error type.\n *\n * @example\n *\n * ```ts\n * if ({{errorClass}}.is(error)) {\n * // TypeScript now knows `error` is a `{{errorClass}}` object\n * console.log(error.errors);\n * }\n * ```\n */\n function is(error: unknown): boolean;\n }\n}\n\nfunction defaultFormatMessage(errors: ReadonlyArray<GraphQLFormattedError>) {\n return (\n errors\n // Handle non-spec-compliant servers: See #1185\n .filter((e) => e)\n .map((e) => e.message || \"Error message not found.\")\n .join(\"\\n\")\n );\n}\n\n/**\n * Represents the combined list of GraphQL errors returned from the server in a\n * GraphQL response. This error type is used when your GraphQL operation returns\n * errors in the `errors` field of the response.\n *\n * @remarks\n *\n * When your GraphQL operation encounters errors on the server side (such as\n * resolver errors, validation errors, or syntax errors), the server returns\n * these errors in the `errors` array of the GraphQL response. Apollo Client\n * wraps these errors in a `CombinedGraphQLErrors` object, which provides access\n * to the individual errors while maintaining additional context about the\n * response.\n *\n * @example\n *\n * ```ts\n * import { CombinedGraphQLErrors } from \"@apollo/client/errors\";\n *\n * // Check if an error is a CombinedGraphQLErrors object\n * if (CombinedGraphQLErrors.is(error)) {\n * // Access individual GraphQL errors\n * error.errors.forEach((graphQLError) => {\n * console.log(graphQLError.message);\n * console.log(graphQLError.path);\n * console.log(graphQLError.locations);\n * });\n *\n * // Access the original GraphQL result\n * console.log(error.result);\n * }\n * ```\n */\nexport class CombinedGraphQLErrors extends Error {\n /**\n * {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.is:function(1) {\"errorClass\":\"CombinedGraphQLErrors\"}}\n */\n static is(error: unknown): error is CombinedGraphQLErrors {\n return isBranded(error, \"CombinedGraphQLErrors\");\n }\n\n /** {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.formatMessage:function(1)} */\n static formatMessage: CombinedGraphQLErrors.MessageFormatter =\n defaultFormatMessage;\n\n /** {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.InstanceProperties#errors:member} */\n readonly errors: ReadonlyArray<GraphQLFormattedError>;\n\n /** {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.InstanceProperties#data:member} */\n readonly data: Record<string, unknown> | null | undefined;\n\n /** {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.InstanceProperties#extensions:member} */\n readonly extensions: Record<string, unknown> | undefined;\n\n constructor(result: FormattedExecutionResult<any>);\n constructor(\n result: ApolloLink.Result<any>,\n errors: ReadonlyArray<GraphQLFormattedError>\n );\n\n constructor(\n result: ApolloLink.Result<any> | FormattedExecutionResult<any>,\n errors = (result as FormattedExecutionResult<any>).errors || []\n ) {\n super(\n CombinedGraphQLErrors.formatMessage(errors, {\n result,\n defaultFormatMessage,\n })\n );\n this.errors = errors;\n this.data = (result as Partial<FormattedExecutionResult>).data;\n this.extensions = (result as Partial<FormattedExecutionResult>).extensions;\n this.name = \"Combin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C,CAApE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8E;QAC1E,CAAJ,CAAA,CAAA,CAAQ,CAAC,CAAT,CAAA,CAAA,EAAA,EAAgB,CAAhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuC;QAEnC,CAAJ,CAAA,CAAA,CAAA,CAAS,CAAC,CAAV,CAAA,CAAA,CAAc,CAAC;QACX,CAAJ,CAAA,CAAA,CAAA,CAAA,CAAU,CAAC,CAAX,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyB,CAAC,CAA1B,CAAA,CAAA,CAA8B,EAAE,CAAhC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqD,CAAC,CAAtD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA+D,CAAC;IAC9D;;"}
|
|
1
|
+
{"version":3,"file":"CombinedGraphQLErrors.js","sources":["../../src/errors/CombinedGraphQLErrors.ts"],"sourcesContent":["import type { FormattedExecutionResult, GraphQLFormattedError } from \"graphql\";\n\nimport type { ApolloLink } from \"@apollo/client/link\";\n\nimport { brand, isBranded } from \"./utils.js\";\n\nexport declare namespace CombinedGraphQLErrors {\n export interface MessageFormatterOptions {\n /**\n * The raw result returned from the server.\n */\n result: ApolloLink.Result<unknown>;\n\n /**\n * The default message formatter. Call this to get a string with the default\n * formatted message.\n *\n * @remarks\n * To format part of the message using the default message formatter, call\n * the `defaultFormatMessage` function provided to the `options` argument of\n * your message formatter.\n *\n * @example\n *\n * The following example prepends a string to the message and uses the\n * default message formatter to format the error messages.\n *\n * ```ts\n * CombinedGraphQLErrors.formatMessage = (errors, { defaultFormatMessage }) => {\n * return `[GraphQL errors]: ${defaultFormatMessage(errors)}`;\n * };\n * ```\n */\n defaultFormatMessage: (\n errors: ReadonlyArray<GraphQLFormattedError>\n ) => string;\n }\n\n /**\n * By default, `CombinedGraphQLErrors` formats the `message` property by\n * joining each error's `message` field with a newline. To customize the\n * format of the `message`, such as changing the delimiter or adding a message\n * prefix, override the static `formatMessage` method.\n *\n * @example\n *\n * The following example demonstrates how to format the error message by\n * joining each error with a comma.\n *\n * ```ts\n * import { CombinedGraphQLErrors } from \"@apollo/client/errors\";\n *\n * CombinedGraphQLErrors.formatMessage = (errors) => {\n * return errors.map((error) => error.message).join(\", \");\n * };\n * ```\n *\n * @remarks\n *\n * See the [`formatMessage`](https://www.apollographql.com/docs/react/api/errors/CombinedGraphQLErrors#formatmessage) docs for details about the parameters provided to the `formatMessage` function.\n *\n * > [!NOTE]\n * > The message formatter needs to be configured before any operation is executed by Apollo Client, otherwise the default message formatter is used. We recommend configuring the message formatter before initializing your `ApolloClient` instance.\n *\n * @param errors - The array of GraphQL errors returned from the server in the\n * `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n export type MessageFormatter = (\n errors: ReadonlyArray<GraphQLFormattedError>,\n options: MessageFormatterOptions\n ) => string;\n\n namespace DocumentationTypes {\n /**\n * A function that formats the error message used for the error's `message`\n * property. Override this method to provide your own formatting.\n *\n * @remarks\n *\n * The `formatMessage` function is called by the `CombinedGraphQLErrors`\n * constructor to provide a formatted message as the `message` property of the\n * `CombinedGraphQLErrors` object. Follow the [\"Providing a custom message\n * formatter\"](https://www.apollographql.com/docs/react/api/errors/CombinedGraphQLErrors#providing-a-custom-message-formatter) guide to learn how to modify the message format.\n *\n * @param errors - The array of GraphQL errors returned from the server in\n * the `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n function formatMessage(\n errors: ReadonlyArray<GraphQLFormattedError>,\n options: MessageFormatterOptions\n ): string;\n\n interface InstanceProperties {\n /**\n * The raw list of GraphQL errors returned by the `errors` field in the GraphQL response.\n */\n readonly errors: ReadonlyArray<GraphQLFormattedError>;\n\n /**\n * Partial data returned in the `data` field of the GraphQL response.\n */\n readonly data: Record<string, unknown> | null | undefined;\n\n /**\n * Extensions returned by the `extensions` field in the GraphQL response.\n */\n readonly extensions: Record<string, unknown> | undefined;\n }\n\n /**\n * A method that determines whether an error is a `{{errorClass}}`\n * object. This method enables TypeScript to narrow the error type.\n *\n * @example\n *\n * ```ts\n * if ({{errorClass}}.is(error)) {\n * // TypeScript now knows `error` is a `{{errorClass}}` object\n * console.log(error.errors);\n * }\n * ```\n */\n function is(error: unknown): boolean;\n }\n}\n\nfunction defaultFormatMessage(errors: ReadonlyArray<GraphQLFormattedError>) {\n return (\n errors\n // Handle non-spec-compliant servers: See #1185\n .filter((e) => e)\n .map((e) => e.message || \"Error message not found.\")\n .join(\"\\n\")\n );\n}\n\n/**\n * Represents the combined list of GraphQL errors returned from the server in a\n * GraphQL response. This error type is used when your GraphQL operation returns\n * errors in the `errors` field of the response.\n *\n * @remarks\n *\n * When your GraphQL operation encounters errors on the server side (such as\n * resolver errors, validation errors, or syntax errors), the server returns\n * these errors in the `errors` array of the GraphQL response. Apollo Client\n * wraps these errors in a `CombinedGraphQLErrors` object, which provides access\n * to the individual errors while maintaining additional context about the\n * response.\n *\n * @example\n *\n * ```ts\n * import { CombinedGraphQLErrors } from \"@apollo/client/errors\";\n *\n * // Check if an error is a CombinedGraphQLErrors object\n * if (CombinedGraphQLErrors.is(error)) {\n * // Access individual GraphQL errors\n * error.errors.forEach((graphQLError) => {\n * console.log(graphQLError.message);\n * console.log(graphQLError.path);\n * console.log(graphQLError.locations);\n * });\n *\n * // Access the original GraphQL result\n * console.log(error.result);\n * }\n * ```\n */\nexport class CombinedGraphQLErrors extends AggregateError {\n /**\n * {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.is:function(1) {\"errorClass\":\"CombinedGraphQLErrors\"}}\n */\n static is(error: unknown): error is CombinedGraphQLErrors {\n return isBranded(error, \"CombinedGraphQLErrors\");\n }\n\n /** {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.formatMessage:function(1)} */\n static formatMessage: CombinedGraphQLErrors.MessageFormatter =\n defaultFormatMessage;\n\n /** {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.InstanceProperties#errors:member} */\n declare errors: Array<GraphQLFormattedError>;\n\n /** {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.InstanceProperties#data:member} */\n readonly data: Record<string, unknown> | null | undefined;\n\n /** {@inheritDoc @apollo/client!CombinedGraphQLErrors.DocumentationTypes.InstanceProperties#extensions:member} */\n readonly extensions: Record<string, unknown> | undefined;\n\n constructor(result: FormattedExecutionResult<any>);\n constructor(\n result: ApolloLink.Result<any>,\n errors: ReadonlyArray<GraphQLFormattedError>\n );\n\n constructor(\n result: ApolloLink.Result<any> | FormattedExecutionResult<any>,\n errors: ReadonlyArray<GraphQLFormattedError> = (\n result as FormattedExecutionResult<any>\n ).errors || []\n ) {\n super(\n errors,\n CombinedGraphQLErrors.formatMessage(errors, {\n result,\n defaultFormatMessage,\n })\n );\n Object.defineProperty(this, \"errors\", { enumerable: true });\n this.data = (result as Partial<FormattedExecutionResult>).data;\n this.extensions = (result as Partial<FormattedExecutionResult>).extensions;\n this.name = \"CombinedGraphQLErrors\";\n\n brand(this);\n Object.setPrototypeOf(this, CombinedGraphQLErrors.prototype);\n }\n}\n"],"names":[],"mappings":"AAIA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAc,EAAE,CAAhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAiC,CAAjC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA6C;AA8H7C,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAS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AA,EAAA,EAAgB,CAAhB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAuC;QAEnC,CAAJ,CAAA,CAAA,CAAA,CAAS,CAAC,CAAV,CAAA,CAAA,CAAc,CAAC;QACX,CAAJ,CAAA,CAAA,CAAA,CAAA,CAAU,CAAC,CAAX,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyB,CAAC,CAA1B,CAAA,CAAA,CAA8B,EAAE,CAAhC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqD,CAAC,CAAtD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA+D,CAAC;IAC9D;;"}
|
|
@@ -108,7 +108,7 @@ export declare namespace CombinedProtocolErrors {
|
|
|
108
108
|
* }
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
|
-
export declare class CombinedProtocolErrors extends
|
|
111
|
+
export declare class CombinedProtocolErrors extends AggregateError {
|
|
112
112
|
/**
|
|
113
113
|
* A method that determines whether an error is a `CombinedProtocolErrors`
|
|
114
114
|
* object. This method enables TypeScript to narrow the error type.
|
|
@@ -144,7 +144,7 @@ export declare class CombinedProtocolErrors extends Error {
|
|
|
144
144
|
* The raw list of errors returned by the top-level `errors` field in the
|
|
145
145
|
* multipart HTTP subscription response.
|
|
146
146
|
*/
|
|
147
|
-
|
|
147
|
+
errors: Array<GraphQLFormattedError>;
|
|
148
148
|
constructor(protocolErrors: Array<GraphQLFormattedError> | ReadonlyArray<GraphQLFormattedError>);
|
|
149
149
|
}
|
|
150
150
|
//# sourceMappingURL=CombinedProtocolErrors.d.ts.map
|
|
@@ -28,7 +28,7 @@ function defaultFormatMessage(errors) {
|
|
|
28
28
|
* }
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
export class CombinedProtocolErrors extends
|
|
31
|
+
export class CombinedProtocolErrors extends AggregateError {
|
|
32
32
|
/**
|
|
33
33
|
* A method that determines whether an error is a `CombinedProtocolErrors`
|
|
34
34
|
* object. This method enables TypeScript to narrow the error type.
|
|
@@ -62,17 +62,12 @@ export class CombinedProtocolErrors extends Error {
|
|
|
62
62
|
* the message.
|
|
63
63
|
*/
|
|
64
64
|
static formatMessage = defaultFormatMessage;
|
|
65
|
-
/**
|
|
66
|
-
* The raw list of errors returned by the top-level `errors` field in the
|
|
67
|
-
* multipart HTTP subscription response.
|
|
68
|
-
*/
|
|
69
|
-
errors;
|
|
70
65
|
constructor(protocolErrors) {
|
|
71
|
-
super(CombinedProtocolErrors.formatMessage(protocolErrors, {
|
|
66
|
+
super(protocolErrors, CombinedProtocolErrors.formatMessage(protocolErrors, {
|
|
72
67
|
defaultFormatMessage,
|
|
73
68
|
}));
|
|
74
69
|
this.name = "CombinedProtocolErrors";
|
|
75
|
-
this
|
|
70
|
+
Object.defineProperty(this, "errors", { enumerable: true });
|
|
76
71
|
brand(this);
|
|
77
72
|
Object.setPrototypeOf(this, CombinedProtocolErrors.prototype);
|
|
78
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CombinedProtocolErrors.js","sources":["../../src/errors/CombinedProtocolErrors.ts"],"sourcesContent":["import type { GraphQLFormattedError } from \"graphql\";\n\nimport { brand, isBranded } from \"./utils.js\";\n\nexport declare namespace CombinedProtocolErrors {\n export interface MessageFormatterOptions {\n /**\n * The default message formatter. Call this to get a string with the default\n * formatted message.\n *\n * @remarks\n * To format part of the message using the default message formatter, call\n * the `defaultFormatMessage` function provided to the `options` argument of\n * your message formatter.\n *\n * @example\n *\n * The following example prepends a string to the message and uses the\n * default message formatter to format the error messages.\n *\n * ```ts\n * CombinedProtocolErrors.formatMessage = (errors, { defaultFormatMessage }) => {\n * return `[Protocol errors]: ${defaultFormatMessage(errors)}`;\n * };\n * ```\n */\n defaultFormatMessage: (\n errors: ReadonlyArray<GraphQLFormattedError>\n ) => string;\n }\n\n /**\n * By default, `CombinedProtocolErrors` formats the `message` property by\n * joining each error's `message` field with a newline. To customize the\n * format of the `message`, such as changing the delimiter or adding a message\n * prefix, override the static `formatMessage` method.\n *\n * @remarks\n *\n * See the [`formatMessage`](https://www.apollographql.com/docs/react/api/errors/CombinedProtocolErrors) section for details about the parameters provided to the `formatMessage` function.\n *\n * > [!NOTE]\n * > The message formatter needs to be configured before any operation is executed by Apollo Client, otherwise the default message formatter is used. We recommend configuring the message formatter before initializing your `ApolloClient` instance.\n *\n * @example\n *\n * The following example demonstrates how to format the error message by\n * joining each error with a comma.\n *\n * ```ts\n * import { CombinedProtocolErrors } from \"@apollo/client/errors\";\n *\n * CombinedProtocolErrors.formatMessage = (errors) => {\n * return errors.map((error) => error.message).join(\", \");\n * };\n * ```\n *\n * @param errors - The array of GraphQL errors returned from the server in the\n * `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n export type MessageFormatter = (\n errors: ReadonlyArray<GraphQLFormattedError>,\n options: MessageFormatterOptions\n ) => string;\n\n namespace DocumentationTypes {\n /**\n * A function that formats the error message used for the error's `message`\n * property. Override this method to provide your own formatting.\n *\n * @remarks\n *\n * The `formatMessage` function is called by the `CombinedProtocolErrors`\n * constructor to provide a formatted message as the `message` property of the\n * `CombinedProtocolErrors` object. Follow the [\"Providing a custom message\n * formatter\"](https://www.apollographql.com/docs/react/api/errors/CombinedProtocolErrors#providing-a-custom-message-formatter) guide to learn how to modify the message format.\n *\n * @param errors - The array of GraphQL errors returned from the server in the\n * `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n function formatMessage(\n errors: ReadonlyArray<GraphQLFormattedError>,\n options: MessageFormatterOptions\n ): string;\n\n interface InstanceProperties {\n /**\n * The raw list of errors returned by the top-level `errors` field in the\n * multipart HTTP subscription response.\n */\n readonly errors: ReadonlyArray<GraphQLFormattedError>;\n }\n }\n}\n\nfunction defaultFormatMessage(errors: ReadonlyArray<GraphQLFormattedError>) {\n return errors.map((e) => e.message || \"Error message not found.\").join(\"\\n\");\n}\n\n/**\n * Fatal transport-level errors returned when executing a subscription using the\n * multipart HTTP subscription protocol. See the documentation on the\n * [multipart HTTP protocol for GraphQL Subscriptions](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol) for more information on these errors.\n *\n * @remarks\n *\n * These errors indicate issues with the subscription transport itself, rather\n * than GraphQL-level errors. They typically occur when there are problems\n * communicating with subgraphs from the Apollo Router.\n *\n * @example\n *\n * ```ts\n * import { CombinedProtocolErrors } from \"@apollo/client/errors\";\n *\n * // Check if an error is a CombinedProtocolErrors instance\n * if (CombinedProtocolErrors.is(error)) {\n * // Access individual protocol errors\n * error.errors.forEach((protocolError) => {\n * console.log(protocolError.message);\n * console.log(protocolError.extensions);\n * });\n * }\n * ```\n */\nexport class CombinedProtocolErrors extends
|
|
1
|
+
{"version":3,"file":"CombinedProtocolErrors.js","sources":["../../src/errors/CombinedProtocolErrors.ts"],"sourcesContent":["import type { GraphQLFormattedError } from \"graphql\";\n\nimport { brand, isBranded } from \"./utils.js\";\n\nexport declare namespace CombinedProtocolErrors {\n export interface MessageFormatterOptions {\n /**\n * The default message formatter. Call this to get a string with the default\n * formatted message.\n *\n * @remarks\n * To format part of the message using the default message formatter, call\n * the `defaultFormatMessage` function provided to the `options` argument of\n * your message formatter.\n *\n * @example\n *\n * The following example prepends a string to the message and uses the\n * default message formatter to format the error messages.\n *\n * ```ts\n * CombinedProtocolErrors.formatMessage = (errors, { defaultFormatMessage }) => {\n * return `[Protocol errors]: ${defaultFormatMessage(errors)}`;\n * };\n * ```\n */\n defaultFormatMessage: (\n errors: ReadonlyArray<GraphQLFormattedError>\n ) => string;\n }\n\n /**\n * By default, `CombinedProtocolErrors` formats the `message` property by\n * joining each error's `message` field with a newline. To customize the\n * format of the `message`, such as changing the delimiter or adding a message\n * prefix, override the static `formatMessage` method.\n *\n * @remarks\n *\n * See the [`formatMessage`](https://www.apollographql.com/docs/react/api/errors/CombinedProtocolErrors) section for details about the parameters provided to the `formatMessage` function.\n *\n * > [!NOTE]\n * > The message formatter needs to be configured before any operation is executed by Apollo Client, otherwise the default message formatter is used. We recommend configuring the message formatter before initializing your `ApolloClient` instance.\n *\n * @example\n *\n * The following example demonstrates how to format the error message by\n * joining each error with a comma.\n *\n * ```ts\n * import { CombinedProtocolErrors } from \"@apollo/client/errors\";\n *\n * CombinedProtocolErrors.formatMessage = (errors) => {\n * return errors.map((error) => error.message).join(\", \");\n * };\n * ```\n *\n * @param errors - The array of GraphQL errors returned from the server in the\n * `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n export type MessageFormatter = (\n errors: ReadonlyArray<GraphQLFormattedError>,\n options: MessageFormatterOptions\n ) => string;\n\n namespace DocumentationTypes {\n /**\n * A function that formats the error message used for the error's `message`\n * property. Override this method to provide your own formatting.\n *\n * @remarks\n *\n * The `formatMessage` function is called by the `CombinedProtocolErrors`\n * constructor to provide a formatted message as the `message` property of the\n * `CombinedProtocolErrors` object. Follow the [\"Providing a custom message\n * formatter\"](https://www.apollographql.com/docs/react/api/errors/CombinedProtocolErrors#providing-a-custom-message-formatter) guide to learn how to modify the message format.\n *\n * @param errors - The array of GraphQL errors returned from the server in the\n * `errors` field of the response.\n * @param options - Additional context that could be useful when formatting\n * the message.\n */\n function formatMessage(\n errors: ReadonlyArray<GraphQLFormattedError>,\n options: MessageFormatterOptions\n ): string;\n\n interface InstanceProperties {\n /**\n * The raw list of errors returned by the top-level `errors` field in the\n * multipart HTTP subscription response.\n */\n readonly errors: ReadonlyArray<GraphQLFormattedError>;\n }\n }\n}\n\nfunction defaultFormatMessage(errors: ReadonlyArray<GraphQLFormattedError>) {\n return errors.map((e) => e.message || \"Error message not found.\").join(\"\\n\");\n}\n\n/**\n * Fatal transport-level errors returned when executing a subscription using the\n * multipart HTTP subscription protocol. See the documentation on the\n * [multipart HTTP protocol for GraphQL Subscriptions](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol) for more information on these errors.\n *\n * @remarks\n *\n * These errors indicate issues with the subscription transport itself, rather\n * than GraphQL-level errors. They typically occur when there are problems\n * communicating with subgraphs from the Apollo Router.\n *\n * @example\n *\n * ```ts\n * import { CombinedProtocolErrors } from \"@apollo/client/errors\";\n *\n * // Check if an error is a CombinedProtocolErrors instance\n * if (CombinedProtocolErrors.is(error)) {\n * // Access individual protocol errors\n * error.errors.forEach((protocolError) => {\n * console.log(protocolError.message);\n * console.log(protocolError.extensions);\n * });\n * }\n * ```\n */\nexport class CombinedProtocolErrors extends AggregateError {\n /**\n * A method that determines whether an error is a `CombinedProtocolErrors`\n * object. This method enables TypeScript to narrow the error type.\n *\n * @example\n *\n * ```ts\n * if (CombinedProtocolErrors.is(error)) {\n * // TypeScript now knows `error` is a CombinedProtocolErrors object\n * console.log(error.errors);\n * }\n * ```\n */\n static is(error: unknown): error is CombinedProtocolErrors {\n return isBranded(error, \"CombinedProtocolErrors\");\n }\n\n /** {@inheritDoc @apollo/client!CombinedProtocolErrors.DocumentationTypes.formatMessage:function(1)} */\n static formatMessage: CombinedProtocolErrors.MessageFormatter =\n defaultFormatMessage;\n\n /** {@inheritDoc @apollo/client!CombinedProtocolErrors.DocumentationTypes.InstanceProperties#errors:member} */\n declare errors: Array<GraphQLFormattedError>;\n\n constructor(\n protocolErrors:\n | Array<GraphQLFormattedError>\n | ReadonlyArray<GraphQLFormattedError>\n ) {\n super(\n protocolErrors,\n CombinedProtocolErrors.formatMessage(protocolErrors, {\n defaultFormatMessage,\n })\n );\n this.name = \"CombinedProtocolErrors\";\n Object.defineProperty(this, \"errors\", { enumerable: true });\n\n brand(this);\n Object.setPrototypeOf(this, CombinedProtocolErrors.prototype);\n }\n}\n"],"names":[],"mappings":"AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,E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AA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAgE,CAAC;IAC/D;;"}
|
|
@@ -34,7 +34,7 @@ class IncrementalRequest {
|
|
|
34
34
|
const name = node.name.value;
|
|
35
35
|
if (name === "defer") {
|
|
36
36
|
const labelNode = node.arguments?.find((arg) => arg.name.value === "label");
|
|
37
|
-
invariant(labelNode && labelNode.value.kind === "StringValue",
|
|
37
|
+
invariant(labelNode && labelNode.value.kind === "StringValue", 69);
|
|
38
38
|
this.deferLabels.add(labelNode.value.value);
|
|
39
39
|
}
|
|
40
40
|
},
|
|
@@ -108,7 +108,7 @@ class IncrementalRequest {
|
|
|
108
108
|
if (hasIncrementalChunks(chunk)) {
|
|
109
109
|
for (const incremental of chunk.incremental) {
|
|
110
110
|
const pending = this.pendingMap.get(incremental.id);
|
|
111
|
-
invariant(pending,
|
|
111
|
+
invariant(pending, 70);
|
|
112
112
|
const path = pending.path.concat(incremental.subPath ?? []);
|
|
113
113
|
let data;
|
|
114
114
|
if ("items" in incremental) {
|
|
@@ -5,7 +5,7 @@ export class NotImplementedHandler {
|
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
7
|
prepareRequest(request) {
|
|
8
|
-
invariant(!hasDirectives(["defer", "stream"], request.query),
|
|
8
|
+
invariant(!hasDirectives(["defer", "stream"], request.query), 71);
|
|
9
9
|
return request;
|
|
10
10
|
}
|
|
11
11
|
extractErrors() { }
|