@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
|
@@ -30,13 +30,6 @@ export declare namespace BaseBatchHttpLink {
|
|
|
30
30
|
* @defaultValue 10
|
|
31
31
|
*/
|
|
32
32
|
batchMax?: number;
|
|
33
|
-
/**
|
|
34
|
-
* If differently-shaped operations (with/without `includeExtensions` or `includeQuery`) should be combined into a single batch request.
|
|
35
|
-
* In most applications this will determine if persisted and non-persisted queries should be combined within the same batch.
|
|
36
|
-
*
|
|
37
|
-
* @defaultValue false
|
|
38
|
-
*/
|
|
39
|
-
batchHybridRequests?: boolean;
|
|
40
33
|
}
|
|
41
34
|
}
|
|
42
35
|
/**
|
|
@@ -58,16 +58,16 @@ export class BaseBatchHttpLink extends ApolloLink {
|
|
|
58
58
|
this.batchMax = batchMax || 10;
|
|
59
59
|
const batchHandler = (operations) => {
|
|
60
60
|
const chosenURI = selectURI(operations[0], uri);
|
|
61
|
+
const context = operations[0].getContext();
|
|
62
|
+
const contextConfig = {
|
|
63
|
+
http: context.http,
|
|
64
|
+
options: context.fetchOptions,
|
|
65
|
+
credentials: context.credentials,
|
|
66
|
+
headers: context.headers,
|
|
67
|
+
};
|
|
61
68
|
//uses fallback, link, and then context to build options
|
|
62
69
|
const optsAndBody = operations.map((operation) => {
|
|
63
|
-
const
|
|
64
|
-
const operationConfig = {
|
|
65
|
-
http: context.http,
|
|
66
|
-
options: context.fetchOptions,
|
|
67
|
-
credentials: context.credentials,
|
|
68
|
-
headers: context.headers,
|
|
69
|
-
};
|
|
70
|
-
const result = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, operationConfig);
|
|
70
|
+
const result = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig);
|
|
71
71
|
if (result.body.variables && !includeUnusedVariables) {
|
|
72
72
|
result.body.variables = filterOperationVariables(result.body.variables, operation.query);
|
|
73
73
|
}
|
|
@@ -129,16 +129,7 @@ export class BaseBatchHttpLink extends ApolloLink {
|
|
|
129
129
|
((operation) => {
|
|
130
130
|
const context = operation.getContext();
|
|
131
131
|
const contextConfig = {
|
|
132
|
-
http:
|
|
133
|
-
{
|
|
134
|
-
...context.http,
|
|
135
|
-
// omit includeExtensions and includeQuery from the HTTP options
|
|
136
|
-
// they only influence body creation, not the HTTP request itself
|
|
137
|
-
// so they should be grouped together
|
|
138
|
-
includeExtensions: undefined,
|
|
139
|
-
includeQuery: undefined,
|
|
140
|
-
}
|
|
141
|
-
: context.http,
|
|
132
|
+
http: context.http,
|
|
142
133
|
options: context.fetchOptions,
|
|
143
134
|
credentials: context.credentials,
|
|
144
135
|
headers: context.headers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseBatchHttpLink.js","sourceRoot":"","sources":["../../../src/link/batch-http/BaseBatchHttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,yBAAyB,EACzB,gCAAgC,EAChC,SAAS,GACV,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,2CAA2C,CAAC;AAsClE,MAAM,WAAW,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAA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UAAU,EAAE,CAAC;oBAEvC,MAAM,aAAa,GAAG;wBACpB,IAAI,EACF,OAAO,CAAC,mBAAmB,CAAC,CAAC;4BAC3B;gCACE,GAAG,OAAO,CAAC,IAAI;gCACf,gEAAgE;gCAChE,iEAAiE;gCACjE,qCAAqC;gCACrC,iBAAiB,EAAE,SAAS;gCAC5B,YAAY,EAAE,SAAS;6BACxB;4BACH,CAAC,CAAC,OAAO,CAAC,IAAI;wBAChB,OAAO,EAAE,OAAO,CAAC,YAAY;wBAC7B,WAAW,EAAE,OAAO,CAAC,WAAW;wBAChC,OAAO,EAAE,OAAO,CAAC,OAAO;qBACzB,CAAC;oBAEF,4CAA4C;oBAC5C,OAAO,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;gBACnE,CAAC,CAAC,CAAC;QAEL,IAAI,CAAC,OAAO,GAAG,IAAI,SAAS,CAAC;YAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ;YACR,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAEM,OAAO,CACZ,SAA+B,EAC/B,OAAmC;QAEnC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { Observable, throwError } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { BatchLink } from \"@apollo/client/link/batch\";\nimport type { BaseHttpLink } from \"@apollo/client/link/http\";\nimport {\n checkFetcher,\n defaultPrinter,\n fallbackHttpConfig,\n parseAndCheckHttpResponse,\n selectHttpOptionsAndBodyInternal,\n selectURI,\n} from \"@apollo/client/link/http\";\nimport { filterOperationVariables } from \"@apollo/client/link/utils\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { compact } from \"@apollo/client/utilities/internal\";\nimport { maybe } from \"@apollo/client/utilities/internal/globals\";\n\nexport declare namespace BaseBatchHttpLink {\n /**\n * Options passed to `BaseBatchHttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous\n * non-terminating links in the link chain also can set these values to\n * customize the behavior of `BatchHttpLink` for each operation.\n *\n * > [!NOTE]\n * > Some of these values can also be provided to the `BaseBatchHttpLink` constructor.\n * > If a value is provided to both, the value in `context` takes precedence.\n */\n export interface ContextOptions extends BaseHttpLink.ContextOptions {}\n /**\n * Configuration options for creating a `BaseBatchHttpLink` instance.\n *\n * > [!NOTE]\n * > Some of these options are also available to override in [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context).\n * > Context options override the options passed to the constructor. Treat\n * > these options as default values that are used when the request context\n * > does not override the value.\n */\n interface Options\n extends BatchLink.Shared.Options,\n BaseHttpLink.Shared.Options {\n /** {@inheritDoc @apollo/client/link/batch!BatchLink.Shared.Options#batchMax:member {\"defaultValue\": 10}} */\n batchMax?: number;\n\n /**\n * If differently-shaped operations (with/without `includeExtensions` or `includeQuery`) should be combined into a single batch request.\n * In most applications this will determine if persisted and non-persisted queries should be combined within the same batch.\n *\n * @defaultValue false\n */\n batchHybridRequests?: boolean;\n }\n}\n\nconst backupFetch = maybe(() => fetch);\n\n/**\n * `BaseBatchHttpLink` is a terminating link that batches array of individual\n * GraphQL operations into a single HTTP request that's sent to a single GraphQL\n * endpoint. It serves as a base link to `BatchHttpLink`.\n *\n * @remarks\n *\n * > [!NOTE]\n * > Prefer using `BatchHttpLink` over `BaseBatchHttpLink`. Use\n * > `BaseBatchHttpLink` when you need to disable client awareness features and\n * > would like to tree-shake the implementation of `ClientAwarenessLink` out\n * > of your app bundle.\n *\n * @example\n *\n * ```ts\n * import { BaseBatchHttpLink } from \"@apollo/client/link/batch-http\";\n *\n * const link = new BaseBatchHttpLink({\n * uri: \"http://localhost:4000/graphql\",\n * batchMax: 5, // No more than 5 operations per batch\n * batchInterval: 20, // Wait no more than 20ms after first batched operation\n * });\n * ```\n */\nexport class BaseBatchHttpLink extends ApolloLink {\n private batchDebounce?: boolean;\n private batchInterval: number;\n private batchMax: number;\n private batcher: ApolloLink;\n\n constructor(options: BaseBatchHttpLink.Options = {}) {\n super();\n\n let {\n uri = \"/graphql\",\n // use default global fetch if nothing is passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n batchInterval,\n batchDebounce,\n batchMax,\n batchKey,\n includeUnusedVariables = false,\n ...requestOptions\n } = options;\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch\n // is defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: compact({ includeExtensions, preserveHeaderCase }),\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval || 10;\n this.batchMax = batchMax || 10;\n\n const batchHandler: BatchLink.BatchHandler = (operations) => {\n const chosenURI = selectURI(operations[0], uri);\n\n //uses fallback, link, and then context to build options\n const optsAndBody = operations.map((operation) => {\n const context = operation.getContext();\n\n const operationConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n const result = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n operationConfig\n );\n\n if (result.body.variables && !includeUnusedVariables) {\n result.body.variables = filterOperationVariables(\n result.body.variables,\n operation.query\n );\n }\n\n return result;\n });\n\n const loadedBody = optsAndBody.map(({ body }) => body);\n const options = optsAndBody[0].options;\n\n // There's no spec for using GET with batches.\n if (options.method === \"GET\") {\n return throwError(\n () =>\n new Error(\"apollo-link-batch-http does not support GET requests\")\n );\n }\n\n try {\n (options as any).body = JSON.stringify(loadedBody);\n } catch (parseError) {\n return throwError(() => parseError);\n }\n\n let controller: AbortController | undefined;\n if (!options.signal && typeof AbortController !== \"undefined\") {\n controller = new AbortController();\n options.signal = controller.signal;\n }\n\n return new Observable((observer) => {\n // Prefer BatchHttpLink.Options.fetch (preferredFetch) if provided, and\n // otherwise fall back to the *current* global window.fetch function\n // (see issue #7832), or (if all else fails) the backupFetch function we\n // saved when this module was first evaluated. This last option protects\n // against the removal of window.fetch, which is unlikely but not\n // impossible.\n const currentFetch =\n preferredFetch || maybe(() => fetch) || backupFetch;\n\n currentFetch!(chosenURI, options)\n .then((response) => {\n // Make the raw response available in the context.\n operations.forEach((operation) =>\n operation.setContext({ response })\n );\n return response;\n })\n .then(parseAndCheckHttpResponse(operations))\n .then((result) => {\n controller = undefined;\n // we have data and can send it to back up the link chain\n observer.next(result);\n observer.complete();\n return result;\n })\n .catch((err) => {\n controller = undefined;\n observer.error(err);\n });\n\n return () => {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller) controller.abort();\n };\n });\n };\n\n batchKey =\n batchKey ||\n ((operation: ApolloLink.Operation) => {\n const context = operation.getContext();\n\n const contextConfig = {\n http:\n options.batchHybridRequests ?\n {\n ...context.http,\n // omit includeExtensions and includeQuery from the HTTP options\n // they only influence body creation, not the HTTP request itself\n // so they should be grouped together\n includeExtensions: undefined,\n includeQuery: undefined,\n }\n : context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //may throw error if config not serializable\n return selectURI(operation, uri) + JSON.stringify(contextConfig);\n });\n\n this.batcher = new BatchLink({\n batchDebounce: this.batchDebounce,\n batchInterval: this.batchInterval,\n batchMax: this.batchMax,\n batchKey,\n batchHandler,\n });\n }\n\n public request(\n operation: ApolloLink.Operation,\n forward: ApolloLink.ForwardFunction\n ): Observable<ApolloLink.Result> {\n return this.batcher.request(operation, forward);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"BaseBatchHttpLink.js","sourceRoot":"","sources":["../../../src/link/batch-http/BaseBatchHttpLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,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AAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["import { Observable, throwError } from \"rxjs\";\n\nimport { ApolloLink } from \"@apollo/client/link\";\nimport { BatchLink } from \"@apollo/client/link/batch\";\nimport type { BaseHttpLink } from \"@apollo/client/link/http\";\nimport {\n checkFetcher,\n defaultPrinter,\n fallbackHttpConfig,\n parseAndCheckHttpResponse,\n selectHttpOptionsAndBodyInternal,\n selectURI,\n} from \"@apollo/client/link/http\";\nimport { filterOperationVariables } from \"@apollo/client/link/utils\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport { compact } from \"@apollo/client/utilities/internal\";\nimport { maybe } from \"@apollo/client/utilities/internal/globals\";\n\nexport declare namespace BaseBatchHttpLink {\n /**\n * Options passed to `BaseBatchHttpLink` through [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context). Previous\n * non-terminating links in the link chain also can set these values to\n * customize the behavior of `BatchHttpLink` for each operation.\n *\n * > [!NOTE]\n * > Some of these values can also be provided to the `BaseBatchHttpLink` constructor.\n * > If a value is provided to both, the value in `context` takes precedence.\n */\n export interface ContextOptions extends BaseHttpLink.ContextOptions {}\n /**\n * Configuration options for creating a `BaseBatchHttpLink` instance.\n *\n * > [!NOTE]\n * > Some of these options are also available to override in [request context](https://apollographql.com/docs/react/api/link/introduction#managing-context).\n * > Context options override the options passed to the constructor. Treat\n * > these options as default values that are used when the request context\n * > does not override the value.\n */\n interface Options\n extends BatchLink.Shared.Options,\n BaseHttpLink.Shared.Options {\n /** {@inheritDoc @apollo/client/link/batch!BatchLink.Shared.Options#batchMax:member {\"defaultValue\": 10}} */\n batchMax?: number;\n }\n}\n\nconst backupFetch = maybe(() => fetch);\n\n/**\n * `BaseBatchHttpLink` is a terminating link that batches array of individual\n * GraphQL operations into a single HTTP request that's sent to a single GraphQL\n * endpoint. It serves as a base link to `BatchHttpLink`.\n *\n * @remarks\n *\n * > [!NOTE]\n * > Prefer using `BatchHttpLink` over `BaseBatchHttpLink`. Use\n * > `BaseBatchHttpLink` when you need to disable client awareness features and\n * > would like to tree-shake the implementation of `ClientAwarenessLink` out\n * > of your app bundle.\n *\n * @example\n *\n * ```ts\n * import { BaseBatchHttpLink } from \"@apollo/client/link/batch-http\";\n *\n * const link = new BaseBatchHttpLink({\n * uri: \"http://localhost:4000/graphql\",\n * batchMax: 5, // No more than 5 operations per batch\n * batchInterval: 20, // Wait no more than 20ms after first batched operation\n * });\n * ```\n */\nexport class BaseBatchHttpLink extends ApolloLink {\n private batchDebounce?: boolean;\n private batchInterval: number;\n private batchMax: number;\n private batcher: ApolloLink;\n\n constructor(options: BaseBatchHttpLink.Options = {}) {\n super();\n\n let {\n uri = \"/graphql\",\n // use default global fetch if nothing is passed in\n fetch: preferredFetch,\n print = defaultPrinter,\n includeExtensions,\n preserveHeaderCase,\n batchInterval,\n batchDebounce,\n batchMax,\n batchKey,\n includeUnusedVariables = false,\n ...requestOptions\n } = options;\n\n if (__DEV__) {\n // Make sure at least one of preferredFetch, window.fetch, or backupFetch\n // is defined, so requests won't fail at runtime.\n checkFetcher(preferredFetch || backupFetch);\n }\n\n const linkConfig = {\n http: compact({ includeExtensions, preserveHeaderCase }),\n options: requestOptions.fetchOptions,\n credentials: requestOptions.credentials,\n headers: requestOptions.headers,\n };\n\n this.batchDebounce = batchDebounce;\n this.batchInterval = batchInterval || 10;\n this.batchMax = batchMax || 10;\n\n const batchHandler: BatchLink.BatchHandler = (operations) => {\n const chosenURI = selectURI(operations[0], uri);\n\n const context = operations[0].getContext();\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //uses fallback, link, and then context to build options\n const optsAndBody = operations.map((operation) => {\n const result = selectHttpOptionsAndBodyInternal(\n operation,\n print,\n fallbackHttpConfig,\n linkConfig,\n contextConfig\n );\n\n if (result.body.variables && !includeUnusedVariables) {\n result.body.variables = filterOperationVariables(\n result.body.variables,\n operation.query\n );\n }\n\n return result;\n });\n\n const loadedBody = optsAndBody.map(({ body }) => body);\n const options = optsAndBody[0].options;\n\n // There's no spec for using GET with batches.\n if (options.method === \"GET\") {\n return throwError(\n () =>\n new Error(\"apollo-link-batch-http does not support GET requests\")\n );\n }\n\n try {\n (options as any).body = JSON.stringify(loadedBody);\n } catch (parseError) {\n return throwError(() => parseError);\n }\n\n let controller: AbortController | undefined;\n if (!options.signal && typeof AbortController !== \"undefined\") {\n controller = new AbortController();\n options.signal = controller.signal;\n }\n\n return new Observable((observer) => {\n // Prefer BatchHttpLink.Options.fetch (preferredFetch) if provided, and\n // otherwise fall back to the *current* global window.fetch function\n // (see issue #7832), or (if all else fails) the backupFetch function we\n // saved when this module was first evaluated. This last option protects\n // against the removal of window.fetch, which is unlikely but not\n // impossible.\n const currentFetch =\n preferredFetch || maybe(() => fetch) || backupFetch;\n\n currentFetch!(chosenURI, options)\n .then((response) => {\n // Make the raw response available in the context.\n operations.forEach((operation) =>\n operation.setContext({ response })\n );\n return response;\n })\n .then(parseAndCheckHttpResponse(operations))\n .then((result) => {\n controller = undefined;\n // we have data and can send it to back up the link chain\n observer.next(result);\n observer.complete();\n return result;\n })\n .catch((err) => {\n controller = undefined;\n observer.error(err);\n });\n\n return () => {\n // XXX support canceling this request\n // https://developers.google.com/web/updates/2017/09/abortable-fetch\n if (controller) controller.abort();\n };\n });\n };\n\n batchKey =\n batchKey ||\n ((operation: ApolloLink.Operation) => {\n const context = operation.getContext();\n\n const contextConfig = {\n http: context.http,\n options: context.fetchOptions,\n credentials: context.credentials,\n headers: context.headers,\n };\n\n //may throw error if config not serializable\n return selectURI(operation, uri) + JSON.stringify(contextConfig);\n });\n\n this.batcher = new BatchLink({\n batchDebounce: this.batchDebounce,\n batchInterval: this.batchInterval,\n batchMax: this.batchMax,\n batchKey,\n batchHandler,\n });\n }\n\n public request(\n operation: ApolloLink.Operation,\n forward: ApolloLink.ForwardFunction\n ): Observable<ApolloLink.Result> {\n return this.batcher.request(operation, forward);\n }\n}\n"]}
|
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, getMainDefinition, hasDirectives, mergeDeep, mergeDeepArray, resultKeyNameFromField, shouldInclude, } from "@apollo/client/utilities/internal";
|
|
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
|
|
@@ -99,6 +99,7 @@ export class LocalState {
|
|
|
99
99
|
variables: variables ?? {},
|
|
100
100
|
}) ?? requestContext,
|
|
101
101
|
variables,
|
|
102
|
+
variablesScope: variables,
|
|
102
103
|
exportedVariables: {},
|
|
103
104
|
selectionsToResolve,
|
|
104
105
|
onlyRunForcedResolvers,
|
|
@@ -122,7 +123,7 @@ export class LocalState {
|
|
|
122
123
|
}
|
|
123
124
|
async getExportedVariables({ document, client, context, variables, }) {
|
|
124
125
|
if (__DEV__) {
|
|
125
|
-
invariant(hasDirectives(["client"], document),
|
|
126
|
+
invariant(hasDirectives(["client"], document), 51);
|
|
126
127
|
validateCacheImplementation(client.cache);
|
|
127
128
|
}
|
|
128
129
|
const { exportsToResolve, exportedVariableDefs, fragmentMap, operationDefinition, } = this.collectQueryDetail(document);
|
|
@@ -145,6 +146,7 @@ export class LocalState {
|
|
|
145
146
|
variables: variables ?? {},
|
|
146
147
|
}) ?? requestContext,
|
|
147
148
|
variables,
|
|
149
|
+
variablesScope: variables,
|
|
148
150
|
exportedVariables: {},
|
|
149
151
|
selectionsToResolve: exportsToResolve,
|
|
150
152
|
onlyRunForcedResolvers: false,
|
|
@@ -161,7 +163,7 @@ export class LocalState {
|
|
|
161
163
|
});
|
|
162
164
|
}
|
|
163
165
|
async resolveSelectionSet(selectionSet, isClientFieldDescendant, rootValue, execContext, path) {
|
|
164
|
-
const { client, fragmentMap,
|
|
166
|
+
const { client, fragmentMap, variablesScope, operationDefinition } = execContext;
|
|
165
167
|
const { cache } = client;
|
|
166
168
|
const resultsToMerge = [];
|
|
167
169
|
const execute = async (selection) => {
|
|
@@ -171,7 +173,7 @@ export class LocalState {
|
|
|
171
173
|
// (still processing if one of the ancestors or one of the child fields has @client directive)
|
|
172
174
|
return;
|
|
173
175
|
}
|
|
174
|
-
if (!shouldInclude(selection,
|
|
176
|
+
if (!shouldInclude(selection, variablesScope)) {
|
|
175
177
|
// Skip this entirely.
|
|
176
178
|
return;
|
|
177
179
|
}
|
|
@@ -204,13 +206,22 @@ export class LocalState {
|
|
|
204
206
|
}
|
|
205
207
|
if (selection.kind === Kind.FRAGMENT_SPREAD) {
|
|
206
208
|
const fragment = fragmentMap[selection.name.value];
|
|
207
|
-
invariant(fragment,
|
|
209
|
+
invariant(fragment, 52, selection.name.value);
|
|
208
210
|
const typename = rootValue?.__typename;
|
|
209
211
|
const typeCondition = fragment.typeCondition.name.value;
|
|
210
212
|
const matches = typename === typeCondition ||
|
|
211
213
|
cache.fragmentMatches(fragment, typename ?? "");
|
|
212
214
|
if (matches) {
|
|
213
|
-
|
|
215
|
+
let context = execContext;
|
|
216
|
+
const variablesScope = getFragmentScope(selection, {
|
|
217
|
+
fragment,
|
|
218
|
+
variables: execContext.variables,
|
|
219
|
+
parentScope: execContext.variablesScope,
|
|
220
|
+
});
|
|
221
|
+
if (variablesScope !== execContext.variablesScope) {
|
|
222
|
+
context = { ...context, variablesScope };
|
|
223
|
+
}
|
|
224
|
+
const fragmentResult = await this.resolveSelectionSet(fragment.selectionSet, isClientFieldDescendant, rootValue, context, path);
|
|
214
225
|
if (fragmentResult) {
|
|
215
226
|
resultsToMerge.push(fragmentResult);
|
|
216
227
|
}
|
|
@@ -244,7 +255,7 @@ export class LocalState {
|
|
|
244
255
|
return this.resolveSelectionSet(field.selectionSet, false, result, execContext, path);
|
|
245
256
|
}
|
|
246
257
|
async resolveClientField(field, isClientFieldDescendant, rootValue, execContext, parentSelectionSet, path) {
|
|
247
|
-
const { client, diff,
|
|
258
|
+
const { client, diff, variablesScope, operationDefinition, phase, onlyRunForcedResolvers, fetchPolicy, } = execContext;
|
|
248
259
|
let { returnPartialData } = execContext;
|
|
249
260
|
const isRootField = parentSelectionSet === operationDefinition.selectionSet;
|
|
250
261
|
const fieldName = field.name.value;
|
|
@@ -269,7 +280,7 @@ export class LocalState {
|
|
|
269
280
|
}
|
|
270
281
|
if (client.cache.resolvesClientField?.(typename, fieldName)) {
|
|
271
282
|
if (fetchPolicy === "no-cache") {
|
|
272
|
-
__DEV__ && invariant.warn(
|
|
283
|
+
__DEV__ && invariant.warn(53, resolverName);
|
|
273
284
|
return null;
|
|
274
285
|
}
|
|
275
286
|
// assume the cache will handle returning the correct value
|
|
@@ -277,7 +288,7 @@ export class LocalState {
|
|
|
277
288
|
return;
|
|
278
289
|
}
|
|
279
290
|
if (!returnPartialData) {
|
|
280
|
-
__DEV__ && invariant.warn(
|
|
291
|
+
__DEV__ && invariant.warn(54, resolverName);
|
|
281
292
|
return null;
|
|
282
293
|
}
|
|
283
294
|
});
|
|
@@ -295,7 +306,8 @@ export class LocalState {
|
|
|
295
306
|
// set cacheSlot to the current cache instance.
|
|
296
307
|
cacheSlot.withValue(client.cache, resolver, [
|
|
297
308
|
rootValue ? dealias(rootValue, parentSelectionSet) : {},
|
|
298
|
-
(argumentsObjectFromField(field,
|
|
309
|
+
(argumentsObjectFromField(field, variablesScope) ??
|
|
310
|
+
{}),
|
|
299
311
|
{ requestContext: execContext.context, client, phase },
|
|
300
312
|
{ field, fragmentMap: execContext.fragmentMap, path },
|
|
301
313
|
]))
|
|
@@ -343,13 +355,13 @@ export class LocalState {
|
|
|
343
355
|
if (result === undefined && !returnPartialData) {
|
|
344
356
|
if (__DEV__ && phase === "resolve") {
|
|
345
357
|
if (resolver && !onlyRunForcedResolvers) {
|
|
346
|
-
__DEV__ && invariant.warn(
|
|
358
|
+
__DEV__ && invariant.warn(55, resolverName);
|
|
347
359
|
}
|
|
348
360
|
else if (onlyRunForcedResolvers) {
|
|
349
|
-
__DEV__ && invariant.warn(
|
|
361
|
+
__DEV__ && invariant.warn(56, resolverName);
|
|
350
362
|
}
|
|
351
363
|
else {
|
|
352
|
-
__DEV__ && invariant.warn(
|
|
364
|
+
__DEV__ && invariant.warn(57, fieldName, rootValue);
|
|
353
365
|
}
|
|
354
366
|
}
|
|
355
367
|
result = null;
|
|
@@ -361,7 +373,7 @@ export class LocalState {
|
|
|
361
373
|
return this.resolveSubSelectedArray(field, true, result, execContext, path);
|
|
362
374
|
}
|
|
363
375
|
if (phase === "resolve" && !result.__typename) {
|
|
364
|
-
this.addError(newInvariantError(
|
|
376
|
+
this.addError(newInvariantError(58, result, resolverName), path, execContext, { resolver: resolverName });
|
|
365
377
|
return null;
|
|
366
378
|
}
|
|
367
379
|
return this.resolveSelectionSet(field.selectionSet, true, result, execContext, path);
|
|
@@ -472,7 +484,7 @@ export class LocalState {
|
|
|
472
484
|
},
|
|
473
485
|
FragmentSpread(spread, _, __, ___, ancestors) {
|
|
474
486
|
const fragment = fragmentMap[spread.name.value];
|
|
475
|
-
invariant(fragment,
|
|
487
|
+
invariant(fragment, 59, spread.name.value);
|
|
476
488
|
const { selectionsToResolve: fragmentSelections } = traverse(fragment);
|
|
477
489
|
if (fragmentSelections.size > 0) {
|
|
478
490
|
// Fragment for this spread contains @client directive (either directly or transitively)
|
|
@@ -531,7 +543,7 @@ function getExportedVariableName(directive) {
|
|
|
531
543
|
}
|
|
532
544
|
}
|
|
533
545
|
function validateCacheImplementation(cache) {
|
|
534
|
-
invariant(cache.fragmentMatches,
|
|
546
|
+
invariant(cache.fragmentMatches, 60);
|
|
535
547
|
}
|
|
536
548
|
function getCacheResultAtPath(diff, path) {
|
|
537
549
|
if (diff.result === null) {
|