@apollo/client 4.3.0-alpha.1 → 4.3.0-alpha.11
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 +503 -0
- package/README.md +3 -7
- package/__cjs/cache/core/Scalar.cjs +36 -0
- package/__cjs/cache/core/Scalar.cjs.map +1 -0
- package/__cjs/cache/core/Scalar.d.cts +19 -0
- package/__cjs/cache/core/cache.cjs +32 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +89 -6
- package/__cjs/cache/core/types/Cache.d.cts +25 -0
- package/__cjs/cache/index.cjs +3 -1
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +3 -2
- package/__cjs/cache/inmemory/entityStore.cjs +48 -5
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +3 -0
- package/__cjs/cache/inmemory/helpers.d.cts +9 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +83 -4
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +44 -5
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +35 -6
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +4 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +490 -49
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.d.cts +11 -2
- package/__cjs/cache/inmemory/types.d.cts +29 -4
- package/__cjs/cache/inmemory/writeToStore.cjs +6 -6
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +37 -38
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +44 -10
- package/__cjs/core/ObservableQuery.cjs +228 -76
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +16 -8
- package/__cjs/core/QueryInfo.cjs +178 -190
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +16 -21
- package/__cjs/core/QueryManager.cjs +88 -59
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +1 -3
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/core/dataStateErrorCache.cjs +12 -0
- package/__cjs/core/dataStateErrorCache.cjs.map +1 -0
- package/__cjs/core/dataStateErrorCache.d.cts +3 -0
- package/__cjs/core/index.cjs +2 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +4 -3
- package/__cjs/core/types.d.cts +10 -3
- package/__cjs/incremental/GraphQLCodegenIncremental.cjs +3 -0
- package/__cjs/incremental/GraphQLCodegenIncremental.cjs.map +1 -0
- package/__cjs/incremental/GraphQLCodegenIncremental.d.cts +55 -0
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +2 -4
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +47 -16
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +29 -6
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/incremental/index.cjs.map +1 -1
- package/__cjs/incremental/index.d.cts +1 -0
- package/__cjs/{utilities/internal/types/NoInfer.cjs → incremental/internal/types.cjs} +1 -1
- package/__cjs/incremental/internal/types.cjs.map +1 -0
- package/__cjs/incremental/internal/types.d.cts +17 -0
- package/__cjs/incremental/types.d.cts +55 -4
- package/__cjs/invariantErrorCodes.cjs +167 -112
- package/__cjs/link/core/ApolloLink.cjs +3 -3
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +2 -2
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +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 +11 -11
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/local-state/LocalState.d.cts +1 -1
- package/__cjs/masking/internal/types.d.cts +1 -2
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/utils.cjs +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/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +100 -47
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +0 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +2 -2
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +40 -34
- package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +23 -15
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +10 -7
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +74 -32
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.cjs +7 -3
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +7 -4
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +83 -34
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/types.d.cts +14 -3
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -5
- package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
- package/__cjs/testing/core/mocking/mockLink.cjs +25 -5
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +1 -2
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +39 -1
- package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +1 -0
- package/__cjs/utilities/internal/StreamArrayState.cjs +27 -0
- package/__cjs/utilities/internal/StreamArrayState.cjs.map +1 -0
- package/__cjs/utilities/internal/StreamArrayState.d.cts +12 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.cjs +33 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.cjs.map +1 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.d.cts +3 -0
- package/__cjs/utilities/internal/capitalize.cjs +12 -0
- package/__cjs/utilities/internal/capitalize.cjs.map +1 -0
- package/__cjs/utilities/internal/capitalize.d.cts +7 -0
- package/__cjs/utilities/internal/coerceScalarFieldsToParsed.cjs +69 -0
- package/__cjs/utilities/internal/coerceScalarFieldsToParsed.cjs.map +1 -0
- package/__cjs/utilities/internal/coerceScalarFieldsToParsed.d.cts +9 -0
- package/__cjs/utilities/internal/constants.cjs +20 -1
- package/__cjs/utilities/internal/constants.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.d.cts +19 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.cjs +19 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.cjs.map +1 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.d.cts +9 -0
- package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +2 -2
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +2 -2
- package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs +6 -0
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +4 -0
- package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getUnwrappedType.cjs +20 -0
- package/__cjs/utilities/internal/getUnwrappedType.cjs.map +1 -0
- package/__cjs/utilities/internal/getUnwrappedType.d.cts +8 -0
- package/__cjs/utilities/internal/index.cjs +25 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +16 -2
- package/__cjs/utilities/internal/isDeferredFragment.cjs +38 -0
- package/__cjs/utilities/internal/isDeferredFragment.cjs.map +1 -0
- package/__cjs/utilities/internal/isDeferredFragment.d.cts +9 -0
- package/__cjs/utilities/internal/isStreamField.cjs +37 -0
- package/__cjs/utilities/internal/isStreamField.cjs.map +1 -0
- package/__cjs/utilities/internal/isStreamField.d.cts +9 -0
- package/__cjs/utilities/internal/isTypenameField.cjs +7 -0
- package/__cjs/utilities/internal/isTypenameField.cjs.map +1 -0
- package/__cjs/utilities/internal/isTypenameField.d.cts +3 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.cjs +17 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.cjs.map +1 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.d.cts +8 -0
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +1 -1
- package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
- package/__cjs/utilities/internal/toDiffWithDataState.cjs +20 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs.map +1 -0
- package/__cjs/utilities/internal/toDiffWithDataState.d.cts +8 -0
- package/__cjs/utilities/internal/types/DeferInfo.cjs +3 -0
- package/__cjs/utilities/internal/types/DeferInfo.cjs.map +1 -0
- package/__cjs/utilities/internal/types/DeferInfo.d.cts +10 -0
- package/__cjs/utilities/internal/types/Exact.cjs +3 -0
- package/__cjs/utilities/internal/types/Exact.cjs.map +1 -0
- package/__cjs/utilities/internal/types/Exact.d.cts +2 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.cjs +3 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.cjs.map +1 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.d.cts +10 -0
- package/__cjs/utilities/internal/types/IsNeverish.cjs +3 -0
- package/__cjs/utilities/internal/types/IsNeverish.cjs.map +1 -0
- package/__cjs/utilities/internal/types/IsNeverish.d.cts +4 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.d.cts +2 -0
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
- package/__cjs/utilities/policies/pagination.cjs.map +1 -1
- package/__cjs/utilities/policies/pagination.d.cts +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs +1 -0
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/core/Scalar.d.ts +19 -0
- package/cache/core/Scalar.js +32 -0
- package/cache/core/Scalar.js.map +1 -0
- package/cache/core/cache.d.ts +89 -6
- package/cache/core/cache.js +33 -2
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +25 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/index.d.ts +3 -2
- package/cache/index.js +1 -0
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +3 -0
- package/cache/inmemory/entityStore.js +49 -6
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +9 -1
- package/cache/inmemory/inMemoryCache.d.ts +44 -5
- package/cache/inmemory/inMemoryCache.js +84 -5
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.d.ts +4 -1
- package/cache/inmemory/policies.js +35 -6
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +11 -2
- package/cache/inmemory/readFromStore.js +486 -49
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +30 -5
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +7 -7
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +44 -10
- package/core/ApolloClient.js +37 -38
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +16 -8
- package/core/ObservableQuery.js +225 -77
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +17 -22
- package/core/QueryInfo.js +174 -190
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +1 -3
- package/core/QueryManager.js +89 -60
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.js +3 -3
- package/core/dataStateErrorCache.d.ts +3 -0
- package/core/dataStateErrorCache.js +9 -0
- package/core/dataStateErrorCache.js.map +1 -0
- package/core/index.d.ts +4 -3
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/types.d.ts +10 -3
- package/core/types.js.map +1 -1
- package/incremental/GraphQLCodegenIncremental.d.ts +55 -0
- package/incremental/GraphQLCodegenIncremental.js +2 -0
- package/incremental/GraphQLCodegenIncremental.js.map +1 -0
- package/incremental/handlers/defer20220824.d.ts +2 -4
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +29 -6
- package/incremental/handlers/graphql17Alpha9.js +48 -17
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/handlers/notImplemented.js +1 -1
- package/incremental/index.d.ts +1 -0
- package/incremental/index.js.map +1 -1
- package/incremental/internal/types.d.ts +17 -0
- package/incremental/internal/types.js +2 -0
- package/incremental/internal/types.js.map +1 -0
- package/incremental/types.d.ts +55 -4
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +167 -112
- package/link/core/ApolloLink.js +3 -3
- package/link/http/checkFetcher.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +2 -2
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/ws/index.js +1 -1
- package/local-state/LocalState.d.ts +1 -1
- package/local-state/LocalState.js +11 -11
- package/local-state/LocalState.js.map +1 -1
- package/masking/internal/types.d.ts +1 -2
- package/masking/internal/types.js.map +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/utils.js +3 -3
- package/package.json +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +100 -47
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +0 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +40 -34
- package/react/hooks/useLazyQuery.js +2 -2
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +23 -15
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +10 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +74 -32
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +7 -4
- package/react/hooks/useSubscription.js +7 -3
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +1 -1
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +83 -34
- package/react/hooks/useSuspenseQuery.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/useBackgroundQuery.d.ts +100 -47
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useFragment.d.ts +0 -1
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +40 -34
- package/react/hooks-compiled/useLazyQuery.js +2 -2
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +23 -15
- package/react/hooks-compiled/useLoadableQuery.js +2 -2
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +10 -7
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +74 -32
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useSubscription.d.ts +7 -4
- package/react/hooks-compiled/useSubscription.js +107 -93
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseFragment.d.ts +1 -1
- package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +83 -34
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/types.d.ts +15 -4
- package/react/internal/types.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +20 -5
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/prerenderStatic.js +2 -2
- package/testing/core/mocking/mockLink.d.ts +1 -2
- package/testing/core/mocking/mockLink.js +25 -5
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/utilities/caching/sizes.d.ts +39 -1
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/index.d.ts +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/internal/StreamArrayState.d.ts +12 -0
- package/utilities/internal/StreamArrayState.js +23 -0
- package/utilities/internal/StreamArrayState.js.map +1 -0
- package/utilities/internal/addDeferFragmentLabels.d.ts +3 -0
- package/utilities/internal/addDeferFragmentLabels.js +30 -0
- package/utilities/internal/addDeferFragmentLabels.js.map +1 -0
- package/utilities/internal/capitalize.d.ts +7 -0
- package/utilities/internal/capitalize.js +9 -0
- package/utilities/internal/capitalize.js.map +1 -0
- package/utilities/internal/coerceScalarFieldsToParsed.d.ts +9 -0
- package/utilities/internal/coerceScalarFieldsToParsed.js +66 -0
- package/utilities/internal/coerceScalarFieldsToParsed.js.map +1 -0
- package/utilities/internal/constants.d.ts +19 -0
- package/utilities/internal/constants.js +19 -0
- package/utilities/internal/constants.js.map +1 -1
- package/utilities/internal/getDirectiveArgValue.d.ts +9 -0
- package/utilities/internal/getDirectiveArgValue.js +16 -0
- package/utilities/internal/getDirectiveArgValue.js.map +1 -0
- package/utilities/internal/getFragmentDefinition.js +3 -3
- package/utilities/internal/getFragmentFromSelection.js +2 -2
- package/utilities/internal/getFragmentFromSelection.js.map +1 -1
- package/utilities/internal/getFragmentQueryDocument.js +2 -2
- package/utilities/internal/getMainDefinition.js +1 -1
- package/utilities/internal/getMemoryInternals.d.ts +4 -0
- package/utilities/internal/getMemoryInternals.js +6 -0
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/getQueryDefinition.js +1 -1
- package/utilities/internal/getUnwrappedType.d.ts +8 -0
- package/utilities/internal/getUnwrappedType.js +17 -0
- package/utilities/internal/getUnwrappedType.js.map +1 -0
- package/utilities/internal/index.d.ts +16 -2
- package/utilities/internal/index.js +12 -1
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isDeferredFragment.d.ts +9 -0
- package/utilities/internal/isDeferredFragment.js +35 -0
- package/utilities/internal/isDeferredFragment.js.map +1 -0
- package/utilities/internal/isStreamField.d.ts +9 -0
- package/utilities/internal/isStreamField.js +34 -0
- package/utilities/internal/isStreamField.js.map +1 -0
- package/utilities/internal/isTypenameField.d.ts +3 -0
- package/utilities/internal/isTypenameField.js +4 -0
- package/utilities/internal/isTypenameField.js.map +1 -0
- package/utilities/internal/makeStreamInfoTrie.d.ts +8 -0
- package/utilities/internal/makeStreamInfoTrie.js +14 -0
- package/utilities/internal/makeStreamInfoTrie.js.map +1 -0
- package/utilities/internal/removeDirectivesFromDocument.js +1 -1
- package/utilities/internal/shouldInclude.js +4 -4
- package/utilities/internal/toDiffWithDataState.d.ts +8 -0
- package/utilities/internal/toDiffWithDataState.js +17 -0
- package/utilities/internal/toDiffWithDataState.js.map +1 -0
- package/utilities/internal/types/DeferInfo.d.ts +10 -0
- package/utilities/internal/types/DeferInfo.js +2 -0
- package/utilities/internal/types/DeferInfo.js.map +1 -0
- package/utilities/internal/types/Exact.d.ts +2 -0
- package/utilities/internal/types/Exact.js +2 -0
- package/utilities/internal/types/Exact.js.map +1 -0
- package/utilities/internal/types/IsLooselyEqual.d.ts +10 -0
- package/utilities/internal/types/IsLooselyEqual.js +2 -0
- package/utilities/internal/types/IsLooselyEqual.js.map +1 -0
- package/utilities/internal/types/IsNeverish.d.ts +4 -0
- package/utilities/internal/types/IsNeverish.js +2 -0
- package/utilities/internal/types/IsNeverish.js.map +1 -0
- package/utilities/internal/types/StreamInfoTrie.d.ts +2 -0
- package/utilities/internal/types/StreamInfoTrie.js.map +1 -1
- package/utilities/internal/valueToObjectRepresentation.js +1 -1
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/subscriptions/relay/index.js +1 -0
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/__cjs/utilities/internal/types/NoInfer.cjs.map +0 -1
- package/__cjs/utilities/internal/types/NoInfer.d.cts +0 -35
- package/utilities/internal/types/NoInfer.d.ts +0 -35
- package/utilities/internal/types/NoInfer.js +0 -2
- package/utilities/internal/types/NoInfer.js.map +0 -1
|
@@ -8,7 +8,7 @@ import type { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
|
|
|
8
8
|
import type { LocalState } from "@apollo/client/local-state";
|
|
9
9
|
import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
|
|
10
10
|
import { DocumentTransform } from "@apollo/client/utilities";
|
|
11
|
-
import type { LazyType, OptionWithFallback, SignatureStyle, VariablesOption, variablesUnknownSymbol } from "@apollo/client/utilities/internal";
|
|
11
|
+
import type { LazyType, OptionWithFallback, Prettify, SignatureStyle, VariablesOption, variablesUnknownSymbol } from "@apollo/client/utilities/internal";
|
|
12
12
|
import { getApolloClientMemoryInternals } from "@apollo/client/utilities/internal";
|
|
13
13
|
import type { DeclareDefaultOptions, DefaultOptions } from "./defaultOptions.cjs";
|
|
14
14
|
import type { ObservableQuery } from "./ObservableQuery.cjs";
|
|
@@ -232,7 +232,20 @@ export declare namespace ApolloClient {
|
|
|
232
232
|
export namespace mutate {
|
|
233
233
|
interface DefaultOptions extends ApolloClient.DefaultOptions.Mutate.Calculated {
|
|
234
234
|
}
|
|
235
|
-
type
|
|
235
|
+
type OptionsFor<TData, TVariables extends OperationVariables, TCache extends Cache.Implementation, TOptions extends {
|
|
236
|
+
variables?: unknown;
|
|
237
|
+
}> = MutateOptions<NoInfer<TData>, NoInfer<TVariables>, TCache> & {
|
|
238
|
+
variables?: Prettify<TVariables & {
|
|
239
|
+
[K in keyof TOptions["variables"]]: K extends keyof TVariables ? TVariables[K] : never;
|
|
240
|
+
}>;
|
|
241
|
+
} & (Exclude<keyof TOptions, keyof MutateOptions<any, any, any>> extends (infer InvalidOptionNames extends string) ? [
|
|
242
|
+
InvalidOptionNames
|
|
243
|
+
] extends [never] ? unknown : {
|
|
244
|
+
[K in InvalidOptionNames]: never;
|
|
245
|
+
} : never);
|
|
246
|
+
type ResultForOptions<TData, TErrorPolicy extends ErrorPolicy | undefined = undefined> = LazyType<MutateResult<MaybeMasked<TData>, OptionWithFallback<{
|
|
247
|
+
errorPolicy: TErrorPolicy;
|
|
248
|
+
}, DefaultOptions, "errorPolicy"> & ErrorPolicy>>;
|
|
236
249
|
namespace Signatures {
|
|
237
250
|
interface Classic {
|
|
238
251
|
/**
|
|
@@ -271,11 +284,21 @@ export declare namespace ApolloClient {
|
|
|
271
284
|
*
|
|
272
285
|
* It takes options as an object with the following keys and values:
|
|
273
286
|
*/
|
|
274
|
-
<TData, TVariables extends OperationVariables, TOptions extends ApolloClient.MutateOptions<NoInfer<TData>,
|
|
275
|
-
|
|
276
|
-
}
|
|
287
|
+
<TData, TVariables extends OperationVariables, TOptions extends Omit<ApolloClient.MutateOptions<NoInfer<TData>, any, Cache.Implementation>, "variables"> & {
|
|
288
|
+
variables?: unknown;
|
|
289
|
+
}, TErrorPolicy extends ErrorPolicy | undefined = undefined>(options: TOptions & ApolloClient.mutate.OptionsFor<TData, TVariables, Cache.Implementation, TOptions> & {
|
|
277
290
|
mutation: TypedDocumentNode<TData, TVariables>;
|
|
278
|
-
|
|
291
|
+
/**
|
|
292
|
+
* Specifies how the mutation handles a response that returns both GraphQL errors and partial results.
|
|
293
|
+
*
|
|
294
|
+
* For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
|
|
295
|
+
*
|
|
296
|
+
* The default value is `none`, meaning that the mutation result includes error details but _not_ partial results.
|
|
297
|
+
*
|
|
298
|
+
* @docGroup 1. Operation options
|
|
299
|
+
*/
|
|
300
|
+
errorPolicy?: TErrorPolicy;
|
|
301
|
+
}): Promise<ApolloClient.mutate.ResultForOptions<TData, TErrorPolicy>>;
|
|
279
302
|
}
|
|
280
303
|
type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
|
|
281
304
|
}
|
|
@@ -473,7 +496,18 @@ export declare namespace ApolloClient {
|
|
|
473
496
|
export namespace query {
|
|
474
497
|
interface DefaultOptions extends ApolloClient.DefaultOptions.Query.Calculated {
|
|
475
498
|
}
|
|
476
|
-
type
|
|
499
|
+
type OptionsFor<TData, TVariables extends OperationVariables, TOptions extends {
|
|
500
|
+
variables?: unknown;
|
|
501
|
+
}> = QueryOptions<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
502
|
+
variables?: Prettify<TVariables & {
|
|
503
|
+
[K in keyof TOptions["variables"]]: K extends keyof TVariables ? TVariables[K] : never;
|
|
504
|
+
}>;
|
|
505
|
+
} & (Exclude<keyof TOptions, keyof QueryOptions<any, any>> extends (infer InvalidOptionNames extends string) ? [
|
|
506
|
+
InvalidOptionNames
|
|
507
|
+
] extends [never] ? unknown : {
|
|
508
|
+
[K in InvalidOptionNames]: never;
|
|
509
|
+
} : never);
|
|
510
|
+
type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, unknown> | Omit<QueryOptions<any, any>, "variables">> = LazyType<QueryResult<MaybeMasked<TData>, OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> & ErrorPolicy>>;
|
|
477
511
|
namespace Signatures {
|
|
478
512
|
interface Classic {
|
|
479
513
|
/**
|
|
@@ -515,9 +549,9 @@ export declare namespace ApolloClient {
|
|
|
515
549
|
* describe how this query should be treated e.g. whether it should hit the
|
|
516
550
|
* server at all or just resolve from the cache, etc.
|
|
517
551
|
*/
|
|
518
|
-
<TData, TVariables extends OperationVariables, TOptions extends ApolloClient.QueryOptions<NoInfer<TData>,
|
|
519
|
-
|
|
520
|
-
}
|
|
552
|
+
<TData, TVariables extends OperationVariables, TOptions extends Omit<ApolloClient.QueryOptions<NoInfer<TData>, any>, "variables"> & {
|
|
553
|
+
variables?: unknown;
|
|
554
|
+
}>(options: TOptions & ApolloClient.query.OptionsFor<TData, TVariables, TOptions> & {
|
|
521
555
|
query: TypedDocumentNode<TData, TVariables>;
|
|
522
556
|
}): Promise<ApolloClient.query.ResultForOptions<TData, TVariables, TOptions>>;
|
|
523
557
|
}
|
|
@@ -12,6 +12,7 @@ const utilities_1 = require("@apollo/client/utilities");
|
|
|
12
12
|
const environment_1 = require("@apollo/client/utilities/environment");
|
|
13
13
|
const internal_1 = require("@apollo/client/utilities/internal");
|
|
14
14
|
const invariant_1 = require("@apollo/client/utilities/invariant");
|
|
15
|
+
const dataStateErrorCache_js_1 = require("./dataStateErrorCache.cjs");
|
|
15
16
|
const networkStatus_js_1 = require("./networkStatus.cjs");
|
|
16
17
|
const { assign, hasOwnProperty } = Object;
|
|
17
18
|
const uninitialized = {
|
|
@@ -28,16 +29,29 @@ const empty = {
|
|
|
28
29
|
dataState: "empty",
|
|
29
30
|
partial: true,
|
|
30
31
|
};
|
|
32
|
+
const destructiveMethodCounts = new WeakMap();
|
|
33
|
+
function wrapDestructiveCacheMethod(cache, methodName) {
|
|
34
|
+
const original = cache[methodName];
|
|
35
|
+
if (typeof original === "function") {
|
|
36
|
+
// @ts-expect-error this is just too generic to be typed correctly
|
|
37
|
+
cache[methodName] = function () {
|
|
38
|
+
destructiveMethodCounts.set(cache,
|
|
39
|
+
// The %1e15 allows the count to wrap around to 0 safely every
|
|
40
|
+
// quadrillion evictions, so there's no risk of overflow. To be
|
|
41
|
+
// clear, this is more of a pedantic principle than something
|
|
42
|
+
// that matters in any conceivable practical scenario.
|
|
43
|
+
(destructiveMethodCounts.get(cache) + 1) % 1e15);
|
|
44
|
+
// @ts-expect-error this is just too generic to be typed correctly
|
|
45
|
+
return original.apply(this, arguments);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
31
49
|
class ObservableQuery {
|
|
32
50
|
options;
|
|
33
51
|
queryName;
|
|
34
52
|
variablesUnknown = false;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
39
|
-
*/
|
|
40
|
-
_lastWrite;
|
|
53
|
+
didWarnOnFeud = false;
|
|
54
|
+
lastMissing;
|
|
41
55
|
// The `query` computed property will always reflect the document transformed
|
|
42
56
|
// by the last run query. `this.options.query` will always reflect the raw
|
|
43
57
|
// untransformed query to ensure document transforms with runtime conditionals
|
|
@@ -74,6 +88,18 @@ class ObservableQuery {
|
|
|
74
88
|
}
|
|
75
89
|
constructor({ queryManager, options, transformedQuery = queryManager.transform(options.query), }) {
|
|
76
90
|
this.queryManager = queryManager;
|
|
91
|
+
// Track how often destructive cache methods are called, since we want
|
|
92
|
+
// eviction to override the feud-stopping logic in `shouldAutoRefetch`,
|
|
93
|
+
// by causing it to return true. Wrapping these cache methods is a bit of a
|
|
94
|
+
// hack, but it saves us from having to make eviction counting an official
|
|
95
|
+
// part of the ApolloCache API.
|
|
96
|
+
const { cache } = queryManager;
|
|
97
|
+
if (!destructiveMethodCounts.has(cache)) {
|
|
98
|
+
destructiveMethodCounts.set(cache, 0);
|
|
99
|
+
wrapDestructiveCacheMethod(cache, "evict");
|
|
100
|
+
wrapDestructiveCacheMethod(cache, "modify");
|
|
101
|
+
wrapDestructiveCacheMethod(cache, "reset");
|
|
102
|
+
}
|
|
77
103
|
// active state
|
|
78
104
|
this.waitForNetworkResult = options.fetchPolicy === "network-only";
|
|
79
105
|
this.isTornDown = false;
|
|
@@ -84,7 +110,7 @@ class ObservableQuery {
|
|
|
84
110
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
85
111
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
86
112
|
if (options[internal_1.variablesUnknownSymbol]) {
|
|
87
|
-
(0, invariant_1.invariant)(fetchPolicy === "standby",
|
|
113
|
+
(0, invariant_1.invariant)(fetchPolicy === "standby", 83);
|
|
88
114
|
this.variablesUnknown = true;
|
|
89
115
|
}
|
|
90
116
|
this.lastQuery = transformedQuery;
|
|
@@ -213,12 +239,13 @@ class ObservableQuery {
|
|
|
213
239
|
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
214
240
|
*/
|
|
215
241
|
getCacheDiff({ optimistic = true } = {}) {
|
|
216
|
-
return this.cache.diff({
|
|
242
|
+
return (0, internal_1.toDiffWithDataState)(this.cache.diff({
|
|
217
243
|
query: this.query,
|
|
218
244
|
variables: this.variables,
|
|
219
245
|
returnPartialData: true,
|
|
220
246
|
optimistic,
|
|
221
|
-
|
|
247
|
+
[internal_1.handleIncrementalSymbol]: undefined,
|
|
248
|
+
}));
|
|
222
249
|
}
|
|
223
250
|
getInitialResult(initialFetchPolicy) {
|
|
224
251
|
let fetchPolicy = initialFetchPolicy || this.options.fetchPolicy;
|
|
@@ -228,16 +255,18 @@ class ObservableQuery {
|
|
|
228
255
|
}
|
|
229
256
|
const cacheResult = () => {
|
|
230
257
|
const diff = this.getCacheDiff();
|
|
258
|
+
let { dataState } = diff;
|
|
231
259
|
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
232
260
|
// null when returnPartialData is false
|
|
233
261
|
const data = this.options.returnPartialData || diff.complete ?
|
|
234
262
|
diff.result ?? undefined
|
|
235
263
|
: undefined;
|
|
264
|
+
if (data === undefined) {
|
|
265
|
+
dataState = "empty";
|
|
266
|
+
}
|
|
236
267
|
return this.maskResult({
|
|
237
268
|
data,
|
|
238
|
-
dataState
|
|
239
|
-
: data === undefined ? "empty"
|
|
240
|
-
: "partial",
|
|
269
|
+
dataState,
|
|
241
270
|
loading: !diff.complete,
|
|
242
271
|
networkStatus: diff.complete ? networkStatus_js_1.NetworkStatus.ready : networkStatus_js_1.NetworkStatus.loading,
|
|
243
272
|
partial: !diff.complete,
|
|
@@ -390,7 +419,7 @@ class ObservableQuery {
|
|
|
390
419
|
const queryDef = (0, internal_1.getQueryDefinition)(this.query);
|
|
391
420
|
const vars = queryDef.variableDefinitions;
|
|
392
421
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
393
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
422
|
+
__DEV__ && invariant_1.invariant.warn(84, variables, queryDef.name?.value || queryDef);
|
|
394
423
|
}
|
|
395
424
|
}
|
|
396
425
|
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
@@ -398,7 +427,6 @@ class ObservableQuery {
|
|
|
398
427
|
reobserveOptions.variables = this.options.variables =
|
|
399
428
|
this.getVariablesWithDefaults({ ...this.variables, ...variables });
|
|
400
429
|
}
|
|
401
|
-
this._lastWrite = undefined;
|
|
402
430
|
return this._reobserve(reobserveOptions, {
|
|
403
431
|
newNetworkStatus: networkStatus_js_1.NetworkStatus.refetch,
|
|
404
432
|
});
|
|
@@ -406,7 +434,7 @@ class ObservableQuery {
|
|
|
406
434
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
407
435
|
(0, invariant_1.invariant)(
|
|
408
436
|
this.options.fetchPolicy !== "cache-only",
|
|
409
|
-
|
|
437
|
+
85,
|
|
410
438
|
(0, internal_1.getOperationName)(this.query, "(anonymous)")
|
|
411
439
|
);
|
|
412
440
|
const combinedOptions = {
|
|
@@ -440,7 +468,7 @@ class ObservableQuery {
|
|
|
440
468
|
let wasUpdated = false;
|
|
441
469
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
442
470
|
if (!isCached) {
|
|
443
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
471
|
+
(0, invariant_1.invariant)(updateQuery, 86);
|
|
444
472
|
}
|
|
445
473
|
const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
|
|
446
474
|
pushNotification({
|
|
@@ -517,9 +545,7 @@ class ObservableQuery {
|
|
|
517
545
|
// will be overwritten anyways, just here for types sake
|
|
518
546
|
loading: false,
|
|
519
547
|
data: diff.result,
|
|
520
|
-
dataState:
|
|
521
|
-
"streaming"
|
|
522
|
-
: "complete",
|
|
548
|
+
dataState: diff.complete ? "complete" : "streaming",
|
|
523
549
|
},
|
|
524
550
|
});
|
|
525
551
|
}
|
|
@@ -616,7 +642,7 @@ class ObservableQuery {
|
|
|
616
642
|
onError(error);
|
|
617
643
|
}
|
|
618
644
|
else {
|
|
619
|
-
invariant_1.invariant.error(
|
|
645
|
+
invariant_1.invariant.error(87, error);
|
|
620
646
|
}
|
|
621
647
|
return;
|
|
622
648
|
}
|
|
@@ -867,7 +893,7 @@ class ObservableQuery {
|
|
|
867
893
|
if (!this.didWarnCacheOnlyPolling &&
|
|
868
894
|
pollInterval &&
|
|
869
895
|
fetchPolicy === "cache-only") {
|
|
870
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
896
|
+
__DEV__ && invariant_1.invariant.warn(88, (0, internal_1.getOperationName)(this.query, "(anonymous)"));
|
|
871
897
|
this.didWarnCacheOnlyPolling = true;
|
|
872
898
|
}
|
|
873
899
|
}
|
|
@@ -933,7 +959,10 @@ class ObservableQuery {
|
|
|
933
959
|
}
|
|
934
960
|
_reobserve(newOptions, internalOptions) {
|
|
935
961
|
this.isTornDown = false;
|
|
936
|
-
let { newNetworkStatus } = internalOptions || {};
|
|
962
|
+
let { newNetworkStatus, keepLastMissing } = internalOptions || {};
|
|
963
|
+
if (!keepLastMissing) {
|
|
964
|
+
this.lastMissing = undefined;
|
|
965
|
+
}
|
|
937
966
|
this.queryManager.obsQueries.add(this);
|
|
938
967
|
const useDisposableObservable =
|
|
939
968
|
// Refetching uses a disposable Observable to allow refetches using different
|
|
@@ -1074,7 +1103,7 @@ class ObservableQuery {
|
|
|
1074
1103
|
this.queryManager.obsQueries.delete(this);
|
|
1075
1104
|
this.isTornDown = true;
|
|
1076
1105
|
this.abortActiveOperations();
|
|
1077
|
-
this.
|
|
1106
|
+
this.lastMissing = undefined;
|
|
1078
1107
|
}
|
|
1079
1108
|
transformDocument(document) {
|
|
1080
1109
|
return this.queryManager.transform(document);
|
|
@@ -1132,53 +1161,126 @@ class ObservableQuery {
|
|
|
1132
1161
|
return;
|
|
1133
1162
|
}
|
|
1134
1163
|
}
|
|
1135
|
-
const { dirty } = this;
|
|
1164
|
+
const { dirty, lastMissing } = this;
|
|
1165
|
+
const { fetchPolicy } = this.options;
|
|
1136
1166
|
this.resetNotifications();
|
|
1137
|
-
if (dirty
|
|
1138
|
-
(
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1167
|
+
if (!dirty ||
|
|
1168
|
+
(fetchPolicy !== "cache-only" &&
|
|
1169
|
+
fetchPolicy !== "cache-and-network" &&
|
|
1170
|
+
this.activeOperations.size)) {
|
|
1171
|
+
return;
|
|
1172
|
+
}
|
|
1173
|
+
const diff = this.getCacheDiff();
|
|
1174
|
+
const current = this.getCurrentResult();
|
|
1175
|
+
// `fromOptimisticTransaction` is not available through the `cache.diff`
|
|
1176
|
+
// code path, so we need to check whether the cache result is an optimistic
|
|
1177
|
+
// result this way.
|
|
1178
|
+
const isOptimistic = !(0, equality_1.equal)(diff.result, this.getCacheDiff({ optimistic: false }).result);
|
|
1179
|
+
if (
|
|
1180
|
+
// When this diff came from an optimistic transaction, deliver the
|
|
1181
|
+
// current cache data to the ObservableQuery, but don't perform a
|
|
1182
|
+
// reobservation, since oq.reobserveCacheFirst might make a network
|
|
1183
|
+
// request, and we never want to trigger network requests in the
|
|
1184
|
+
// middle of optimistic updates.
|
|
1185
|
+
isOptimistic ||
|
|
1186
|
+
// If we get a cache update in the middle of streaming (possible with
|
|
1187
|
+
// cache-and-network fetch policy), just deliver the cache value without
|
|
1188
|
+
// going through the full reobserve which would otherwise trigger another
|
|
1189
|
+
// request (deduplication should kick in, but doing so replays any
|
|
1190
|
+
// previous emits from the link chain, which get rewritten into the cache
|
|
1191
|
+
// and might clobber this cache update)
|
|
1192
|
+
(!diff.complete && current.networkStatus === networkStatus_js_1.NetworkStatus.streaming)) {
|
|
1193
|
+
this.deliverCacheDiff(diff);
|
|
1194
|
+
return;
|
|
1195
|
+
}
|
|
1196
|
+
if (diff.complete) {
|
|
1197
|
+
this.lastMissing = undefined;
|
|
1198
|
+
}
|
|
1199
|
+
else if (!lastMissing ||
|
|
1200
|
+
// If a destructive cache method has been called since the last recorded
|
|
1201
|
+
// incomplete result, there's a chance fetching this data again will
|
|
1202
|
+
// restore what was evicted, even though the cache result looks the same
|
|
1203
|
+
// as before.
|
|
1204
|
+
lastMissing.dmCount !== destructiveMethodCounts.get(this.cache) ||
|
|
1205
|
+
!(0, equality_1.equal)(lastMissing.variables, this.variables) ||
|
|
1206
|
+
!(0, equality_1.equal)(lastMissing.missing, diff.missing?.missing)) {
|
|
1207
|
+
this.didWarnOnFeud = false;
|
|
1208
|
+
this.lastMissing = {
|
|
1209
|
+
variables: this.variables,
|
|
1210
|
+
missing: diff.missing?.missing,
|
|
1211
|
+
dmCount: destructiveMethodCounts.get(this.cache),
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
else if (
|
|
1215
|
+
// reobserveCacheFirst with cache-only fetch policy only calls
|
|
1216
|
+
// reobserve which never fetches from the network so we are ok
|
|
1217
|
+
// allowing cache-only queries to fallthrough to reobserveCacheFirst.
|
|
1218
|
+
// This also prevents the feud warning which would be confusing for a
|
|
1219
|
+
// cache-only query anyways.
|
|
1220
|
+
fetchPolicy !== "cache-only") {
|
|
1221
|
+
// If we've fallen through to this case, a cache emit has returned the
|
|
1222
|
+
// same missing fields which means at least one value on the fields we've
|
|
1223
|
+
// already delivered have changed. We are ok delivering the updated
|
|
1224
|
+
// partial result in this case to keep the result as fresh as possible. We
|
|
1225
|
+
// NEVER want to downgrade this query from a complete query to a partial
|
|
1226
|
+
// query though, so we also make sure we only deliver if the previous
|
|
1227
|
+
// result was also partial.
|
|
1228
|
+
if (current.dataState === "partial") {
|
|
1229
|
+
this.deliverCacheDiff(diff);
|
|
1156
1230
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
});
|
|
1231
|
+
// If the (partial) result is the same as the last partial result
|
|
1232
|
+
// we recorded from a previous broadcast (and the variables match
|
|
1233
|
+
// too), avoid calling reobserveCacheFirst to refetch this query
|
|
1234
|
+
// again. If we allow refetching anytime this result becomes partial,
|
|
1235
|
+
// we risk feuds between queries competing to update the same data in
|
|
1236
|
+
// incompatible ways, which can lead to an endless cycle of cache
|
|
1237
|
+
// broadcasts and useless network requests. As with any
|
|
1238
|
+
// feud, eventually one side must step back from the brink,
|
|
1239
|
+
// letting the other side(s) have the last word(s). There may
|
|
1240
|
+
// be other points where we could break this cycle, such as
|
|
1241
|
+
// silencing the broadcast for cache.writeQuery (not a good
|
|
1242
|
+
// idea, since it just delays the feud a bit) or somehow
|
|
1243
|
+
// avoiding the network request that just happened (also bad,
|
|
1244
|
+
// because the server could return useful new data). All
|
|
1245
|
+
// options considered, returning early and stopping the
|
|
1246
|
+
// reobserveCacheFirst cycle seems to be the least damaging place to
|
|
1247
|
+
// break the cycle because it allows read functions/custom scalars to
|
|
1248
|
+
// be applied to the feuding query while avoiding the endless cycle of
|
|
1249
|
+
// requests.
|
|
1250
|
+
if (environment_1.__DEV__ && !this.didWarnOnFeud) {
|
|
1251
|
+
this.didWarnOnFeud = true;
|
|
1252
|
+
warnOnFeud(this.query, diff);
|
|
1180
1253
|
}
|
|
1254
|
+
return;
|
|
1181
1255
|
}
|
|
1256
|
+
//If this diff did not come from an optimistic transaction
|
|
1257
|
+
// make the ObservableQuery "reobserve" the latest data
|
|
1258
|
+
// using a temporary fetch policy of "cache-first", so complete cache
|
|
1259
|
+
// results have a chance to be delivered without triggering additional
|
|
1260
|
+
// network requests, even when options.fetchPolicy is "network-only"
|
|
1261
|
+
// or "cache-and-network". All other fetch policies are preserved by
|
|
1262
|
+
// this method, and are handled by calling oq.reobserve(). If this
|
|
1263
|
+
// reobservation is spurious, distinctUntilChanged still has a
|
|
1264
|
+
// chance to catch it before delivery to ObservableQuery subscribers.
|
|
1265
|
+
this.reobserveCacheFirst();
|
|
1266
|
+
}
|
|
1267
|
+
deliverCacheDiff(diff) {
|
|
1268
|
+
const current = this.getCurrentResult();
|
|
1269
|
+
this.input.next({
|
|
1270
|
+
kind: "N",
|
|
1271
|
+
value: {
|
|
1272
|
+
data: diff.result,
|
|
1273
|
+
dataState: diff.dataState,
|
|
1274
|
+
networkStatus: current.networkStatus,
|
|
1275
|
+
loading: current.loading,
|
|
1276
|
+
error: undefined,
|
|
1277
|
+
partial: !diff.complete,
|
|
1278
|
+
},
|
|
1279
|
+
source: "cache",
|
|
1280
|
+
query: this.query,
|
|
1281
|
+
variables: this.variables,
|
|
1282
|
+
meta: {},
|
|
1283
|
+
});
|
|
1182
1284
|
}
|
|
1183
1285
|
activeOperations = new Set();
|
|
1184
1286
|
pushOperation(networkStatus) {
|
|
@@ -1241,6 +1343,7 @@ class ObservableQuery {
|
|
|
1241
1343
|
// exception for cache-only queries - we reset them into a "ready" state
|
|
1242
1344
|
// as we won't trigger a refetch for them
|
|
1243
1345
|
const resetToEmpty = this.options.fetchPolicy === "cache-only";
|
|
1346
|
+
this.lastMissing = undefined;
|
|
1244
1347
|
this.setResult(resetToEmpty ? empty : uninitialized, {
|
|
1245
1348
|
shouldEmit: resetToEmpty ? 1 /* EmitBehavior.force */ : 2 /* EmitBehavior.never */,
|
|
1246
1349
|
});
|
|
@@ -1262,19 +1365,55 @@ class ObservableQuery {
|
|
|
1262
1365
|
});
|
|
1263
1366
|
}
|
|
1264
1367
|
operator = (0, internal_1.filterMap)((notification) => {
|
|
1265
|
-
const { query,
|
|
1368
|
+
const { query, meta } = notification;
|
|
1266
1369
|
if (notification.source === "setResult") {
|
|
1267
|
-
return {
|
|
1370
|
+
return {
|
|
1371
|
+
query,
|
|
1372
|
+
variables: this.variables,
|
|
1373
|
+
result: notification.value,
|
|
1374
|
+
meta,
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
if (notification.kind === "C") {
|
|
1378
|
+
return;
|
|
1268
1379
|
}
|
|
1269
|
-
|
|
1380
|
+
const resolvedVariables = "resolvedVariables" in notification ?
|
|
1381
|
+
notification.resolvedVariables
|
|
1382
|
+
: undefined;
|
|
1383
|
+
// Usually we prefer to drop notifications that don't match this query
|
|
1384
|
+
// but this breaks when used with `@export` queries that resolve variables
|
|
1385
|
+
// after the request is initiated. `notification.resolvedVariables` gives us
|
|
1386
|
+
// the variables the query actually resolved with during evaluation in
|
|
1387
|
+
// QueryManager (which is the variables value after `@export` variables have
|
|
1388
|
+
// been applied), but we need to update this query with those resolved
|
|
1389
|
+
// variables maybe in the middle of a request (updating is handled below).
|
|
1390
|
+
// When we update this.variables to the resolved variables, this causes
|
|
1391
|
+
// isEqualQuery(notification, this) to fail for future notifications since
|
|
1392
|
+
// the notification.variables holds the stale variables value. In this case,
|
|
1393
|
+
// we want to allow the notification through only if the current variables
|
|
1394
|
+
// value matches the resolved variables.
|
|
1395
|
+
//
|
|
1396
|
+
// Note: the check for matching resolved variables typically kicks in for
|
|
1397
|
+
// multi-emission fetches (such as defer, or cache-and-network, etc).
|
|
1398
|
+
if (notification.query !== this.query) {
|
|
1270
1399
|
return;
|
|
1271
1400
|
}
|
|
1401
|
+
if (!(0, equality_1.equal)(resolvedVariables, this.variables)) {
|
|
1402
|
+
if (!(0, equality_1.equal)(notification.variables, this.variables)) {
|
|
1403
|
+
return;
|
|
1404
|
+
}
|
|
1405
|
+
if (resolvedVariables) {
|
|
1406
|
+
this.options.variables = resolvedVariables;
|
|
1407
|
+
this.resubscribeCache();
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
const variables = this.variables;
|
|
1272
1411
|
let result;
|
|
1273
1412
|
const previous = this.subject.getValue();
|
|
1274
1413
|
if (notification.source === "cache") {
|
|
1275
1414
|
result = notification.value;
|
|
1276
1415
|
if (result.networkStatus === networkStatus_js_1.NetworkStatus.ready &&
|
|
1277
|
-
result.partial &&
|
|
1416
|
+
result.dataState === "partial" &&
|
|
1278
1417
|
(!this.options.returnPartialData ||
|
|
1279
1418
|
previous.result.networkStatus === networkStatus_js_1.NetworkStatus.error) &&
|
|
1280
1419
|
this.options.fetchPolicy !== "cache-only") {
|
|
@@ -1289,7 +1428,9 @@ class ObservableQuery {
|
|
|
1289
1428
|
result =
|
|
1290
1429
|
notification.kind === "E" ?
|
|
1291
1430
|
{
|
|
1292
|
-
...(isEqualQuery(previous, notification)
|
|
1431
|
+
...((isEqualQuery(previous, notification) ||
|
|
1432
|
+
(resolvedVariables &&
|
|
1433
|
+
(0, equality_1.equal)(resolvedVariables, previous.variables))) ?
|
|
1293
1434
|
previous.result
|
|
1294
1435
|
: { data: undefined, dataState: "empty", partial: true }),
|
|
1295
1436
|
error: notification.error,
|
|
@@ -1298,7 +1439,8 @@ class ObservableQuery {
|
|
|
1298
1439
|
}
|
|
1299
1440
|
: notification.value;
|
|
1300
1441
|
if (notification.kind === "E" && result.dataState === "streaming") {
|
|
1301
|
-
result.dataState =
|
|
1442
|
+
result.dataState =
|
|
1443
|
+
dataStateErrorCache_js_1.dataStateErrorCache.get(notification.error) ?? "complete";
|
|
1302
1444
|
}
|
|
1303
1445
|
if (result.error) {
|
|
1304
1446
|
meta.shouldEmit = 1 /* EmitBehavior.force */;
|
|
@@ -1346,7 +1488,10 @@ class ObservableQuery {
|
|
|
1346
1488
|
reobserveCacheFirst() {
|
|
1347
1489
|
const { fetchPolicy, nextFetchPolicy } = this.options;
|
|
1348
1490
|
if (fetchPolicy === "cache-and-network" || fetchPolicy === "network-only") {
|
|
1349
|
-
this.
|
|
1491
|
+
// Preserve this.lastMissing so a cache update that triggers this
|
|
1492
|
+
// reobserve doesn't reset feud detection. All user-initiated calls to
|
|
1493
|
+
// reobserve (refetch/poll/reobserve, etc) should clear it.
|
|
1494
|
+
this._reobserve({
|
|
1350
1495
|
fetchPolicy: "cache-first",
|
|
1351
1496
|
// Use a temporary nextFetchPolicy function that replaces itself with the
|
|
1352
1497
|
// previous nextFetchPolicy value and returns the original fetchPolicy.
|
|
@@ -1362,10 +1507,10 @@ class ObservableQuery {
|
|
|
1362
1507
|
// Otherwise go back to the original this.options.fetchPolicy.
|
|
1363
1508
|
return fetchPolicy;
|
|
1364
1509
|
},
|
|
1365
|
-
});
|
|
1510
|
+
}, { keepLastMissing: true });
|
|
1366
1511
|
}
|
|
1367
1512
|
else {
|
|
1368
|
-
this.
|
|
1513
|
+
this._reobserve(undefined, { keepLastMissing: true });
|
|
1369
1514
|
}
|
|
1370
1515
|
}
|
|
1371
1516
|
getVariablesWithDefaults(variables) {
|
|
@@ -1375,7 +1520,7 @@ class ObservableQuery {
|
|
|
1375
1520
|
exports.ObservableQuery = ObservableQuery;
|
|
1376
1521
|
function logMissingFieldErrors(missing) {
|
|
1377
1522
|
if (environment_1.__DEV__ && missing) {
|
|
1378
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1523
|
+
__DEV__ && invariant_1.invariant.debug(89, missing);
|
|
1379
1524
|
}
|
|
1380
1525
|
}
|
|
1381
1526
|
function isEqualQuery(a, b) {
|
|
@@ -1418,4 +1563,11 @@ function getTrackingOperatorPromise(defaultValue) {
|
|
|
1418
1563
|
});
|
|
1419
1564
|
return { promise, operator };
|
|
1420
1565
|
}
|
|
1566
|
+
function warnOnFeud(query, diff) {
|
|
1567
|
+
__DEV__ && invariant_1.invariant.warn(
|
|
1568
|
+
90,
|
|
1569
|
+
(0, internal_1.getOperationName)(query, "(anonymous)"),
|
|
1570
|
+
diff.missing?.missing
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1421
1573
|
//# sourceMappingURL=ObservableQuery.cjs.map
|