@apollo/client 4.0.12-beta.0 → 4.0.13
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 +10 -194
- package/__cjs/cache/core/cache.cjs +48 -169
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +25 -94
- package/__cjs/cache/core/types/Cache.d.cts +17 -49
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +4 -6
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/fragmentRegistry.cjs +5 -0
- package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.d.cts +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +1 -15
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +0 -1
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.cjs +17 -56
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +6 -30
- package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +0 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +10 -24
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +1 -2
- package/__cjs/core/ApolloClient.cjs +49 -31
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +17 -143
- package/__cjs/core/ObservableQuery.cjs +128 -162
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +0 -1
- package/__cjs/core/QueryInfo.cjs +1 -9
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +1 -2
- package/__cjs/core/QueryManager.cjs +24 -46
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +2 -18
- package/__cjs/incremental/handlers/defer20220824.cjs +19 -44
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +7 -15
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
- package/__cjs/incremental/index.cjs +1 -3
- package/__cjs/incremental/index.cjs.map +1 -1
- package/__cjs/incremental/index.d.cts +0 -1
- package/__cjs/incremental/types.d.cts +0 -9
- package/__cjs/invariantErrorCodes.cjs +62 -78
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +1 -13
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +1 -1
- 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/remove-typename/removeTypenameFromVariables.cjs +51 -50
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +3 -0
- package/__cjs/link/ws/index.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +14 -28
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/local-state/LocalState.d.cts +2 -3
- package/__cjs/masking/types.d.cts +1 -2
- package/__cjs/react/hooks/internal/useDeepMemo.cjs +0 -2
- package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.cjs +1 -1
- package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.d.cts +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.cjs +87 -38
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +6 -65
- package/__cjs/react/hooks/useLazyQuery.cjs +0 -2
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.cjs +1 -7
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +1 -13
- package/__cjs/react/hooks/useQuery.cjs +4 -1
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs +3 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs +3 -1
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.cjs +16 -16
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +7 -33
- package/__cjs/react/hooks/useSuspenseQuery.cjs +4 -4
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs +22 -3
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +4 -2
- package/__cjs/react/internal/cache/QueryReference.cjs +0 -16
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +0 -5
- package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.d.cts +1 -1
- package/__cjs/react/internal/cache/types.d.cts +2 -2
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -41
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/ssr/useSSRQuery.cjs +0 -1
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
- package/__cjs/utilities/DeepPartial.cjs.map +1 -1
- package/__cjs/utilities/DeepPartial.d.cts +1 -1
- package/__cjs/utilities/internal/DeepMerger.cjs +4 -36
- package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
- package/__cjs/utilities/internal/DeepMerger.d.cts +4 -20
- package/__cjs/utilities/internal/bindCacheKey.cjs +21 -0
- package/__cjs/utilities/internal/bindCacheKey.cjs.map +1 -0
- package/__cjs/utilities/internal/bindCacheKey.d.cts +15 -0
- package/__cjs/utilities/internal/compact.cjs +1 -1
- package/__cjs/utilities/internal/compact.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.cjs +1 -17
- package/__cjs/utilities/internal/constants.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.d.cts +0 -16
- package/__cjs/utilities/internal/getStoreKeyName.cjs +0 -1
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
- package/__cjs/utilities/internal/index.cjs +4 -8
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +2 -4
- package/__cjs/utilities/internal/memoize.cjs +2 -2
- package/__cjs/utilities/internal/memoize.cjs.map +1 -1
- package/__cjs/utilities/internal/memoize.d.cts +1 -2
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/core/cache.d.ts +25 -94
- package/cache/core/cache.js +51 -172
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +17 -49
- package/cache/core/types/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 -6
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +6 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +0 -1
- package/cache/inmemory/inMemoryCache.js +1 -15
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/policies.d.ts +6 -30
- package/cache/inmemory/policies.js +7 -45
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +3 -3
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +0 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -2
- package/cache/inmemory/writeToStore.js +12 -26
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +17 -143
- package/core/ApolloClient.js +50 -32
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +0 -1
- package/core/ObservableQuery.js +131 -165
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -2
- package/core/QueryInfo.js +2 -10
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +2 -18
- package/core/QueryManager.js +25 -47
- package/core/QueryManager.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +7 -15
- package/incremental/handlers/defer20220824.js +19 -44
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/notImplemented.js +1 -1
- package/incremental/handlers/notImplemented.js.map +1 -1
- package/incremental/index.d.ts +0 -1
- package/incremental/index.js +2 -3
- package/incremental/index.js.map +1 -1
- package/incremental/types.d.ts +0 -9
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +62 -78
- package/link/client-awareness/ClientAwarenessLink.d.ts +1 -1
- package/link/client-awareness/ClientAwarenessLink.js +1 -13
- package/link/client-awareness/ClientAwarenessLink.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/remove-typename/removeTypenameFromVariables.d.ts +3 -0
- package/link/remove-typename/removeTypenameFromVariables.js +51 -50
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/ws/index.js +1 -1
- package/local-state/LocalState.d.ts +2 -3
- package/local-state/LocalState.js +14 -28
- package/local-state/LocalState.js.map +1 -1
- package/masking/types.d.ts +1 -2
- package/masking/types.js.map +1 -1
- package/package.json +1 -15
- package/react/hooks/internal/useDeepMemo.js +0 -2
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/useApolloClient.d.ts +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.js +3 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +6 -65
- package/react/hooks/useFragment.js +87 -38
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +0 -2
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +1 -13
- package/react/hooks/useMutation.js +1 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.js +4 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js +3 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.js +3 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +7 -33
- package/react/hooks/useSuspenseFragment.js +17 -17
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +4 -4
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/internal/useDeepMemo.js +0 -2
- package/react/hooks-compiled/internal/useDeepMemo.js.map +1 -1
- package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js +2 -0
- package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js.map +1 -1
- package/react/hooks-compiled/useApolloClient.d.ts +1 -1
- package/react/hooks-compiled/useApolloClient.js +1 -1
- package/react/hooks-compiled/useApolloClient.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.js +3 -1
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useFragment.d.ts +6 -65
- package/react/hooks-compiled/useFragment.js +88 -110
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.js +0 -2
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.js +75 -69
- package/react/hooks-compiled/useMutation.d.ts +1 -13
- package/react/hooks-compiled/useMutation.js +13 -5
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.js +56 -44
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.js +5 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useReadQuery.js +14 -77
- package/react/hooks-compiled/useReadQuery.js.map +1 -1
- package/react/hooks-compiled/useSubscription.js +93 -237
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseFragment.d.ts +7 -33
- package/react/hooks-compiled/useSuspenseFragment.js +17 -17
- package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.js +8 -4
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/index.compiled.d.ts +1 -1
- package/react/index.compiled.js +1 -1
- package/react/index.compiled.js.map +1 -1
- package/react/internal/cache/FragmentReference.d.ts +4 -2
- package/react/internal/cache/FragmentReference.js +22 -3
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +0 -5
- package/react/internal/cache/QueryReference.js +0 -16
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +1 -1
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/cache/types.d.ts +2 -2
- package/react/internal/cache/types.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.js +1 -41
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/useSSRQuery.js +0 -1
- package/react/ssr/useSSRQuery.js.map +1 -1
- package/utilities/DeepPartial.d.ts +1 -1
- package/utilities/DeepPartial.js.map +1 -1
- package/utilities/internal/DeepMerger.d.ts +4 -20
- package/utilities/internal/DeepMerger.js +4 -36
- package/utilities/internal/DeepMerger.js.map +1 -1
- package/utilities/internal/bindCacheKey.d.ts +15 -0
- package/utilities/internal/bindCacheKey.js +18 -0
- package/utilities/internal/bindCacheKey.js.map +1 -0
- package/utilities/internal/compact.js +1 -1
- package/utilities/internal/compact.js.map +1 -1
- package/utilities/internal/constants.d.ts +0 -16
- package/utilities/internal/constants.js +0 -16
- package/utilities/internal/constants.js.map +1 -1
- package/utilities/internal/getStoreKeyName.js +0 -1
- package/utilities/internal/getStoreKeyName.js.map +1 -1
- package/utilities/internal/index.d.ts +2 -4
- package/utilities/internal/index.js +2 -3
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/memoize.d.ts +1 -2
- package/utilities/internal/memoize.js +2 -2
- package/utilities/internal/memoize.js.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +0 -222
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +0 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +0 -98
- package/__cjs/utilities/internal/combineLatestBatched.cjs +0 -71
- package/__cjs/utilities/internal/combineLatestBatched.cjs.map +0 -1
- package/__cjs/utilities/internal/combineLatestBatched.d.cts +0 -14
- package/__cjs/utilities/internal/mapObservableFragment.cjs +0 -27
- package/__cjs/utilities/internal/mapObservableFragment.cjs.map +0 -1
- package/__cjs/utilities/internal/mapObservableFragment.d.cts +0 -3
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs +0 -61
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs.map +0 -1
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.d.cts +0 -11
- package/__cjs/utilities/internal/ponyfills/index.cjs +0 -6
- package/__cjs/utilities/internal/ponyfills/index.cjs.map +0 -1
- package/__cjs/utilities/internal/ponyfills/index.d.cts +0 -3
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs +0 -6
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs.map +0 -1
- package/__cjs/utilities/internal/ponyfills/index.react-native.d.cts +0 -2
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs +0 -3
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs.map +0 -1
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.d.cts +0 -24
- package/incremental/handlers/graphql17Alpha9.d.ts +0 -98
- package/incremental/handlers/graphql17Alpha9.js +0 -218
- package/incremental/handlers/graphql17Alpha9.js.map +0 -1
- package/legacyEntryPoints/utilities/internal/ponyfills/index.d.ts +0 -1
- package/legacyEntryPoints/utilities/internal/ponyfills/index.js +0 -1
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.cjs +0 -1
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.d.cts +0 -1
- package/utilities/internal/combineLatestBatched.d.ts +0 -14
- package/utilities/internal/combineLatestBatched.js +0 -68
- package/utilities/internal/combineLatestBatched.js.map +0 -1
- package/utilities/internal/mapObservableFragment.d.ts +0 -3
- package/utilities/internal/mapObservableFragment.js +0 -24
- package/utilities/internal/mapObservableFragment.js.map +0 -1
- package/utilities/internal/ponyfills/FinalizationRegistry.d.ts +0 -11
- package/utilities/internal/ponyfills/FinalizationRegistry.js +0 -57
- package/utilities/internal/ponyfills/FinalizationRegistry.js.map +0 -1
- package/utilities/internal/ponyfills/index.d.ts +0 -3
- package/utilities/internal/ponyfills/index.js +0 -3
- package/utilities/internal/ponyfills/index.js.map +0 -1
- package/utilities/internal/ponyfills/index.react-native.d.ts +0 -2
- package/utilities/internal/ponyfills/index.react-native.js +0 -2
- package/utilities/internal/ponyfills/index.react-native.js.map +0 -1
- package/utilities/internal/types/ExtensionsWithStreamDetails.d.ts +0 -24
- package/utilities/internal/types/ExtensionsWithStreamDetails.js +0 -2
- package/utilities/internal/types/ExtensionsWithStreamDetails.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,208 +1,24 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
-
## 4.0.
|
|
3
|
+
## 4.0.13
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- [#
|
|
7
|
+
- [#13094](https://github.com/apollographql/apollo-client/pull/13094) [`9cbe2c2`](https://github.com/apollographql/apollo-client/commit/9cbe2c2dd2282ac861327d3c394578db7706df05) Thanks [@phryneas](https://github.com/phryneas)! - Ensure that `compact` and `mergeOptions` preserve symbol keys.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
This fixes an issue where the change introduced in 4.0.11 via #13049 would not
|
|
10
|
+
be applied if `defaultOptions` for `watchQuery` were declared.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
Please note that `compact` and `mergeOptions` are considered internal utilities
|
|
13
|
+
and they might have similar behavior changes in future releases.
|
|
14
|
+
Do not use them in your application code - a change like this is not considered
|
|
15
|
+
breaking and will not be announced as such.
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- [#13056](https://github.com/apollographql/apollo-client/pull/13056) [`b224efc`](https://github.com/apollographql/apollo-client/commit/b224efc25515370c68b514405762e68a443e4a4a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `InMemoryCache` no longer filters out explicitly returned `undefined` items from `read` functions for array fields. This now makes it possible to create `read` functions on array fields that return partial data and trigger a fetch for the full list.
|
|
16
|
-
|
|
17
|
-
- [#13058](https://github.com/apollographql/apollo-client/pull/13058) [`121a2cb`](https://github.com/apollographql/apollo-client/commit/121a2cb68820727186ecd74ce1041ef95284682e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add an `extensions` option to `cache.write`, `cache.writeQuery`, and `client.writeQuery`. This makes `extensions` available in cache `merge` functions which can be accessed with the other merge function options.
|
|
18
|
-
|
|
19
|
-
As a result of this change, any `extensions` returned in GraphQL operations are now available in `merge` in the cache writes for these operations.
|
|
20
|
-
|
|
21
|
-
### Patch Changes
|
|
22
|
-
|
|
23
|
-
- [#13053](https://github.com/apollographql/apollo-client/pull/13053) [`23ca0ba`](https://github.com/apollographql/apollo-client/commit/23ca0ba895473b397805e6bcc70e0fcf987547c5) Thanks [@phryneas](https://github.com/phryneas)! - Use memoized observable mapping when using `watchFragment`, `useFragment` or `useSuspenseFragment`.
|
|
24
|
-
|
|
25
|
-
## 4.1.0-alpha.10
|
|
26
|
-
|
|
27
|
-
### Patch Changes
|
|
28
|
-
|
|
29
|
-
- [#13053](https://github.com/apollographql/apollo-client/pull/13053) [`23ca0ba`](https://github.com/apollographql/apollo-client/commit/23ca0ba895473b397805e6bcc70e0fcf987547c5) Thanks [@phryneas](https://github.com/phryneas)! - Use memoized observable mapping when using `watchFragment`, `useFragment` or `useSuspenseFragment`.
|
|
30
|
-
|
|
31
|
-
## 4.1.0-alpha.9
|
|
32
|
-
|
|
33
|
-
### Minor Changes
|
|
34
|
-
|
|
35
|
-
- [#13056](https://github.com/apollographql/apollo-client/pull/13056) [`b224efc`](https://github.com/apollographql/apollo-client/commit/b224efc25515370c68b514405762e68a443e4a4a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `InMemoryCache` no longer filters out explicitly returned `undefined` items from `read` functions for array fields. This now makes it possible to create `read` functions on array fields that return partial data and trigger a fetch for the full list.
|
|
36
|
-
|
|
37
|
-
## 4.1.0-alpha.8
|
|
38
|
-
|
|
39
|
-
### Minor Changes
|
|
40
|
-
|
|
41
|
-
- [#13043](https://github.com/apollographql/apollo-client/pull/13043) [`65e66ca`](https://github.com/apollographql/apollo-client/commit/65e66cafb6828b63d14b64877bbad47af95f66e4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Support `headers` transport for enhanced client awareness.
|
|
42
|
-
|
|
43
|
-
## 4.1.0-alpha.7
|
|
44
|
-
|
|
45
|
-
### Minor Changes
|
|
46
|
-
|
|
47
|
-
- [#13038](https://github.com/apollographql/apollo-client/pull/13038) [`109efe7`](https://github.com/apollographql/apollo-client/commit/109efe7e4380b579c6a577982bd9a6e8c6a53892) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the `from` option to `readFragment`, `watchFragment`, and `updateFragment`.
|
|
48
|
-
|
|
49
|
-
## 4.1.0-alpha.6
|
|
50
|
-
|
|
51
|
-
### Patch Changes
|
|
52
|
-
|
|
53
|
-
- [#13026](https://github.com/apollographql/apollo-client/pull/13026) [`05eee67`](https://github.com/apollographql/apollo-client/commit/05eee67e91b480252923879987534e81d2866aba) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Reduce the number of observables created by `watchFragment` by reusing existing observables as much as possible. This should improve performance when watching the same item in the cache multiple times after a cache update occurs.
|
|
54
|
-
|
|
55
|
-
## 4.1.0-alpha.5
|
|
56
|
-
|
|
57
|
-
### Patch Changes
|
|
58
|
-
|
|
59
|
-
- [#13010](https://github.com/apollographql/apollo-client/pull/13010) [`7627000`](https://github.com/apollographql/apollo-client/commit/76270002254b0c6acb18872a39ab180f9f1e4067) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where errors parsed from incremental chunks in `ErrorLink` might throw when using the `GraphQL17Alpha9Handler`.
|
|
60
|
-
|
|
61
|
-
- [#13010](https://github.com/apollographql/apollo-client/pull/13010) [`7627000`](https://github.com/apollographql/apollo-client/commit/76270002254b0c6acb18872a39ab180f9f1e4067) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Handle `@stream` payloads that send multiple items in the same chunk when using the `Defer20220824Handler`.
|
|
62
|
-
|
|
63
|
-
- [#13010](https://github.com/apollographql/apollo-client/pull/13010) [`7627000`](https://github.com/apollographql/apollo-client/commit/76270002254b0c6acb18872a39ab180f9f1e4067) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Handle an edge case with the `Defer20220824Handler` where an error for a `@stream` item that bubbles to the `@stream` boundary (such as an item returning `null` for a non-null array item) would write items from future chunks to the wrong array index. In these cases, the `@stream` field is no longer processed and future updates to the field are ignored. This prevents runtime errors that TypeScript would otherwise not be able to catch.
|
|
64
|
-
|
|
65
|
-
## 4.1.0-alpha.4
|
|
66
|
-
|
|
67
|
-
### Patch Changes
|
|
68
|
-
|
|
69
|
-
- [#13009](https://github.com/apollographql/apollo-client/pull/13009) [`259ae9b`](https://github.com/apollographql/apollo-client/commit/259ae9bafaa8122996b0a52dd99828b2261087e5) Thanks [@phryneas](https://github.com/phryneas)! - Allow `FragmentType` not only to be called as `FragmentType<TData>`, but also as `FragmentType<TypedDocumentNode>`.
|
|
70
|
-
|
|
71
|
-
- [#13012](https://github.com/apollographql/apollo-client/pull/13012) [`44706a2`](https://github.com/apollographql/apollo-client/commit/44706a2e7ae2c977fa917214a1ff5e5fe4a9b3a7) Thanks [@phryneas](https://github.com/phryneas)! - Add helper type `QueryRef.ForQuery<TypedDocumentNode>`
|
|
72
|
-
|
|
73
|
-
## 4.1.0-alpha.3
|
|
74
|
-
|
|
75
|
-
### Minor Changes
|
|
76
|
-
|
|
77
|
-
- [#12971](https://github.com/apollographql/apollo-client/pull/12971) [`d11eb40`](https://github.com/apollographql/apollo-client/commit/d11eb40aa41d90ac664705bac01158d58bf55e9b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add support for `from: null` in `client.watchFragment` and `cache.watchFragment`. When `from` is `null`, the emitted result is:
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
{
|
|
81
|
-
data: null,
|
|
82
|
-
dataState: "complete",
|
|
83
|
-
complete: true,
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
- [#12971](https://github.com/apollographql/apollo-client/pull/12971) [`d11eb40`](https://github.com/apollographql/apollo-client/commit/d11eb40aa41d90ac664705bac01158d58bf55e9b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add support for arrays with `useFragment`, `useSuspenseFragment`, and `client.watchFragment`. This allows the ability to use a fragment to watch multiple entities in the cache. Passing an array to `from` will return `data` as an array where each array index corresponds to the index in the `from` array.
|
|
88
|
-
|
|
89
|
-
```ts
|
|
90
|
-
function MyComponent() {
|
|
91
|
-
const result = useFragment({
|
|
92
|
-
fragment,
|
|
93
|
-
from: [item1, item2, item3],
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// `data` is an array with 3 items
|
|
97
|
-
console.log(result); // { data: [{...}, {...}, {...}], dataState: "complete", complete: true }
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
- [#12971](https://github.com/apollographql/apollo-client/pull/12971) [`d11eb40`](https://github.com/apollographql/apollo-client/commit/d11eb40aa41d90ac664705bac01158d58bf55e9b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a `getCurrentResult` function to the observable returned by `client.watchFragment` and `cache.watchFragment` that returns the current value for the watched fragment.
|
|
102
|
-
|
|
103
|
-
```ts
|
|
104
|
-
const observable = client.watchFragment({
|
|
105
|
-
fragment,
|
|
106
|
-
from: { __typename: "Item", id: 1 },
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
console.log(observable.getCurrentResult());
|
|
110
|
-
// {
|
|
111
|
-
// data: {...},
|
|
112
|
-
// dataState: "complete",
|
|
113
|
-
// complete: true,
|
|
114
|
-
// }
|
|
115
|
-
```
|
|
17
|
+
## 4.0.12
|
|
116
18
|
|
|
117
19
|
### Patch Changes
|
|
118
20
|
|
|
119
|
-
- [#
|
|
120
|
-
|
|
121
|
-
- [#12982](https://github.com/apollographql/apollo-client/pull/12982) [`5c56b32`](https://github.com/apollographql/apollo-client/commit/5c56b3210a2c03e247ec9e600f1e27eb71df5e96) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ignore top-level `data` values on subsequent chunks in incremental responses.
|
|
122
|
-
|
|
123
|
-
- [#12982](https://github.com/apollographql/apollo-client/pull/12982) [`5c56b32`](https://github.com/apollographql/apollo-client/commit/5c56b3210a2c03e247ec9e600f1e27eb71df5e96) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix the `Defer20220824Handler.SubsequentResult` type to match the `FormattedSubsequentIncrementalExecutionResult` type in `graphql@17.0.0-alpha.2`.
|
|
124
|
-
|
|
125
|
-
- [#12973](https://github.com/apollographql/apollo-client/pull/12973) [`072da24`](https://github.com/apollographql/apollo-client/commit/072da24a8daec3a646ef0cce30de32f95ea0bb23) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Update the `accept` header used with the `GraphQL17Alpha9Handler` to `multipart/mixed;incrementalSpec=v0.2` to ensure the newest incremental delivery format is requested.
|
|
126
|
-
|
|
127
|
-
- [#12971](https://github.com/apollographql/apollo-client/pull/12971) [`d11eb40`](https://github.com/apollographql/apollo-client/commit/d11eb40aa41d90ac664705bac01158d58bf55e9b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `DeepPartial<Array<TData>>` now returns `Array<DeepPartial<TData>>` instead of `Array<DeepPartial<TData | undefined>>`.
|
|
128
|
-
|
|
129
|
-
## 4.1.0-alpha.2
|
|
130
|
-
|
|
131
|
-
### Minor Changes
|
|
132
|
-
|
|
133
|
-
- [#12959](https://github.com/apollographql/apollo-client/pull/12959) [`556e837`](https://github.com/apollographql/apollo-client/commit/556e83781069d925a7e8f99e49023f6f858c6438) Thanks [@jerelmiller](https://github.com/jerelmiller)! - You can now provide a callback function as the `context` option on the `mutate` function returned by `useMutation`. The callback function is called with the value of the `context` option provided to the `useMutation` hook. This is useful if you'd like to merge the context object provided to the `useMutation` hook with a value provided to the `mutate` function.
|
|
134
|
-
|
|
135
|
-
```ts
|
|
136
|
-
function MyComponent() {
|
|
137
|
-
const [mutate, result] = useMutation(MUTATION, {
|
|
138
|
-
context: { foo: true },
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
async function runMutation() {
|
|
142
|
-
await mutate({
|
|
143
|
-
// sends context as { foo: true, bar: true }
|
|
144
|
-
context: (hookContext) => ({ ...hookContext, bar: true }),
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// ...
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### Patch Changes
|
|
153
|
-
|
|
154
|
-
- [#12954](https://github.com/apollographql/apollo-client/pull/12954) [`1c82eaf`](https://github.com/apollographql/apollo-client/commit/1c82eafe4921a9e30128202623be6c5a3d4df803) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure an error is thrown when `@stream` is detected and an `incrementalDelivery` handler is not configured.
|
|
155
|
-
|
|
156
|
-
## 4.1.0-alpha.1
|
|
157
|
-
|
|
158
|
-
### Minor Changes
|
|
159
|
-
|
|
160
|
-
- [#12934](https://github.com/apollographql/apollo-client/pull/12934) [`54ab6d9`](https://github.com/apollographql/apollo-client/commit/54ab6d994692dad9f06d3d0b84c84d021d126577) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't set the fallback value of a `@client` field to `null` when a `read` function is defined. Instead the `read` function will be called with an `existing` value of `undefined` to allow default arguments to be used to set the returned value.
|
|
161
|
-
|
|
162
|
-
When a `read` function is not defined nor is there a defined resolver for the field, warn and set the value to `null` only in that instance.
|
|
163
|
-
|
|
164
|
-
- [#12934](https://github.com/apollographql/apollo-client/pull/12934) [`54ab6d9`](https://github.com/apollographql/apollo-client/commit/54ab6d994692dad9f06d3d0b84c84d021d126577) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add an abstract `resolvesClientField` function to `ApolloCache` that can be used by caches to tell `LocalState` if it can resolve a `@client` field when a local resolver is not defined.
|
|
165
|
-
|
|
166
|
-
`LocalState` will emit a warning and set a fallback value of `null` when no local resolver is defined and `resolvesClientField` returns `false`, or isn't defined. Returning `true` from `resolvesClientField` signals that a mechanism in the cache will set the field value. In this case, `LocalState` won't set the field value.
|
|
167
|
-
|
|
168
|
-
### Patch Changes
|
|
169
|
-
|
|
170
|
-
- [#12915](https://github.com/apollographql/apollo-client/pull/12915) [`c97b145`](https://github.com/apollographql/apollo-client/commit/c97b145188d39d754ff098ff399a80cae5b10cc0) Thanks [@phryneas](https://github.com/phryneas)! - Create mechanism to add experimental features to Apollo Client
|
|
171
|
-
|
|
172
|
-
- [#12934](https://github.com/apollographql/apollo-client/pull/12934) [`54ab6d9`](https://github.com/apollographql/apollo-client/commit/54ab6d994692dad9f06d3d0b84c84d021d126577) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `LocalState` doesn't try to read from the cache when using a `no-cache` fetch policy.
|
|
173
|
-
|
|
174
|
-
- [#12934](https://github.com/apollographql/apollo-client/pull/12934) [`54ab6d9`](https://github.com/apollographql/apollo-client/commit/54ab6d994692dad9f06d3d0b84c84d021d126577) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Warn when using a `no-cache` fetch policy without a local resolver defined. `no-cache` queries do not read or write to the cache which meant `no-cache` queries are silently incomplete when the `@client` field value was handled by a cache `read` function.
|
|
175
|
-
|
|
176
|
-
## 4.1.0-alpha.0
|
|
177
|
-
|
|
178
|
-
### Minor Changes
|
|
179
|
-
|
|
180
|
-
- [#12923](https://github.com/apollographql/apollo-client/pull/12923) [`2aa31c7`](https://github.com/apollographql/apollo-client/commit/2aa31c718155e88814551afb14fd7a0035acc57d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where deferred payloads that reteurned arrays with fewer items than the original cached array would retain items from the cached array. This change includes `@stream` arrays where stream arrays replace the cached arrays.
|
|
181
|
-
|
|
182
|
-
- [#12926](https://github.com/apollographql/apollo-client/pull/12926) [`c7fba99`](https://github.com/apollographql/apollo-client/commit/c7fba99e16da522fdbc35b9c16cdb8df0dda4c2c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Support the newer incremental delivery format for the `@defer` directive implemented in `graphql@17.0.0-alpha.9`. Import the `GraphQL17Alpha9Handler` to use the newer incremental delivery format with `@defer`.
|
|
183
|
-
|
|
184
|
-
```ts
|
|
185
|
-
import { GraphQL17Alpha9Handler } from "@apollo/client/incremental";
|
|
186
|
-
|
|
187
|
-
const client = new ApolloClient({
|
|
188
|
-
// ...
|
|
189
|
-
incrementalHandler: new GraphQL17Alpha9Handler(),
|
|
190
|
-
});
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
> [!NOTE]
|
|
194
|
-
> In order to use the `GraphQL17Alpha9Handler`, the GraphQL server MUST implement the newer incremental delivery format. You may see errors or unusual behavior if you use the wrong handler. If you are using Apollo Router, continue to use the `Defer20220824Handler` because Apollo Router does not yet support the newer incremental delivery format.
|
|
195
|
-
|
|
196
|
-
- [#12918](https://github.com/apollographql/apollo-client/pull/12918) [`562e219`](https://github.com/apollographql/apollo-client/commit/562e2191a4b38e05edb3da9074e2958db3c7b6b9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add support for the `@stream` directive on both the `Defer20220824Handler` and the `GraphQL17Alpha2Handler`.
|
|
197
|
-
|
|
198
|
-
> [!NOTE]
|
|
199
|
-
> The implementations of `@stream` differ in the delivery of incremental results between the different GraphQL spec versions. If you upgrading from the older format to the newer format, expect the timing of some incremental results to change.
|
|
200
|
-
|
|
201
|
-
### Patch Changes
|
|
202
|
-
|
|
203
|
-
- [#12925](https://github.com/apollographql/apollo-client/pull/12925) [`f538a83`](https://github.com/apollographql/apollo-client/commit/f538a83621e1d110286c056dd8e91611dfd9a1d3) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where calling `fetchMore` with `@defer` or `@stream` would not rerender incremental results as they were streamed.
|
|
204
|
-
|
|
205
|
-
- [#12923](https://github.com/apollographql/apollo-client/pull/12923) [`01cace0`](https://github.com/apollographql/apollo-client/commit/01cace0a6d4faf79e8a4188b93c7d13c4b26d6d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Improve the cache data loss warning message when `existing` or `incoming` is an array.
|
|
21
|
+
- [#13077](https://github.com/apollographql/apollo-client/pull/13077) [`f322460`](https://github.com/apollographql/apollo-client/commit/f322460fe9baae82c0980dd082c1b6b4956a4951) Thanks [@phryneas](https://github.com/phryneas)! - Fix a potential memory leak where Trie nodes would remain in memory too long.
|
|
206
22
|
|
|
207
23
|
## 4.0.11
|
|
208
24
|
|
|
@@ -6,8 +6,6 @@ const {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ApolloCache = void 0;
|
|
8
8
|
const caches_1 = require("@wry/caches");
|
|
9
|
-
const equality_1 = require("@wry/equality");
|
|
10
|
-
const trie_1 = require("@wry/trie");
|
|
11
9
|
const optimism_1 = require("optimism");
|
|
12
10
|
const rxjs_1 = require("rxjs");
|
|
13
11
|
const utilities_1 = require("@apollo/client/utilities");
|
|
@@ -108,7 +106,6 @@ class ApolloCache {
|
|
|
108
106
|
optimistic,
|
|
109
107
|
});
|
|
110
108
|
}
|
|
111
|
-
fragmentWatches = new trie_1.Trie(true);
|
|
112
109
|
/**
|
|
113
110
|
* Watches the cache store of the fragment according to the options specified
|
|
114
111
|
* and returns an `Observable`. We can subscribe to this
|
|
@@ -126,159 +123,61 @@ class ApolloCache {
|
|
|
126
123
|
* to optimistic updates.
|
|
127
124
|
*/
|
|
128
125
|
watchFragment(options) {
|
|
129
|
-
const { fragment, fragmentName, from } = options;
|
|
126
|
+
const { fragment, fragmentName, from, optimistic = true, ...otherOptions } = options;
|
|
130
127
|
const query = this.getFragmentDoc(fragment, fragmentName);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
128
|
+
// While our TypeScript types do not allow for `undefined` as a valid
|
|
129
|
+
// `from`, its possible `useFragment` gives us an `undefined` since it
|
|
130
|
+
// calls` cache.identify` and provides that value to `from`. We are
|
|
131
|
+
// adding this fix here however to ensure those using plain JavaScript
|
|
132
|
+
// and using `cache.identify` themselves will avoid seeing the obscure
|
|
133
|
+
// warning.
|
|
134
|
+
const id = typeof from === "undefined" || typeof from === "string" ?
|
|
135
|
+
from
|
|
136
|
+
: this.identify(from);
|
|
137
|
+
if (environment_1.__DEV__) {
|
|
138
|
+
const actualFragmentName = fragmentName || (0, internal_1.getFragmentDefinition)(fragment).name.value;
|
|
139
|
+
if (!id) {
|
|
140
|
+
__DEV__ && invariant_1.invariant.warn(110, actualFragmentName);
|
|
145
141
|
}
|
|
146
|
-
return id;
|
|
147
|
-
});
|
|
148
|
-
if (!Array.isArray(from)) {
|
|
149
|
-
const observable = this.watchSingleFragment(ids[0], query, options);
|
|
150
|
-
// Unfortunately we forgot to allow for `null` on watchFragment in 4.0
|
|
151
|
-
// when `from` is a single record. As such, we need to fallback to {}
|
|
152
|
-
// when diff.result is null to maintain backwards compatibility. We
|
|
153
|
-
// should plan to change this in v5. We do however support `null` if
|
|
154
|
-
// `from` is explicitly `null`.
|
|
155
|
-
//
|
|
156
|
-
// NOTE: Using `from` with an array will maintain `null` properly
|
|
157
|
-
// without the need for a similar fallback since watchFragment with
|
|
158
|
-
// arrays is new functionality in v4.1.
|
|
159
|
-
return from === null ? observable : ((0, internal_1.mapObservableFragmentMemoized)(observable, Symbol.for("apollo.transform.individualResult"), (result) => ({
|
|
160
|
-
...result,
|
|
161
|
-
data: result.data ?? {},
|
|
162
|
-
})));
|
|
163
|
-
}
|
|
164
|
-
let currentResult;
|
|
165
|
-
function toResult(results) {
|
|
166
|
-
const result = results.reduce((memo, result, idx) => {
|
|
167
|
-
memo.data.push(result.data);
|
|
168
|
-
memo.complete &&= result.complete;
|
|
169
|
-
memo.dataState = memo.complete ? "complete" : "partial";
|
|
170
|
-
if (result.missing) {
|
|
171
|
-
memo.missing ||= {};
|
|
172
|
-
memo.missing[idx] = result.missing;
|
|
173
|
-
}
|
|
174
|
-
return memo;
|
|
175
|
-
}, {
|
|
176
|
-
data: [],
|
|
177
|
-
dataState: "complete",
|
|
178
|
-
complete: true,
|
|
179
|
-
});
|
|
180
|
-
if (!(0, equality_1.equal)(currentResult, result)) {
|
|
181
|
-
currentResult = result;
|
|
182
|
-
}
|
|
183
|
-
return currentResult;
|
|
184
|
-
}
|
|
185
|
-
if (ids.length === 0) {
|
|
186
|
-
return emptyArrayObservable;
|
|
187
142
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
const { optimistic = true, variables } = options;
|
|
215
|
-
const cacheKey = [
|
|
216
|
-
fragmentQuery,
|
|
217
|
-
(0, utilities_1.canonicalStringify)({ id, optimistic, variables }),
|
|
218
|
-
];
|
|
219
|
-
const cacheEntry = this.fragmentWatches.lookupArray(cacheKey);
|
|
220
|
-
if (!cacheEntry.observable) {
|
|
221
|
-
let subscribed = false;
|
|
222
|
-
let currentResult;
|
|
223
|
-
function getNewestResult(diff) {
|
|
224
|
-
const data = diff.result;
|
|
225
|
-
if (!currentResult ||
|
|
226
|
-
!(0, internal_1.equalByQuery)(fragmentQuery, { data: currentResult.data }, { data }, options.variables)) {
|
|
227
|
-
currentResult = {
|
|
143
|
+
const diffOptions = {
|
|
144
|
+
...otherOptions,
|
|
145
|
+
returnPartialData: true,
|
|
146
|
+
id,
|
|
147
|
+
query,
|
|
148
|
+
optimistic,
|
|
149
|
+
};
|
|
150
|
+
let latestDiff;
|
|
151
|
+
return new rxjs_1.Observable((observer) => {
|
|
152
|
+
return this.watch({
|
|
153
|
+
...diffOptions,
|
|
154
|
+
immediate: true,
|
|
155
|
+
callback: (diff) => {
|
|
156
|
+
let data = diff.result;
|
|
157
|
+
// TODO: Remove this once `watchFragment` supports `null` as valid
|
|
158
|
+
// value emitted
|
|
159
|
+
if (data === null) {
|
|
160
|
+
data = {};
|
|
161
|
+
}
|
|
162
|
+
if (
|
|
163
|
+
// Always ensure we deliver the first result
|
|
164
|
+
latestDiff &&
|
|
165
|
+
(0, internal_1.equalByQuery)(query, { data: latestDiff.result }, { data }, options.variables)) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const result = {
|
|
228
169
|
data,
|
|
229
170
|
dataState: diff.complete ? "complete" : "partial",
|
|
230
|
-
complete: diff.complete,
|
|
171
|
+
complete: !!diff.complete,
|
|
231
172
|
};
|
|
232
173
|
if (diff.missing) {
|
|
233
|
-
|
|
174
|
+
result.missing = diff.missing.missing;
|
|
234
175
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
const observable = new rxjs_1.Observable((observer) => {
|
|
239
|
-
subscribed = true;
|
|
240
|
-
const cleanup = this.watch({
|
|
241
|
-
variables,
|
|
242
|
-
returnPartialData: true,
|
|
243
|
-
id,
|
|
244
|
-
query: fragmentQuery,
|
|
245
|
-
optimistic,
|
|
246
|
-
immediate: true,
|
|
247
|
-
callback: (diff) => {
|
|
248
|
-
observable.dirty = true;
|
|
249
|
-
this.onAfterBroadcast(() => {
|
|
250
|
-
observer.next(getNewestResult(diff));
|
|
251
|
-
observable.dirty = false;
|
|
252
|
-
});
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
return () => {
|
|
256
|
-
subscribed = false;
|
|
257
|
-
cleanup();
|
|
258
|
-
this.fragmentWatches.removeArray(cacheKey);
|
|
259
|
-
};
|
|
260
|
-
}).pipe((0, rxjs_1.distinctUntilChanged)(), (0, rxjs_1.share)({
|
|
261
|
-
connector: () => new rxjs_1.ReplaySubject(1),
|
|
262
|
-
// debounce so a synchronous unsubscribe+resubscribe doesn't tear down the watch and create a new one
|
|
263
|
-
resetOnRefCountZero: () => (0, rxjs_1.timer)(0),
|
|
264
|
-
}));
|
|
265
|
-
cacheEntry.observable = Object.assign(observable, {
|
|
266
|
-
dirty: false,
|
|
267
|
-
getCurrentResult: () => {
|
|
268
|
-
if (subscribed && currentResult) {
|
|
269
|
-
return currentResult;
|
|
270
|
-
}
|
|
271
|
-
return getNewestResult(this.diff({
|
|
272
|
-
id,
|
|
273
|
-
query: fragmentQuery,
|
|
274
|
-
returnPartialData: true,
|
|
275
|
-
optimistic,
|
|
276
|
-
variables,
|
|
277
|
-
}));
|
|
176
|
+
latestDiff = { ...diff, result: data };
|
|
177
|
+
observer.next(result);
|
|
278
178
|
},
|
|
279
179
|
});
|
|
280
|
-
}
|
|
281
|
-
return cacheEntry.observable;
|
|
180
|
+
});
|
|
282
181
|
}
|
|
283
182
|
// Make sure we compute the same (===) fragment query document every
|
|
284
183
|
// time we receive the same fragment in readFragment.
|
|
@@ -286,13 +185,13 @@ class ApolloCache {
|
|
|
286
185
|
max: utilities_1.cacheSizes["cache.fragmentQueryDocuments"] ||
|
|
287
186
|
1000 /* defaultCacheSizes["cache.fragmentQueryDocuments"] */,
|
|
288
187
|
cache: caches_1.WeakCache,
|
|
188
|
+
makeCacheKey: (0, internal_1.bindCacheKey)(this),
|
|
289
189
|
});
|
|
290
190
|
readFragment(options, optimistic = !!options.optimistic) {
|
|
291
|
-
const id = options.from !== undefined ? this.toCacheId(options.from) : options.id;
|
|
292
191
|
return this.read({
|
|
293
192
|
...options,
|
|
294
193
|
query: this.getFragmentDoc(options.fragment, options.fragmentName),
|
|
295
|
-
rootId: id,
|
|
194
|
+
rootId: options.id,
|
|
296
195
|
optimistic,
|
|
297
196
|
});
|
|
298
197
|
}
|
|
@@ -302,8 +201,7 @@ class ApolloCache {
|
|
|
302
201
|
result: data,
|
|
303
202
|
}));
|
|
304
203
|
}
|
|
305
|
-
writeFragment({ data, fragment, fragmentName, ...options }) {
|
|
306
|
-
const id = options.from !== undefined ? this.toCacheId(options.from) : options.id;
|
|
204
|
+
writeFragment({ id, data, fragment, fragmentName, ...options }) {
|
|
307
205
|
return this.write(Object.assign(options, {
|
|
308
206
|
query: this.getFragmentDoc(fragment, fragmentName),
|
|
309
207
|
dataId: id,
|
|
@@ -334,28 +232,9 @@ class ApolloCache {
|
|
|
334
232
|
},
|
|
335
233
|
});
|
|
336
234
|
}
|
|
337
|
-
toCacheId(from) {
|
|
338
|
-
return typeof from === "string" ? from : this.identify(from);
|
|
339
|
-
}
|
|
340
235
|
}
|
|
341
236
|
exports.ApolloCache = ApolloCache;
|
|
342
237
|
if (environment_1.__DEV__) {
|
|
343
238
|
ApolloCache.prototype.getMemoryInternals = internal_1.getApolloCacheMemoryInternals;
|
|
344
239
|
}
|
|
345
|
-
const nullResult = Object.freeze({
|
|
346
|
-
data: null,
|
|
347
|
-
dataState: "complete",
|
|
348
|
-
complete: true,
|
|
349
|
-
});
|
|
350
|
-
const nullObservable = Object.assign(new rxjs_1.Observable((observer) => {
|
|
351
|
-
observer.next(nullResult);
|
|
352
|
-
}), { dirty: false, getCurrentResult: () => nullResult });
|
|
353
|
-
const emptyArrayResult = Object.freeze({
|
|
354
|
-
data: [],
|
|
355
|
-
dataState: "complete",
|
|
356
|
-
complete: true,
|
|
357
|
-
});
|
|
358
|
-
const emptyArrayObservable = Object.assign(new rxjs_1.Observable((observer) => {
|
|
359
|
-
observer.next(emptyArrayResult);
|
|
360
|
-
}), { getCurrentResult: () => emptyArrayResult });
|
|
361
240
|
//# sourceMappingURL=cache.cjs.map
|