@apollo/client 4.4.0-alpha.0 → 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 +39 -0
- 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 +7 -7
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +86 -31
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +11 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +27 -24
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +5 -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/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 +23 -22
- 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/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/createFragmentSpreadNode.cjs +4 -1
- package/__cjs/utilities/internal/createFragmentSpreadNode.cjs.map +1 -1
- package/__cjs/utilities/internal/createFragmentSpreadNode.d.cts +3 -2
- 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/equalByQuery.cjs +8 -8
- package/__cjs/utilities/internal/equalByQuery.cjs.map +1 -1
- package/__cjs/utilities/internal/equalByQuery.d.cts +2 -3
- 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 +10 -2
- 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 +14 -15
- package/__cjs/utilities/internal/getFragmentVariables.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentVariables.d.cts +8 -4
- package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
- package/__cjs/utilities/internal/index.cjs +9 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +5 -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 +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/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/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.js +7 -7
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +89 -34
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +11 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +5 -4
- package/cache/inmemory/writeToStore.js +30 -27
- 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/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 +24 -23
- 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 +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/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/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/createFragmentSpreadNode.d.ts +3 -2
- package/utilities/internal/createFragmentSpreadNode.js +4 -1
- package/utilities/internal/createFragmentSpreadNode.js.map +1 -1
- 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/equalByQuery.d.ts +2 -3
- package/utilities/internal/equalByQuery.js +8 -8
- package/utilities/internal/equalByQuery.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 +10 -2
- 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 +9 -5
- package/utilities/internal/getFragmentVariables.js +15 -16
- package/utilities/internal/getFragmentVariables.js.map +1 -1
- package/utilities/internal/getMainDefinition.js +1 -1
- package/utilities/internal/getQueryDefinition.js +1 -1
- package/utilities/internal/index.d.ts +5 -1
- package/utilities/internal/index.js +3 -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 +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/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/link/core/ApolloLink.js
CHANGED
|
@@ -100,7 +100,7 @@ export class ApolloLink {
|
|
|
100
100
|
const result = test(operation);
|
|
101
101
|
if (__DEV__) {
|
|
102
102
|
if (typeof result !== "boolean") {
|
|
103
|
-
__DEV__ && invariant.warn(
|
|
103
|
+
__DEV__ && invariant.warn(66, result);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
return result ?
|
|
@@ -142,7 +142,7 @@ export class ApolloLink {
|
|
|
142
142
|
static execute(link, request, context) {
|
|
143
143
|
return link.request(createOperation(request, context), () => {
|
|
144
144
|
if (__DEV__) {
|
|
145
|
-
__DEV__ && invariant.warn(
|
|
145
|
+
__DEV__ && invariant.warn(67);
|
|
146
146
|
}
|
|
147
147
|
return EMPTY;
|
|
148
148
|
});
|
|
@@ -246,7 +246,7 @@ export class ApolloLink {
|
|
|
246
246
|
* > request instead.
|
|
247
247
|
*/
|
|
248
248
|
request(operation, forward) {
|
|
249
|
-
throw newInvariantError(
|
|
249
|
+
throw newInvariantError(68);
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
252
|
* @internal
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
2
2
|
export const checkFetcher = (fetcher) => {
|
|
3
|
-
invariant(fetcher || typeof fetch !== "undefined",
|
|
3
|
+
invariant(fetcher || typeof fetch !== "undefined", 64);
|
|
4
4
|
};
|
|
5
5
|
//# sourceMappingURL=checkFetcher.js.map
|
|
@@ -33,7 +33,7 @@ async function* consumeMultipartBody(response) {
|
|
|
33
33
|
/;\s*boundary=(?:'([^']+)'|"([^"]+)"|([^"'].+?))\s*(?:;|$)/i);
|
|
34
34
|
const boundary = "\r\n--" + (match ? match[1] ?? match[2] ?? match[3] ?? "-" : "-");
|
|
35
35
|
let buffer = "";
|
|
36
|
-
invariant(response.body && typeof response.body.getReader === "function",
|
|
36
|
+
invariant(response.body && typeof response.body.getReader === "function", 65);
|
|
37
37
|
const stream = response.body;
|
|
38
38
|
const reader = stream.getReader();
|
|
39
39
|
let done = false;
|
|
@@ -66,7 +66,7 @@ export class PersistedQueryLink extends ApolloLink {
|
|
|
66
66
|
// hashing with something other than SHA-256.
|
|
67
67
|
invariant(options &&
|
|
68
68
|
(typeof options.sha256 === "function" ||
|
|
69
|
-
typeof options.generateHash === "function"),
|
|
69
|
+
typeof options.generateHash === "function"), 62);
|
|
70
70
|
const { sha256,
|
|
71
71
|
// If both a `sha256` and `generateHash` option are provided, the
|
|
72
72
|
// `sha256` option will be ignored. Developers can configure and
|
|
@@ -92,7 +92,7 @@ export class PersistedQueryLink extends ApolloLink {
|
|
|
92
92
|
return hash;
|
|
93
93
|
}
|
|
94
94
|
super((operation, forward) => {
|
|
95
|
-
invariant(forward,
|
|
95
|
+
invariant(forward, 63);
|
|
96
96
|
const { query } = operation;
|
|
97
97
|
return new Observable((observer) => {
|
|
98
98
|
let subscription;
|
package/link/ws/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export class WebSocketLink extends ApolloLink {
|
|
|
33
33
|
constructor(paramsOrClient) {
|
|
34
34
|
super();
|
|
35
35
|
if (__DEV__) {
|
|
36
|
-
__DEV__ && invariant.warn(
|
|
36
|
+
__DEV__ && invariant.warn(61);
|
|
37
37
|
}
|
|
38
38
|
if (paramsOrClient instanceof SubscriptionClient) {
|
|
39
39
|
this.subscriptionClient = paramsOrClient;
|
|
@@ -3,7 +3,7 @@ import { cacheSlot } from "@apollo/client/cache";
|
|
|
3
3
|
import { LocalStateError, toErrorLike } from "@apollo/client/errors";
|
|
4
4
|
import { stripTypename } from "@apollo/client/utilities";
|
|
5
5
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
6
|
-
import { argumentsObjectFromField, createFragmentMap, dealias, getFragmentDefinitions,
|
|
6
|
+
import { argumentsObjectFromField, createFragmentMap, dealias, getFragmentDefinitions, getFragmentScope, getMainDefinition, hasDirectives, mergeDeep, mergeDeepArray, resultKeyNameFromField, shouldInclude, } from "@apollo/client/utilities/internal";
|
|
7
7
|
import { invariant, newInvariantError, } from "@apollo/client/utilities/invariant";
|
|
8
8
|
/**
|
|
9
9
|
* LocalState enables the use of `@client` fields in GraphQL operations.
|
|
@@ -66,7 +66,7 @@ export class LocalState {
|
|
|
66
66
|
}
|
|
67
67
|
async execute({ document, client, context, remoteResult, variables = {}, onlyRunForcedResolvers = false, returnPartialData = false, fetchPolicy, }) {
|
|
68
68
|
if (__DEV__) {
|
|
69
|
-
invariant(hasDirectives(["client"], document),
|
|
69
|
+
invariant(hasDirectives(["client"], document), 50);
|
|
70
70
|
validateCacheImplementation(client.cache);
|
|
71
71
|
}
|
|
72
72
|
// note: if `remoteResult` is `undefined`, we will execute resolvers since
|
|
@@ -98,8 +98,8 @@ export class LocalState {
|
|
|
98
98
|
phase: "resolve",
|
|
99
99
|
variables: variables ?? {},
|
|
100
100
|
}) ?? requestContext,
|
|
101
|
-
operationVariables: variables,
|
|
102
101
|
variables,
|
|
102
|
+
variablesScope: variables,
|
|
103
103
|
exportedVariables: {},
|
|
104
104
|
selectionsToResolve,
|
|
105
105
|
onlyRunForcedResolvers,
|
|
@@ -123,7 +123,7 @@ export class LocalState {
|
|
|
123
123
|
}
|
|
124
124
|
async getExportedVariables({ document, client, context, variables, }) {
|
|
125
125
|
if (__DEV__) {
|
|
126
|
-
invariant(hasDirectives(["client"], document),
|
|
126
|
+
invariant(hasDirectives(["client"], document), 51);
|
|
127
127
|
validateCacheImplementation(client.cache);
|
|
128
128
|
}
|
|
129
129
|
const { exportsToResolve, exportedVariableDefs, fragmentMap, operationDefinition, } = this.collectQueryDetail(document);
|
|
@@ -145,8 +145,8 @@ export class LocalState {
|
|
|
145
145
|
phase: "resolve",
|
|
146
146
|
variables: variables ?? {},
|
|
147
147
|
}) ?? requestContext,
|
|
148
|
-
operationVariables: variables,
|
|
149
148
|
variables,
|
|
149
|
+
variablesScope: variables,
|
|
150
150
|
exportedVariables: {},
|
|
151
151
|
selectionsToResolve: exportsToResolve,
|
|
152
152
|
onlyRunForcedResolvers: false,
|
|
@@ -163,7 +163,7 @@ export class LocalState {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
async resolveSelectionSet(selectionSet, isClientFieldDescendant, rootValue, execContext, path) {
|
|
166
|
-
const { client, fragmentMap,
|
|
166
|
+
const { client, fragmentMap, variablesScope, operationDefinition } = execContext;
|
|
167
167
|
const { cache } = client;
|
|
168
168
|
const resultsToMerge = [];
|
|
169
169
|
const execute = async (selection) => {
|
|
@@ -173,7 +173,7 @@ export class LocalState {
|
|
|
173
173
|
// (still processing if one of the ancestors or one of the child fields has @client directive)
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
|
-
if (!shouldInclude(selection,
|
|
176
|
+
if (!shouldInclude(selection, variablesScope)) {
|
|
177
177
|
// Skip this entirely.
|
|
178
178
|
return;
|
|
179
179
|
}
|
|
@@ -206,20 +206,20 @@ export class LocalState {
|
|
|
206
206
|
}
|
|
207
207
|
if (selection.kind === Kind.FRAGMENT_SPREAD) {
|
|
208
208
|
const fragment = fragmentMap[selection.name.value];
|
|
209
|
-
invariant(fragment,
|
|
209
|
+
invariant(fragment, 52, selection.name.value);
|
|
210
210
|
const typename = rootValue?.__typename;
|
|
211
211
|
const typeCondition = fragment.typeCondition.name.value;
|
|
212
212
|
const matches = typename === typeCondition ||
|
|
213
213
|
cache.fragmentMatches(fragment, typename ?? "");
|
|
214
214
|
if (matches) {
|
|
215
215
|
let context = execContext;
|
|
216
|
-
const
|
|
216
|
+
const variablesScope = getFragmentScope(selection, {
|
|
217
217
|
fragment,
|
|
218
|
-
variables: execContext.
|
|
219
|
-
parentScope: execContext.
|
|
218
|
+
variables: execContext.variables,
|
|
219
|
+
parentScope: execContext.variablesScope,
|
|
220
220
|
});
|
|
221
|
-
if (
|
|
222
|
-
context = { ...context,
|
|
221
|
+
if (variablesScope !== execContext.variablesScope) {
|
|
222
|
+
context = { ...context, variablesScope };
|
|
223
223
|
}
|
|
224
224
|
const fragmentResult = await this.resolveSelectionSet(fragment.selectionSet, isClientFieldDescendant, rootValue, context, path);
|
|
225
225
|
if (fragmentResult) {
|
|
@@ -255,7 +255,7 @@ export class LocalState {
|
|
|
255
255
|
return this.resolveSelectionSet(field.selectionSet, false, result, execContext, path);
|
|
256
256
|
}
|
|
257
257
|
async resolveClientField(field, isClientFieldDescendant, rootValue, execContext, parentSelectionSet, path) {
|
|
258
|
-
const { client, diff,
|
|
258
|
+
const { client, diff, variablesScope, operationDefinition, phase, onlyRunForcedResolvers, fetchPolicy, } = execContext;
|
|
259
259
|
let { returnPartialData } = execContext;
|
|
260
260
|
const isRootField = parentSelectionSet === operationDefinition.selectionSet;
|
|
261
261
|
const fieldName = field.name.value;
|
|
@@ -280,7 +280,7 @@ export class LocalState {
|
|
|
280
280
|
}
|
|
281
281
|
if (client.cache.resolvesClientField?.(typename, fieldName)) {
|
|
282
282
|
if (fetchPolicy === "no-cache") {
|
|
283
|
-
__DEV__ && invariant.warn(
|
|
283
|
+
__DEV__ && invariant.warn(53, resolverName);
|
|
284
284
|
return null;
|
|
285
285
|
}
|
|
286
286
|
// assume the cache will handle returning the correct value
|
|
@@ -288,7 +288,7 @@ export class LocalState {
|
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
290
|
if (!returnPartialData) {
|
|
291
|
-
__DEV__ && invariant.warn(
|
|
291
|
+
__DEV__ && invariant.warn(54, resolverName);
|
|
292
292
|
return null;
|
|
293
293
|
}
|
|
294
294
|
});
|
|
@@ -306,7 +306,8 @@ export class LocalState {
|
|
|
306
306
|
// set cacheSlot to the current cache instance.
|
|
307
307
|
cacheSlot.withValue(client.cache, resolver, [
|
|
308
308
|
rootValue ? dealias(rootValue, parentSelectionSet) : {},
|
|
309
|
-
(argumentsObjectFromField(field,
|
|
309
|
+
(argumentsObjectFromField(field, variablesScope) ??
|
|
310
|
+
{}),
|
|
310
311
|
{ requestContext: execContext.context, client, phase },
|
|
311
312
|
{ field, fragmentMap: execContext.fragmentMap, path },
|
|
312
313
|
]))
|
|
@@ -354,13 +355,13 @@ export class LocalState {
|
|
|
354
355
|
if (result === undefined && !returnPartialData) {
|
|
355
356
|
if (__DEV__ && phase === "resolve") {
|
|
356
357
|
if (resolver && !onlyRunForcedResolvers) {
|
|
357
|
-
__DEV__ && invariant.warn(
|
|
358
|
+
__DEV__ && invariant.warn(55, resolverName);
|
|
358
359
|
}
|
|
359
360
|
else if (onlyRunForcedResolvers) {
|
|
360
|
-
__DEV__ && invariant.warn(
|
|
361
|
+
__DEV__ && invariant.warn(56, resolverName);
|
|
361
362
|
}
|
|
362
363
|
else {
|
|
363
|
-
__DEV__ && invariant.warn(
|
|
364
|
+
__DEV__ && invariant.warn(57, fieldName, rootValue);
|
|
364
365
|
}
|
|
365
366
|
}
|
|
366
367
|
result = null;
|
|
@@ -372,7 +373,7 @@ export class LocalState {
|
|
|
372
373
|
return this.resolveSubSelectedArray(field, true, result, execContext, path);
|
|
373
374
|
}
|
|
374
375
|
if (phase === "resolve" && !result.__typename) {
|
|
375
|
-
this.addError(newInvariantError(
|
|
376
|
+
this.addError(newInvariantError(58, result, resolverName), path, execContext, { resolver: resolverName });
|
|
376
377
|
return null;
|
|
377
378
|
}
|
|
378
379
|
return this.resolveSelectionSet(field.selectionSet, true, result, execContext, path);
|
|
@@ -483,7 +484,7 @@ export class LocalState {
|
|
|
483
484
|
},
|
|
484
485
|
FragmentSpread(spread, _, __, ___, ancestors) {
|
|
485
486
|
const fragment = fragmentMap[spread.name.value];
|
|
486
|
-
invariant(fragment,
|
|
487
|
+
invariant(fragment, 59, spread.name.value);
|
|
487
488
|
const { selectionsToResolve: fragmentSelections } = traverse(fragment);
|
|
488
489
|
if (fragmentSelections.size > 0) {
|
|
489
490
|
// Fragment for this spread contains @client directive (either directly or transitively)
|
|
@@ -542,7 +543,7 @@ function getExportedVariableName(directive) {
|
|
|
542
543
|
}
|
|
543
544
|
}
|
|
544
545
|
function validateCacheImplementation(cache) {
|
|
545
|
-
invariant(cache.fragmentMatches,
|
|
546
|
+
invariant(cache.fragmentMatches, 60);
|
|
546
547
|
}
|
|
547
548
|
function getCacheResultAtPath(diff, path) {
|
|
548
549
|
if (diff.result === null) {
|