@apollo/client 4.0.0-alpha.7 → 4.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/afraid-moons-arrive.md +5 -0
- package/.changeset/beige-mirrors-talk.md +15 -0
- package/.changeset/early-eggs-develop.md +22 -0
- package/.changeset/forty-tomatoes-punch.md +5 -0
- package/.changeset/fuzzy-tips-sit.md +5 -0
- package/.changeset/giant-apes-thank.md +5 -0
- package/.changeset/khaki-keys-deliver.md +5 -0
- package/.changeset/large-plants-know.md +5 -0
- package/.changeset/mean-lizards-think.md +5 -0
- package/.changeset/ninety-bags-bake.md +17 -0
- package/.changeset/perfect-vans-give.md +7 -0
- package/.changeset/pre.json +16 -0
- package/.changeset/shaggy-pugs-add.md +52 -0
- package/.changeset/short-months-complain.md +5 -0
- package/.changeset/swift-rivers-share.md +13 -0
- package/.changeset/thin-peas-hear.md +16 -0
- package/.changeset/wicked-forks-double.md +33 -0
- package/CHANGELOG.md +195 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +1 -1
- package/__cjs/cache/core/types/Cache.cjs.map +1 -1
- package/__cjs/cache/core/types/Cache.d.cts +1 -1
- package/__cjs/cache/core/types/DataProxy.d.cts +1 -1
- package/__cjs/cache/core/types/common.cjs +1 -0
- package/__cjs/cache/core/types/common.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +7 -4
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +1 -0
- package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +1 -1
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/reactiveVars.cjs.map +1 -1
- package/__cjs/cache/inmemory/reactiveVars.d.cts +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +1 -1
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs +2 -3
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs +2 -3
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs +2 -3
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areServerErrorsEqual.cjs +21 -0
- package/__cjs/config/jest/areServerErrorsEqual.cjs.map +1 -0
- package/__cjs/config/jest/areServerErrorsEqual.d.cts +3 -0
- package/__cjs/config/jest/resolver.cjs +11 -0
- package/__cjs/config/jest/resolver.cjs.map +1 -1
- package/__cjs/config/jest/setup.cjs +12 -1
- package/__cjs/config/jest/setup.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +7 -7
- package/__cjs/core/LocalState.cjs +2 -2
- package/__cjs/core/ObservableQuery.cjs +196 -66
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +20 -2
- package/__cjs/core/QueryInfo.cjs +4 -71
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +0 -8
- package/__cjs/core/QueryManager.cjs +29 -50
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +3 -3
- package/__cjs/core/index.cjs +3 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +1 -0
- package/__cjs/core/watchQueryOptions.d.cts +2 -2
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +1 -1
- package/__cjs/errors/index.cjs +21 -2
- package/__cjs/errors/index.cjs.map +1 -1
- package/__cjs/errors/index.d.cts +2 -0
- package/__cjs/invariantErrorCodes.cjs +82 -70
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +1 -1
- package/__cjs/link/core/ApolloLink.cjs +2 -20
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +1 -3
- package/__cjs/link/core/types.d.cts +1 -1
- package/__cjs/link/error/index.cjs +13 -28
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +4 -15
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/masking/maskFragment.d.cts +1 -1
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/maskOperation.cjs.map +1 -1
- package/__cjs/masking/maskOperation.d.cts +1 -1
- package/__cjs/masking/utils.cjs +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs.map +1 -1
- package/__cjs/react/context/ApolloConsumer.d.cts +1 -1
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs.map +1 -1
- package/__cjs/react/context/ApolloContext.d.cts +1 -1
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs.map +1 -1
- package/__cjs/react/context/ApolloProvider.d.cts +1 -1
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +2 -2
- 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.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +2 -2
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +21 -24
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +3 -3
- package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +2 -2
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +2 -2
- package/__cjs/react/hooks/useQuery.cjs +4 -4
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +3 -4
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +2 -2
- package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
- package/__cjs/react/hooks/useReactiveVar.d.cts +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs +4 -4
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +3 -3
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +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/cache/QueryReference.d.cts +1 -1
- 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/getSuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.d.cts +2 -2
- package/__cjs/react/internal/types.d.cts +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -0
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
- package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
- package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -1
- package/__cjs/react/ssr/prerenderStatic.d.cts +1 -1
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
- package/__cjs/react/types/deprecated.d.cts +1 -1
- package/__cjs/react/types/types.documentation.d.cts +2 -2
- package/__cjs/testing/core/index.cjs +2 -1
- package/__cjs/testing/core/index.cjs.map +1 -1
- package/__cjs/testing/core/index.d.cts +2 -2
- package/__cjs/testing/core/mocking/mockClient.cjs +3 -4
- package/__cjs/testing/core/mocking/mockClient.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockClient.d.cts +1 -1
- package/__cjs/testing/core/mocking/mockLink.cjs +118 -112
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +26 -7
- package/__cjs/testing/experimental/createSchemaFetch.cjs +2 -2
- package/__cjs/testing/experimental/createSchemaFetch.cjs.map +1 -1
- package/__cjs/testing/experimental/createTestSchema.cjs.map +1 -1
- package/__cjs/testing/experimental/createTestSchema.d.cts +1 -1
- package/__cjs/testing/index.cjs +2 -1
- package/__cjs/testing/index.cjs.map +1 -1
- package/__cjs/testing/index.d.cts +1 -1
- package/__cjs/testing/internal/incremental.cjs.map +1 -1
- package/__cjs/testing/internal/incremental.d.cts +1 -1
- package/__cjs/testing/internal/renderHelpers.cjs.map +1 -1
- package/__cjs/testing/internal/renderHelpers.d.cts +1 -1
- package/__cjs/testing/internal/scenarios/index.cjs +9 -7
- package/__cjs/testing/internal/scenarios/index.cjs.map +1 -1
- package/__cjs/testing/internal/scenarios/index.d.cts +6 -8
- package/__cjs/testing/matchers/arrayWithLength.cjs +15 -0
- package/__cjs/testing/matchers/arrayWithLength.cjs.map +1 -0
- package/__cjs/testing/matchers/arrayWithLength.d.cts +3 -0
- package/__cjs/testing/matchers/index.cjs +2 -0
- package/__cjs/testing/matchers/index.cjs.map +1 -1
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs +2 -2
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs.map +1 -1
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.d.cts +1 -1
- package/__cjs/testing/matchers/toMatchDocument.cjs.map +1 -1
- package/__cjs/testing/matchers/toMatchDocument.d.cts +1 -1
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +2 -2
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.cjs +9 -5
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +5 -3
- package/__cjs/utilities/common/mergeOptions.cjs.map +1 -1
- package/__cjs/utilities/common/mergeOptions.d.cts +1 -1
- package/__cjs/utilities/graphql/operations.cjs.map +1 -1
- package/__cjs/utilities/graphql/operations.d.cts +1 -1
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -1
- package/__cjs/utilities/internal/toQueryResult.d.cts +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs +2 -2
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/utilities/subscriptions/relay/index.d.cts +1 -1
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/__cjs/version.d.cts +1 -1
- package/cache/core/cache.d.ts +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +1 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +1 -1
- package/cache/core/types/common.js +1 -0
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -0
- package/cache/inmemory/entityStore.js +7 -4
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +1 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +1 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.js +4 -4
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/areCombinedGraphQLErrorsEqual.js +2 -3
- package/config/jest/areCombinedGraphQLErrorsEqual.js.map +1 -1
- package/config/jest/areCombinedProtocolErrorsEqual.js +2 -3
- package/config/jest/areCombinedProtocolErrorsEqual.js.map +1 -1
- package/config/jest/areMissingFieldErrorsEqual.js +2 -3
- package/config/jest/areMissingFieldErrorsEqual.js.map +1 -1
- package/config/jest/areServerErrorsEqual.d.ts +3 -0
- package/config/jest/areServerErrorsEqual.js +17 -0
- package/config/jest/areServerErrorsEqual.js.map +1 -0
- package/config/jest/resolver.js +12 -1
- package/config/jest/resolver.js.map +1 -1
- package/config/jest/setup.js +13 -2
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.js +7 -7
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.d.ts +20 -2
- package/core/ObservableQuery.js +195 -64
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +0 -8
- package/core/QueryInfo.js +4 -71
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +3 -3
- package/core/QueryManager.js +30 -51
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +1 -0
- package/core/index.js +2 -1
- package/core/index.js.map +1 -1
- package/core/watchQueryOptions.d.ts +2 -2
- package/errors/CombinedGraphQLErrors.d.ts +1 -1
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/index.d.ts +2 -0
- package/errors/index.js +18 -0
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +82 -70
- package/link/context/index.d.ts +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +1 -3
- package/link/core/ApolloLink.js +2 -20
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/types.d.ts +1 -1
- package/link/error/index.d.ts +4 -15
- package/link/error/index.js +14 -29
- package/link/error/index.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +3 -3
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.d.ts +1 -1
- package/masking/maskFragment.js +2 -2
- package/masking/maskFragment.js.map +1 -1
- package/masking/maskOperation.d.ts +1 -1
- package/masking/maskOperation.js +1 -1
- package/masking/maskOperation.js.map +1 -1
- package/masking/utils.js +1 -1
- package/package.json +10 -10
- package/react/context/ApolloConsumer.d.ts +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/hooks/internal/wrapHook.d.ts +2 -2
- package/react/hooks/internal/wrapHook.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.d.ts +2 -2
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +3 -3
- package/react/hooks/useLazyQuery.js +20 -23
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +2 -2
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +2 -2
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +3 -4
- package/react/hooks/useQuery.js +2 -2
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +2 -2
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +1 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +1 -1
- package/react/hooks/useSubscription.js +1 -1
- 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 +3 -3
- package/react/hooks/useSuspenseQuery.js +3 -3
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/FragmentReference.d.ts +1 -1
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +1 -1
- package/react/internal/cache/QueryReference.js +1 -1
- 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/getSuspenseCache.d.ts +2 -2
- package/react/internal/cache/getSuspenseCache.js.map +1 -1
- package/react/internal/types.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.js +1 -0
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/prerenderStatic.d.ts +1 -1
- package/react/ssr/prerenderStatic.js +2 -2
- package/react/ssr/prerenderStatic.js.map +1 -1
- package/react/ssr/useSSRQuery.js.map +1 -1
- package/react/types/deprecated.d.ts +1 -1
- package/react/types/types.documentation.d.ts +2 -2
- package/testing/core/index.d.ts +2 -2
- package/testing/core/index.js +1 -1
- package/testing/core/index.js.map +1 -1
- package/testing/core/mocking/mockClient.d.ts +1 -1
- package/testing/core/mocking/mockClient.js +2 -3
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +26 -7
- package/testing/core/mocking/mockLink.js +117 -113
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/experimental/createSchemaFetch.js +1 -1
- package/testing/experimental/createSchemaFetch.js.map +1 -1
- package/testing/experimental/createTestSchema.d.ts +1 -1
- package/testing/experimental/createTestSchema.js.map +1 -1
- package/testing/index.d.ts +1 -1
- package/testing/index.js +1 -1
- package/testing/index.js.map +1 -1
- package/testing/internal/incremental.d.ts +1 -1
- package/testing/internal/incremental.js.map +1 -1
- package/testing/internal/renderHelpers.d.ts +1 -1
- package/testing/internal/renderHelpers.js.map +1 -1
- package/testing/internal/scenarios/index.d.ts +6 -8
- package/testing/internal/scenarios/index.js +4 -2
- package/testing/internal/scenarios/index.js.map +1 -1
- package/testing/matchers/arrayWithLength.d.ts +3 -0
- package/testing/matchers/arrayWithLength.js +11 -0
- package/testing/matchers/arrayWithLength.js.map +1 -0
- package/testing/matchers/index.js +2 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.d.ts +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/matchers/utils/getSerializableProperties.js +1 -1
- package/testing/matchers/utils/getSerializableProperties.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +5 -3
- package/testing/react/MockedProvider.js +7 -3
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/graphql/operations.d.ts +1 -1
- package/utilities/graphql/operations.js.map +1 -1
- package/utilities/index.d.ts +1 -1
- package/utilities/index.js.map +1 -1
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/toQueryResult.d.ts +1 -1
- package/utilities/internal/toQueryResult.js.map +1 -1
- package/utilities/subscriptions/relay/index.d.ts +1 -1
- package/utilities/subscriptions/relay/index.js +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/__cjs/index.cjs +0 -9
- package/__cjs/index.cjs.map +0 -1
- package/__cjs/index.d.cts +0 -3
- package/index.d.ts +0 -3
- package/index.js +0 -4
- package/index.js.map +0 -1
|
@@ -5,9 +5,9 @@ const {
|
|
|
5
5
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ObservableQuery = void 0;
|
|
8
|
-
exports.reobserveCacheFirst = reobserveCacheFirst;
|
|
9
8
|
exports.logMissingFieldErrors = logMissingFieldErrors;
|
|
10
9
|
const equality_1 = require("@wry/equality");
|
|
10
|
+
const optimism_1 = require("optimism");
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const utilities_1 = require("@apollo/client/utilities");
|
|
13
13
|
const environment_1 = require("@apollo/client/utilities/environment");
|
|
@@ -17,7 +17,16 @@ const equalByQuery_js_1 = require("./equalByQuery.cjs");
|
|
|
17
17
|
const networkStatus_js_1 = require("./networkStatus.cjs");
|
|
18
18
|
const { assign, hasOwnProperty } = Object;
|
|
19
19
|
const newNetworkStatusSymbol = Symbol();
|
|
20
|
+
const uninitialized = {};
|
|
20
21
|
class ObservableQuery {
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* A slot used by the `useQuery` hook to indicate that `client.watchQuery`
|
|
25
|
+
* should not register the query immediately, but instead wait for the query to
|
|
26
|
+
* be started registered with the `QueryManager` when `useSyncExternalStore`
|
|
27
|
+
* actively subscribes to it.
|
|
28
|
+
*/
|
|
29
|
+
static inactiveOnCreation = new optimism_1.Slot();
|
|
21
30
|
options;
|
|
22
31
|
queryId;
|
|
23
32
|
queryName;
|
|
@@ -38,7 +47,6 @@ class ObservableQuery {
|
|
|
38
47
|
}
|
|
39
48
|
subject;
|
|
40
49
|
observable;
|
|
41
|
-
initialResult;
|
|
42
50
|
isTornDown;
|
|
43
51
|
queryManager;
|
|
44
52
|
subscriptions = new Set();
|
|
@@ -52,16 +60,31 @@ class ObservableQuery {
|
|
|
52
60
|
networkStatus;
|
|
53
61
|
constructor({ queryManager, queryInfo, options, }) {
|
|
54
62
|
this.networkStatus = networkStatus_js_1.NetworkStatus.loading;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
loading: true,
|
|
58
|
-
networkStatus: this.networkStatus,
|
|
59
|
-
partial: true,
|
|
60
|
-
};
|
|
61
|
-
this.subject = new rxjs_1.BehaviorSubject(this.initialResult);
|
|
63
|
+
let startedInactive = ObservableQuery.inactiveOnCreation.getValue();
|
|
64
|
+
this.subject = new rxjs_1.BehaviorSubject(uninitialized);
|
|
62
65
|
this.observable = this.subject.pipe((0, rxjs_1.tap)({
|
|
63
66
|
subscribe: () => {
|
|
67
|
+
if (startedInactive) {
|
|
68
|
+
queryManager["queries"].set(this.queryId, queryInfo);
|
|
69
|
+
startedInactive = false;
|
|
70
|
+
}
|
|
64
71
|
if (!this.subject.observed) {
|
|
72
|
+
if (this.subject.value === uninitialized) {
|
|
73
|
+
// Emitting a value in the `subscribe` callback of `tap` gives
|
|
74
|
+
// the subject a chance to save this initial result without
|
|
75
|
+
// emitting the placeholder value since this callback is executed
|
|
76
|
+
// before `tap` subscribes to the source observable (the subject).
|
|
77
|
+
// `reobserve` also has the chance to update this value if it
|
|
78
|
+
// synchronously emits one (usually due to reporting a cache
|
|
79
|
+
// value).
|
|
80
|
+
//
|
|
81
|
+
// We don't initialize the `BehaviorSubject` with
|
|
82
|
+
// `getInitialResult` because its possible the cache might have
|
|
83
|
+
// updated between when the `ObservableQuery` was instantiated and
|
|
84
|
+
// when it is subscribed to. Updating the value here ensures we
|
|
85
|
+
// report the most up-to-date result from the cache.
|
|
86
|
+
this.subject.next(this.getInitialResult());
|
|
87
|
+
}
|
|
65
88
|
this.reobserve();
|
|
66
89
|
// TODO: See if we can rework updatePolling to better handle this.
|
|
67
90
|
// reobserve calls updatePolling but this `subscribe` callback is
|
|
@@ -76,19 +99,14 @@ class ObservableQuery {
|
|
|
76
99
|
this.tearDownQuery();
|
|
77
100
|
}
|
|
78
101
|
},
|
|
79
|
-
}),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// TODO: Remove this behavior when unifying loading state for notifyOnNetworkStatusChange
|
|
88
|
-
(this.options.fetchPolicy === "network-only" &&
|
|
89
|
-
!this.queryManager.prioritizeCacheValues &&
|
|
90
|
-
this.queryInfo.getDiff().complete) ||
|
|
91
|
-
result !== this.initialResult));
|
|
102
|
+
}), (0, rxjs_1.filter)((result) => {
|
|
103
|
+
return (this.options.fetchPolicy !== "standby" &&
|
|
104
|
+
(this.options.notifyOnNetworkStatusChange ||
|
|
105
|
+
!result.loading ||
|
|
106
|
+
// data could be defined for cache-and-network fetch policies
|
|
107
|
+
// when emitting the cache result while loading the network result
|
|
108
|
+
!!result.data));
|
|
109
|
+
}));
|
|
92
110
|
this["@@observable"] = () => this;
|
|
93
111
|
if (Symbol.observable) {
|
|
94
112
|
this[Symbol.observable] = () => this;
|
|
@@ -133,6 +151,50 @@ class ObservableQuery {
|
|
|
133
151
|
resetDiff() {
|
|
134
152
|
this.queryInfo.resetDiff();
|
|
135
153
|
}
|
|
154
|
+
getInitialResult() {
|
|
155
|
+
const fetchPolicy = this.queryManager.prioritizeCacheValues ?
|
|
156
|
+
"cache-first"
|
|
157
|
+
: this.options.fetchPolicy;
|
|
158
|
+
const defaultResult = {
|
|
159
|
+
data: undefined,
|
|
160
|
+
loading: true,
|
|
161
|
+
networkStatus: networkStatus_js_1.NetworkStatus.loading,
|
|
162
|
+
partial: true,
|
|
163
|
+
};
|
|
164
|
+
const cacheResult = () => {
|
|
165
|
+
const diff = this.queryInfo.getDiff();
|
|
166
|
+
return this.maskResult({
|
|
167
|
+
data:
|
|
168
|
+
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
169
|
+
// null when returnPartialData is false
|
|
170
|
+
this.options.returnPartialData || diff.complete ?
|
|
171
|
+
diff.result ?? undefined
|
|
172
|
+
: undefined,
|
|
173
|
+
loading: !diff.complete,
|
|
174
|
+
networkStatus: diff.complete ? networkStatus_js_1.NetworkStatus.ready : networkStatus_js_1.NetworkStatus.loading,
|
|
175
|
+
partial: !diff.complete,
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
switch (fetchPolicy) {
|
|
179
|
+
case "cache-only":
|
|
180
|
+
case "cache-first":
|
|
181
|
+
return cacheResult();
|
|
182
|
+
case "cache-and-network":
|
|
183
|
+
return {
|
|
184
|
+
...cacheResult(),
|
|
185
|
+
loading: true,
|
|
186
|
+
networkStatus: networkStatus_js_1.NetworkStatus.loading,
|
|
187
|
+
};
|
|
188
|
+
case "standby":
|
|
189
|
+
return {
|
|
190
|
+
...defaultResult,
|
|
191
|
+
loading: false,
|
|
192
|
+
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
193
|
+
};
|
|
194
|
+
default:
|
|
195
|
+
return defaultResult;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
136
198
|
getCurrentFullResult(saveAsLastResult = true) {
|
|
137
199
|
// Use the last result as long as the variables match this.variables.
|
|
138
200
|
const lastResult = this.getLastResult(true);
|
|
@@ -272,7 +334,7 @@ class ObservableQuery {
|
|
|
272
334
|
const queryDef = (0, utilities_1.getQueryDefinition)(this.query);
|
|
273
335
|
const vars = queryDef.variableDefinitions;
|
|
274
336
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
275
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
337
|
+
__DEV__ && invariant_1.invariant.warn(67, variables, queryDef.name?.value || queryDef);
|
|
276
338
|
}
|
|
277
339
|
}
|
|
278
340
|
if (variables && !(0, equality_1.equal)(this.options.variables, variables)) {
|
|
@@ -308,6 +370,7 @@ class ObservableQuery {
|
|
|
308
370
|
// fetchMore to provide an updateQuery callback that determines how
|
|
309
371
|
// the data gets written to the cache.
|
|
310
372
|
fetchPolicy: "no-cache",
|
|
373
|
+
notifyOnNetworkStatusChange: this.options.notifyOnNetworkStatusChange,
|
|
311
374
|
};
|
|
312
375
|
combinedOptions.query = this.transformDocument(combinedOptions.query);
|
|
313
376
|
const qid = this.queryManager.generateQueryId();
|
|
@@ -331,7 +394,7 @@ class ObservableQuery {
|
|
|
331
394
|
const updateQuery = fetchMoreOptions?.updateQuery;
|
|
332
395
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
333
396
|
if (!isCached) {
|
|
334
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
397
|
+
(0, invariant_1.invariant)(updateQuery, 68);
|
|
335
398
|
}
|
|
336
399
|
return this.queryManager
|
|
337
400
|
.fetchQuery(qid, combinedOptions, networkStatus_js_1.NetworkStatus.fetchMore)
|
|
@@ -416,7 +479,7 @@ class ObservableQuery {
|
|
|
416
479
|
// the cache, we still want fetchMore to deliver its final loading:false
|
|
417
480
|
// result with the unchanged data.
|
|
418
481
|
if (isCached && !updatedQuerySet.has(this.query)) {
|
|
419
|
-
reobserveCacheFirst(
|
|
482
|
+
this.reobserveCacheFirst();
|
|
420
483
|
}
|
|
421
484
|
});
|
|
422
485
|
}
|
|
@@ -444,7 +507,7 @@ class ObservableQuery {
|
|
|
444
507
|
onError(error);
|
|
445
508
|
}
|
|
446
509
|
else {
|
|
447
|
-
__DEV__ && invariant_1.invariant.error(
|
|
510
|
+
__DEV__ && invariant_1.invariant.error(69, error);
|
|
448
511
|
}
|
|
449
512
|
return;
|
|
450
513
|
}
|
|
@@ -588,8 +651,9 @@ class ObservableQuery {
|
|
|
588
651
|
fetch(options, newNetworkStatus, emitLoadingState, query) {
|
|
589
652
|
// TODO Make sure we update the networkStatus (and infer fetchVariables)
|
|
590
653
|
// before actually committing to the fetch.
|
|
591
|
-
this.queryManager.
|
|
592
|
-
|
|
654
|
+
const queryInfo = this.queryManager.getOrCreateQuery(this.queryId);
|
|
655
|
+
queryInfo.setObservableQuery(this);
|
|
656
|
+
return this.queryManager.fetchObservableWithInfo(queryInfo, options, newNetworkStatus, query, emitLoadingState);
|
|
593
657
|
}
|
|
594
658
|
// Turns polling on or off based on this.options.pollInterval.
|
|
595
659
|
updatePolling() {
|
|
@@ -599,16 +663,13 @@ class ObservableQuery {
|
|
|
599
663
|
}
|
|
600
664
|
const { pollingInfo, options: { pollInterval }, } = this;
|
|
601
665
|
if (!pollInterval || !this.hasObservers()) {
|
|
602
|
-
|
|
603
|
-
clearTimeout(pollingInfo.timeout);
|
|
604
|
-
delete this.pollingInfo;
|
|
605
|
-
}
|
|
666
|
+
this.cancelPolling();
|
|
606
667
|
return;
|
|
607
668
|
}
|
|
608
669
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
609
670
|
return;
|
|
610
671
|
}
|
|
611
|
-
(0, invariant_1.invariant)(pollInterval,
|
|
672
|
+
(0, invariant_1.invariant)(pollInterval, 70);
|
|
612
673
|
const info = pollingInfo || (this.pollingInfo = {});
|
|
613
674
|
info.interval = pollInterval;
|
|
614
675
|
const maybeFetch = () => {
|
|
@@ -640,6 +701,13 @@ class ObservableQuery {
|
|
|
640
701
|
};
|
|
641
702
|
poll();
|
|
642
703
|
}
|
|
704
|
+
// This differs from stopPolling in that it does not set pollInterval to 0
|
|
705
|
+
cancelPolling() {
|
|
706
|
+
if (this.pollingInfo) {
|
|
707
|
+
clearTimeout(this.pollingInfo.timeout);
|
|
708
|
+
delete this.pollingInfo;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
643
711
|
updateLastResult(newResult, variables = this.variables) {
|
|
644
712
|
let error = this.getLastError();
|
|
645
713
|
// Preserve this.last.error unless the variables have changed.
|
|
@@ -691,6 +759,7 @@ class ObservableQuery {
|
|
|
691
759
|
// We want to ensure we can re-run the custom document transforms the next
|
|
692
760
|
// time a request is made against the original query.
|
|
693
761
|
const query = this.transformDocument(options.query);
|
|
762
|
+
const { fetchPolicy } = options;
|
|
694
763
|
this.lastQuery = query;
|
|
695
764
|
if (!useDisposableObservable) {
|
|
696
765
|
// We can skip calling updatePolling if we're not changing this.options.
|
|
@@ -701,10 +770,10 @@ class ObservableQuery {
|
|
|
701
770
|
newOptions.variables &&
|
|
702
771
|
!(0, equality_1.equal)(newOptions.variables, oldVariables) &&
|
|
703
772
|
// Don't mess with the fetchPolicy if it's currently "standby".
|
|
704
|
-
|
|
773
|
+
fetchPolicy !== "standby" &&
|
|
705
774
|
// If we're changing the fetchPolicy anyway, don't try to change it here
|
|
706
775
|
// using applyNextFetchPolicy. The explicit options.fetchPolicy wins.
|
|
707
|
-
(
|
|
776
|
+
(fetchPolicy === oldFetchPolicy ||
|
|
708
777
|
// A `nextFetchPolicy` function has even higher priority, though,
|
|
709
778
|
// so in that case `applyNextFetchPolicy` must be called.
|
|
710
779
|
typeof options.nextFetchPolicy === "function")) {
|
|
@@ -722,6 +791,14 @@ class ObservableQuery {
|
|
|
722
791
|
!(0, equality_1.equal)(newOptions.variables, oldVariables)) {
|
|
723
792
|
newNetworkStatus = networkStatus_js_1.NetworkStatus.setVariables;
|
|
724
793
|
}
|
|
794
|
+
// QueryManager does not emit any values for standby fetch policies so we
|
|
795
|
+
// want ensure that the networkStatus remains ready.
|
|
796
|
+
if (fetchPolicy === "standby") {
|
|
797
|
+
newNetworkStatus = networkStatus_js_1.NetworkStatus.ready;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
if (fetchPolicy === "standby") {
|
|
801
|
+
this.cancelPolling();
|
|
725
802
|
}
|
|
726
803
|
this.networkStatus = newNetworkStatus;
|
|
727
804
|
this.waitForOwnResult &&= skipCacheDataFor(options.fetchPolicy);
|
|
@@ -731,7 +808,7 @@ class ObservableQuery {
|
|
|
731
808
|
}
|
|
732
809
|
};
|
|
733
810
|
const variables = options.variables && { ...options.variables };
|
|
734
|
-
const { notifyOnNetworkStatusChange =
|
|
811
|
+
const { notifyOnNetworkStatusChange = true } = options;
|
|
735
812
|
const { observable, fromLink } = this.fetch(options, newNetworkStatus, notifyOnNetworkStatusChange &&
|
|
736
813
|
oldNetworkStatus !== newNetworkStatus &&
|
|
737
814
|
(0, networkStatus_js_1.isNetworkRequestInFlight)(newNetworkStatus), query);
|
|
@@ -844,41 +921,94 @@ class ObservableQuery {
|
|
|
844
921
|
}
|
|
845
922
|
: result;
|
|
846
923
|
}
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
924
|
+
dirty = false;
|
|
925
|
+
notifyTimeout;
|
|
926
|
+
/** @internal */
|
|
927
|
+
resetNotifications() {
|
|
928
|
+
this.cancelNotifyTimeout();
|
|
929
|
+
this.dirty = false;
|
|
930
|
+
}
|
|
931
|
+
cancelNotifyTimeout() {
|
|
932
|
+
if (this.notifyTimeout) {
|
|
933
|
+
clearTimeout(this.notifyTimeout);
|
|
934
|
+
this.notifyTimeout = void 0;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
/** @internal */
|
|
938
|
+
scheduleNotify() {
|
|
939
|
+
if (this.dirty)
|
|
940
|
+
return;
|
|
941
|
+
this.dirty = true;
|
|
942
|
+
if (!this.notifyTimeout) {
|
|
943
|
+
this.notifyTimeout = setTimeout(() => this.notify(), 0);
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
/** @internal */
|
|
947
|
+
notify() {
|
|
948
|
+
this.cancelNotifyTimeout();
|
|
949
|
+
if (this.dirty) {
|
|
950
|
+
if (this.options.fetchPolicy == "cache-only" ||
|
|
951
|
+
this.options.fetchPolicy == "cache-and-network" ||
|
|
952
|
+
!(0, networkStatus_js_1.isNetworkRequestInFlight)(this.networkStatus)) {
|
|
953
|
+
const diff = this.queryInfo.getDiff();
|
|
954
|
+
if (diff.fromOptimisticTransaction) {
|
|
955
|
+
// If this diff came from an optimistic transaction, deliver the
|
|
956
|
+
// current cache data to the ObservableQuery, but don't perform a
|
|
957
|
+
// reobservation, since oq.reobserveCacheFirst might make a network
|
|
958
|
+
// request, and we never want to trigger network requests in the
|
|
959
|
+
// middle of optimistic updates.
|
|
960
|
+
this.observe();
|
|
871
961
|
}
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
962
|
+
else {
|
|
963
|
+
// Otherwise, make the ObservableQuery "reobserve" the latest data
|
|
964
|
+
// using a temporary fetch policy of "cache-first", so complete cache
|
|
965
|
+
// results have a chance to be delivered without triggering additional
|
|
966
|
+
// network requests, even when options.fetchPolicy is "network-only"
|
|
967
|
+
// or "cache-and-network". All other fetch policies are preserved by
|
|
968
|
+
// this method, and are handled by calling oq.reobserve(). If this
|
|
969
|
+
// reobservation is spurious, isDifferentFromLastResult still has a
|
|
970
|
+
// chance to catch it before delivery to ObservableQuery subscribers.
|
|
971
|
+
this.reobserveCacheFirst();
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
this.dirty = false;
|
|
976
|
+
}
|
|
977
|
+
// Reobserve with fetchPolicy effectively set to "cache-first", triggering
|
|
978
|
+
// delivery of any new data from the cache, possibly falling back to the network
|
|
979
|
+
// if any cache data are missing. This allows _complete_ cache results to be
|
|
980
|
+
// delivered without also kicking off unnecessary network requests when
|
|
981
|
+
// this.options.fetchPolicy is "cache-and-network" or "network-only". When
|
|
982
|
+
// this.options.fetchPolicy is any other policy ("cache-first", "cache-only",
|
|
983
|
+
// "standby", or "no-cache"), we call this.reobserve() as usual.
|
|
984
|
+
reobserveCacheFirst() {
|
|
985
|
+
const { fetchPolicy, nextFetchPolicy } = this.options;
|
|
986
|
+
if (fetchPolicy === "cache-and-network" || fetchPolicy === "network-only") {
|
|
987
|
+
return this.reobserve({
|
|
988
|
+
fetchPolicy: "cache-first",
|
|
989
|
+
// Use a temporary nextFetchPolicy function that replaces itself with the
|
|
990
|
+
// previous nextFetchPolicy value and returns the original fetchPolicy.
|
|
991
|
+
nextFetchPolicy(currentFetchPolicy, context) {
|
|
992
|
+
// Replace this nextFetchPolicy function in the options object with the
|
|
993
|
+
// original this.options.nextFetchPolicy value.
|
|
994
|
+
this.nextFetchPolicy = nextFetchPolicy;
|
|
995
|
+
// If the original nextFetchPolicy value was a function, give it a
|
|
996
|
+
// chance to decide what happens here.
|
|
997
|
+
if (typeof this.nextFetchPolicy === "function") {
|
|
998
|
+
return this.nextFetchPolicy(currentFetchPolicy, context);
|
|
999
|
+
}
|
|
1000
|
+
// Otherwise go back to the original this.options.fetchPolicy.
|
|
1001
|
+
return fetchPolicy;
|
|
1002
|
+
},
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
1005
|
+
return this.reobserve();
|
|
876
1006
|
}
|
|
877
|
-
return obsQuery.reobserve();
|
|
878
1007
|
}
|
|
1008
|
+
exports.ObservableQuery = ObservableQuery;
|
|
879
1009
|
function logMissingFieldErrors(missing) {
|
|
880
1010
|
if (environment_1.__DEV__ && missing) {
|
|
881
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1011
|
+
__DEV__ && invariant_1.invariant.debug(71, missing);
|
|
882
1012
|
}
|
|
883
1013
|
}
|
|
884
1014
|
function skipCacheDataFor(fetchPolicy /* `undefined` would mean `"cache-first"` */) {
|