@apollo/client 4.0.0-alpha.4 → 4.0.0-alpha.5
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/eleven-kangaroos-jump.md +5 -0
- package/.changeset/forty-shrimps-fry.md +5 -0
- package/.changeset/grumpy-vans-type.md +5 -0
- package/.changeset/little-spoons-kick.md +7 -0
- package/.changeset/loud-cows-raise.md +7 -0
- package/.changeset/many-buses-allow.md +5 -0
- package/.changeset/poor-eels-punch.md +5 -0
- package/.changeset/pre.json +13 -0
- package/.changeset/real-teachers-peel.md +5 -0
- package/.changeset/slimy-chicken-melt.md +5 -0
- package/.changeset/thick-books-grin.md +5 -0
- package/.changeset/tough-rockets-allow.md +5 -0
- package/.changeset/tricky-tables-shave.md +5 -0
- package/.changeset/warm-ties-sit.md +7 -0
- package/CHANGELOG.md +40 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +3 -3
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +4 -4
- package/__cjs/core/LocalState.cjs +2 -2
- package/__cjs/core/ObservableQuery.cjs +15 -12
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +57 -35
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +3 -3
- package/__cjs/core/types.d.cts +32 -0
- package/__cjs/invariantErrorCodes.cjs +57 -77
- package/__cjs/link/core/ApolloLink.cjs +2 -2
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/utils/validateOperation.cjs +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 +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs.map +1 -1
- package/__cjs/react/context/ApolloContext.d.cts +2 -2
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/hooks/internal/wrapHook.cjs +26 -5
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +3 -1
- package/__cjs/react/hooks/useMutation.cjs +14 -19
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +4 -4
- package/__cjs/react/hooks/useQuery.cjs +82 -187
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +4 -0
- package/__cjs/react/hooks/useSubscription.cjs +8 -57
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +6 -42
- package/__cjs/react/hooks/useSuspenseQuery.cjs +2 -2
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/index.cjs +3 -1
- package/__cjs/react/internal/index.cjs.map +1 -1
- package/__cjs/react/internal/index.d.cts +1 -0
- package/__cjs/react/ssr/getDataFromTree.cjs +43 -12
- package/__cjs/react/ssr/getDataFromTree.cjs.map +1 -1
- package/__cjs/react/ssr/getDataFromTree.d.cts +5 -0
- package/__cjs/react/ssr/index.cjs +1 -3
- package/__cjs/react/ssr/index.cjs.map +1 -1
- package/__cjs/react/ssr/index.d.cts +0 -1
- package/__cjs/react/ssr/useSSRQuery.cjs +60 -0
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -0
- package/__cjs/react/ssr/useSSRQuery.d.cts +5 -0
- package/__cjs/react/types/deprecated.d.cts +1 -1
- package/__cjs/react/types/types.documentation.d.cts +4 -12
- package/__cjs/testing/matchers/index.cjs +2 -0
- package/__cjs/testing/matchers/index.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitStrictTyped.cjs +42 -0
- package/__cjs/testing/matchers/toEmitStrictTyped.cjs.map +1 -0
- package/__cjs/testing/matchers/toEmitStrictTyped.d.cts +7 -0
- package/__cjs/testing/matchers/toEqualStrictTyped.cjs +2 -20
- package/__cjs/testing/matchers/toEqualStrictTyped.cjs.map +1 -1
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +23 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.d.cts +2 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.d.cts +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +4 -4
- package/core/ApolloClient.js +3 -3
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.js +15 -12
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +3 -3
- package/core/QueryManager.js +58 -36
- package/core/QueryManager.js.map +1 -1
- package/core/types.d.ts +32 -0
- package/invariantErrorCodes.js +57 -77
- package/link/core/ApolloLink.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/utils.js +1 -1
- package/package.json +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.d.ts +2 -2
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/wrapHook.d.ts +3 -1
- package/react/hooks/internal/wrapHook.js +24 -5
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useMutation.d.ts +4 -4
- package/react/hooks/useMutation.js +14 -19
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +4 -0
- package/react/hooks/useQuery.js +83 -188
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +6 -42
- package/react/hooks/useSubscription.js +7 -53
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/index.d.ts +1 -0
- package/react/internal/index.js +2 -1
- package/react/internal/index.js.map +1 -1
- package/react/ssr/getDataFromTree.d.ts +5 -0
- package/react/ssr/getDataFromTree.js +43 -12
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/index.d.ts +0 -1
- package/react/ssr/index.js +0 -1
- package/react/ssr/index.js.map +1 -1
- package/react/ssr/useSSRQuery.d.ts +5 -0
- package/react/ssr/useSSRQuery.js +56 -0
- package/react/ssr/useSSRQuery.js.map +1 -0
- package/react/types/deprecated.d.ts +1 -1
- package/react/types/types.documentation.d.ts +4 -12
- package/testing/matchers/index.js +2 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toEmitStrictTyped.d.ts +7 -0
- package/testing/matchers/toEmitStrictTyped.js +38 -0
- package/testing/matchers/toEmitStrictTyped.js.map +1 -0
- package/testing/matchers/toEqualStrictTyped.js +1 -19
- package/testing/matchers/toEqualStrictTyped.js.map +1 -1
- package/testing/matchers/utils/getSerializableProperties.d.ts +2 -0
- package/testing/matchers/utils/getSerializableProperties.js +20 -0
- package/testing/matchers/utils/getSerializableProperties.js.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/__cjs/react/ssr/RenderPromises.cjs +0 -104
- package/__cjs/react/ssr/RenderPromises.cjs.map +0 -1
- package/__cjs/react/ssr/RenderPromises.d.cts +0 -25
- package/react/ssr/RenderPromises.d.ts +0 -25
- package/react/ssr/RenderPromises.js +0 -100
- package/react/ssr/RenderPromises.js.map +0 -1
package/core/QueryManager.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { DefaultOptions } from "./ApolloClient.js";
|
|
|
9
9
|
import type { LocalState } from "./LocalState.js";
|
|
10
10
|
import { NetworkStatus } from "./networkStatus.js";
|
|
11
11
|
import { ObservableQuery } from "./ObservableQuery.js";
|
|
12
|
-
import type { ApolloQueryResult, DefaultContext, InternalRefetchQueriesInclude, InternalRefetchQueriesMap, InternalRefetchQueriesOptions, MutationUpdaterFunction, OnQueryUpdated, OperationVariables } from "./types.js";
|
|
12
|
+
import type { ApolloQueryResult, DefaultContext, InternalRefetchQueriesInclude, InternalRefetchQueriesMap, InternalRefetchQueriesOptions, MutateResult, MutationUpdaterFunction, OnQueryUpdated, OperationVariables, SubscribeResult } from "./types.js";
|
|
13
13
|
import type { ErrorPolicy, MutationFetchPolicy, MutationOptions, QueryOptions, SubscriptionOptions, WatchQueryFetchPolicy, WatchQueryOptions } from "./watchQueryOptions.js";
|
|
14
14
|
interface MutationStoreValue {
|
|
15
15
|
mutation: DocumentNode;
|
|
@@ -89,7 +89,7 @@ export declare class QueryManager {
|
|
|
89
89
|
*/
|
|
90
90
|
stop(): void;
|
|
91
91
|
private cancelPendingFetches;
|
|
92
|
-
mutate<TData, TVariables extends OperationVariables, TContext extends Record<string, any>, TCache extends ApolloCache>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions<TData, TVariables, TContext>): Promise<
|
|
92
|
+
mutate<TData, TVariables extends OperationVariables, TContext extends Record<string, any>, TCache extends ApolloCache>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions<TData, TVariables, TContext>): Promise<MutateResult<MaybeMasked<TData>>>;
|
|
93
93
|
markMutationResult<TData, TVariables extends OperationVariables, TContext, TCache extends ApolloCache>(mutation: {
|
|
94
94
|
mutationId: string;
|
|
95
95
|
result: FetchResult<TData>;
|
|
@@ -134,7 +134,7 @@ export declare class QueryManager {
|
|
|
134
134
|
getObservableQueries(include?: InternalRefetchQueriesInclude): Map<string, ObservableQuery<any, OperationVariables>>;
|
|
135
135
|
reFetchObservableQueries(includeStandby?: boolean): Promise<ApolloQueryResult<any>[]>;
|
|
136
136
|
setObservableQuery(observableQuery: ObservableQuery<any, any>): void;
|
|
137
|
-
startGraphQLSubscription<TData = unknown>(options: SubscriptionOptions): Observable<
|
|
137
|
+
startGraphQLSubscription<TData = unknown>(options: SubscriptionOptions): Observable<SubscribeResult<TData>>;
|
|
138
138
|
stopQuery(queryId: string): void;
|
|
139
139
|
removeQuery(queryId: string): void;
|
|
140
140
|
broadcastQueries(): void;
|
package/core/QueryManager.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Trie } from "@wry/trie";
|
|
2
|
-
import { catchError, concat, EMPTY, from, lastValueFrom, map, mergeMap, mergeWith, Observable, of, share, shareReplay, Subject, tap, } from "rxjs";
|
|
2
|
+
import { catchError, concat, EMPTY, filter, from, lastValueFrom, map, mergeMap, mergeWith, Observable, of, share, shareReplay, Subject, tap, } from "rxjs";
|
|
3
3
|
import { canonicalStringify } from "@apollo/client/cache";
|
|
4
4
|
import { CombinedGraphQLErrors, graphQLResultHasProtocolErrors, UnconventionalError, } from "@apollo/client/errors";
|
|
5
5
|
import { PROTOCOL_ERRORS_SYMBOL } from "@apollo/client/errors";
|
|
@@ -88,15 +88,15 @@ export class QueryManager {
|
|
|
88
88
|
this.queries.forEach((_info, queryId) => {
|
|
89
89
|
this.removeQuery(queryId);
|
|
90
90
|
});
|
|
91
|
-
this.cancelPendingFetches(newInvariantError(
|
|
91
|
+
this.cancelPendingFetches(newInvariantError(68));
|
|
92
92
|
}
|
|
93
93
|
cancelPendingFetches(error) {
|
|
94
94
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
95
95
|
this.fetchCancelFns.clear();
|
|
96
96
|
}
|
|
97
97
|
async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy = this.defaultOptions.mutate?.fetchPolicy || "network-only", errorPolicy = this.defaultOptions.mutate?.errorPolicy || "none", keepRootFields, context, }) {
|
|
98
|
-
invariant(mutation,
|
|
99
|
-
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache",
|
|
98
|
+
invariant(mutation, 69);
|
|
99
|
+
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 70);
|
|
100
100
|
const mutationId = this.generateMutationId();
|
|
101
101
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
102
102
|
const { hasClientExports } = this.getDocumentInfo(mutation);
|
|
@@ -130,7 +130,8 @@ export class QueryManager {
|
|
|
130
130
|
optimisticResponse: isOptimistic ? optimisticResponse : void 0,
|
|
131
131
|
}, variables, {}, false)
|
|
132
132
|
.pipe(mergeMap((result) => {
|
|
133
|
-
|
|
133
|
+
const hasErrors = graphQLResultHasError(result);
|
|
134
|
+
if (hasErrors && errorPolicy === "none") {
|
|
134
135
|
throw new CombinedGraphQLErrors(getGraphQLErrorsFromResult(result));
|
|
135
136
|
}
|
|
136
137
|
if (mutationStoreValue) {
|
|
@@ -141,8 +142,7 @@ export class QueryManager {
|
|
|
141
142
|
if (typeof refetchQueries === "function") {
|
|
142
143
|
refetchQueries = refetchQueries(storeResult);
|
|
143
144
|
}
|
|
144
|
-
if (errorPolicy === "ignore" &&
|
|
145
|
-
graphQLResultHasError(storeResult)) {
|
|
145
|
+
if (errorPolicy === "ignore" && hasErrors) {
|
|
146
146
|
delete storeResult.errors;
|
|
147
147
|
}
|
|
148
148
|
return from(this.markMutationResult({
|
|
@@ -171,28 +171,40 @@ export class QueryManager {
|
|
|
171
171
|
// ExecutionPatchResult has arrived and we have assembled the
|
|
172
172
|
// multipart response into a single result.
|
|
173
173
|
if (!("hasNext" in storeResult) || storeResult.hasNext === false) {
|
|
174
|
-
|
|
175
|
-
...storeResult,
|
|
174
|
+
const result = {
|
|
176
175
|
data: this.maskOperation({
|
|
177
176
|
document: mutation,
|
|
178
177
|
data: storeResult.data,
|
|
179
178
|
fetchPolicy,
|
|
180
179
|
id: mutationId,
|
|
181
180
|
}),
|
|
182
|
-
}
|
|
181
|
+
};
|
|
182
|
+
if (graphQLResultHasError(storeResult)) {
|
|
183
|
+
result.error = new CombinedGraphQLErrors(getGraphQLErrorsFromResult(storeResult));
|
|
184
|
+
}
|
|
185
|
+
if (storeResult.extensions) {
|
|
186
|
+
result.extensions = storeResult.extensions;
|
|
187
|
+
}
|
|
188
|
+
resolve(result);
|
|
183
189
|
}
|
|
184
190
|
},
|
|
185
191
|
error: (err) => {
|
|
186
|
-
|
|
192
|
+
const error = maybeWrapError(err);
|
|
187
193
|
if (mutationStoreValue) {
|
|
188
194
|
mutationStoreValue.loading = false;
|
|
189
|
-
mutationStoreValue.error =
|
|
195
|
+
mutationStoreValue.error = error;
|
|
190
196
|
}
|
|
191
197
|
if (isOptimistic) {
|
|
192
198
|
this.cache.removeOptimistic(mutationId);
|
|
193
199
|
}
|
|
194
200
|
this.broadcastQueries();
|
|
195
|
-
|
|
201
|
+
if (errorPolicy === "ignore") {
|
|
202
|
+
return resolve({ data: undefined });
|
|
203
|
+
}
|
|
204
|
+
if (errorPolicy === "all") {
|
|
205
|
+
return resolve({ data: undefined, error });
|
|
206
|
+
}
|
|
207
|
+
reject(error);
|
|
196
208
|
},
|
|
197
209
|
});
|
|
198
210
|
});
|
|
@@ -465,10 +477,10 @@ export class QueryManager {
|
|
|
465
477
|
// TODO: catch `EmptyError` and rethrow as network error if `complete`
|
|
466
478
|
// notification is emitted without a value.
|
|
467
479
|
query(options, queryId = this.generateQueryId()) {
|
|
468
|
-
invariant(options.query,
|
|
469
|
-
invariant(options.query.kind === "Document",
|
|
470
|
-
invariant(!options.returnPartialData,
|
|
471
|
-
invariant(!options.pollInterval,
|
|
480
|
+
invariant(options.query, 71);
|
|
481
|
+
invariant(options.query.kind === "Document", 72);
|
|
482
|
+
invariant(!options.returnPartialData, 73);
|
|
483
|
+
invariant(!options.pollInterval, 74);
|
|
472
484
|
const query = this.transform(options.query);
|
|
473
485
|
return this.fetchQuery(queryId, { ...options, query })
|
|
474
486
|
.then((result) => result && {
|
|
@@ -502,7 +514,7 @@ export class QueryManager {
|
|
|
502
514
|
// depend on values that previously existed in the data portion of the
|
|
503
515
|
// store. So, we cancel the promises and observers that we have issued
|
|
504
516
|
// so far and not yet resolved (in the case of queries).
|
|
505
|
-
this.cancelPendingFetches(newInvariantError(
|
|
517
|
+
this.cancelPendingFetches(newInvariantError(75));
|
|
506
518
|
this.queries.forEach((queryInfo) => {
|
|
507
519
|
if (queryInfo.observableQuery) {
|
|
508
520
|
// Set loading to true so listeners don't trigger unless they want
|
|
@@ -590,10 +602,10 @@ export class QueryManager {
|
|
|
590
602
|
if (!included) {
|
|
591
603
|
const queryName = queryNames.get(nameOrQueryString);
|
|
592
604
|
if (queryName) {
|
|
593
|
-
__DEV__ && invariant.warn(
|
|
605
|
+
__DEV__ && invariant.warn(76, queryName);
|
|
594
606
|
}
|
|
595
607
|
else {
|
|
596
|
-
__DEV__ && invariant.warn(
|
|
608
|
+
__DEV__ && invariant.warn(77);
|
|
597
609
|
}
|
|
598
610
|
}
|
|
599
611
|
});
|
|
@@ -622,38 +634,48 @@ export class QueryManager {
|
|
|
622
634
|
const { fetchPolicy, errorPolicy = "none", context = {}, extensions = {}, } = options;
|
|
623
635
|
query = this.transform(query);
|
|
624
636
|
variables = this.getVariables(query, variables);
|
|
625
|
-
const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe(map((
|
|
637
|
+
const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe(map((rawResult) => {
|
|
626
638
|
if (fetchPolicy !== "no-cache") {
|
|
627
639
|
// the subscription interface should handle not sending us results we no longer subscribe to.
|
|
628
640
|
// XXX I don't think we ever send in an object with errors, but we might in the future...
|
|
629
|
-
if (shouldWriteResult(
|
|
641
|
+
if (shouldWriteResult(rawResult, errorPolicy)) {
|
|
630
642
|
this.cache.write({
|
|
631
643
|
query,
|
|
632
|
-
result:
|
|
644
|
+
result: rawResult.data,
|
|
633
645
|
dataId: "ROOT_SUBSCRIPTION",
|
|
634
646
|
variables: variables,
|
|
635
647
|
});
|
|
636
648
|
}
|
|
637
649
|
this.broadcastQueries();
|
|
638
650
|
}
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
651
|
+
const result = {
|
|
652
|
+
data: rawResult.data ?? undefined,
|
|
653
|
+
};
|
|
654
|
+
if (graphQLResultHasError(rawResult)) {
|
|
655
|
+
result.error = new CombinedGraphQLErrors(rawResult.errors);
|
|
656
|
+
}
|
|
657
|
+
else if (graphQLResultHasProtocolErrors(rawResult)) {
|
|
658
|
+
result.error = rawResult.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
659
|
+
// Don't emit protocol errors added by HttpLink
|
|
660
|
+
delete rawResult.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
661
|
+
}
|
|
662
|
+
if (rawResult.extensions &&
|
|
663
|
+
Object.keys(rawResult.extensions).length) {
|
|
664
|
+
result.extensions = rawResult.extensions;
|
|
643
665
|
}
|
|
644
|
-
if (
|
|
645
|
-
|
|
646
|
-
// to our documentation, so we throw protocol errors regardless of the
|
|
647
|
-
// set error policy.
|
|
648
|
-
throw result.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
666
|
+
if (result.error && errorPolicy === "none") {
|
|
667
|
+
result.data = undefined;
|
|
649
668
|
}
|
|
650
669
|
if (errorPolicy === "ignore") {
|
|
651
|
-
delete result.
|
|
670
|
+
delete result.error;
|
|
652
671
|
}
|
|
653
672
|
return result;
|
|
654
673
|
}), catchError((error) => {
|
|
655
|
-
|
|
656
|
-
|
|
674
|
+
if (errorPolicy === "ignore") {
|
|
675
|
+
return of({ data: undefined });
|
|
676
|
+
}
|
|
677
|
+
return of({ data: undefined, error: maybeWrapError(error) });
|
|
678
|
+
}), filter((result) => !!(result.data || result.error)));
|
|
657
679
|
if (this.getDocumentInfo(query).hasClientExports) {
|
|
658
680
|
const observablePromise = this.localState
|
|
659
681
|
.addExportedVariables(query, variables, context)
|
|
@@ -1024,7 +1046,7 @@ export class QueryManager {
|
|
|
1024
1046
|
!isFullyUnmaskedOperation(document) &&
|
|
1025
1047
|
!this.noCacheWarningsByQueryId.has(operationId)) {
|
|
1026
1048
|
this.noCacheWarningsByQueryId.add(operationId);
|
|
1027
|
-
__DEV__ && invariant.warn(
|
|
1049
|
+
__DEV__ && invariant.warn(78, getOperationName(document) ??
|
|
1028
1050
|
`Unnamed ${operationType ?? "operation"}`);
|
|
1029
1051
|
}
|
|
1030
1052
|
}
|