@apollo/client 3.8.7 → 3.8.8
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/README.md +8 -0
- package/.changeset/config.json +14 -0
- package/CHANGELOG.md +3357 -0
- package/apollo-client.cjs +314 -316
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +133 -152
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +133 -152
- package/cache/core/cache.d.ts +10 -0
- package/cache/core/cache.js +17 -5
- 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 +92 -0
- package/cache/core/types/common.js +4 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -1
- package/cache/inmemory/entityStore.js +190 -29
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fixPolyfills.js +9 -0
- package/cache/inmemory/fixPolyfills.js.map +1 -1
- package/cache/inmemory/fixPolyfills.native.js +12 -0
- package/cache/inmemory/fixPolyfills.native.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +23 -12
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.js +20 -11
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.js +161 -8
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +72 -4
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/object-canon.js +91 -3
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.js +193 -43
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.js +20 -2
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +4 -0
- package/cache/inmemory/readFromStore.js +54 -9
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +28 -0
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +152 -25
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/setup.js +2 -0
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +264 -3
- package/core/ApolloClient.js +235 -7
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +4 -6
- package/core/LocalState.js +56 -18
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +25 -0
- package/core/ObservableQuery.js +239 -30
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +3 -3
- package/core/QueryInfo.js +116 -13
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +4 -0
- package/core/QueryManager.js +229 -33
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +112 -103
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +112 -103
- package/core/equalByQuery.js +20 -1
- package/core/equalByQuery.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +19 -0
- package/core/index.js.map +1 -1
- package/core/networkStatus.d.ts +39 -0
- package/core/networkStatus.js +39 -0
- package/core/networkStatus.js.map +1 -1
- package/core/types.d.ts +9 -0
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +225 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +5 -111
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +5 -111
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/errors/errors.cjs +1 -1
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +1 -1
- package/errors/index.js +14 -1
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +1 -0
- package/link/batch/batch.cjs +2 -2
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +2 -2
- package/link/batch/batchLink.d.ts +21 -0
- package/link/batch/batchLink.js +2 -1
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.js +24 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +3 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +3 -2
- package/link/batch-http/batchHttpLink.d.ts +4 -0
- package/link/batch-http/batchHttpLink.js +53 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/context.cjs.map +1 -1
- package/link/context/index.js +1 -0
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.js +12 -5
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +5 -5
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +5 -5
- package/link/error/error.cjs +1 -1
- package/link/error/error.cjs.map +1 -1
- package/link/error/error.cjs.native.js +1 -1
- package/link/error/index.d.ts +3 -0
- package/link/error/index.js +4 -1
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +0 -2
- package/link/http/HttpLink.js +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.js +23 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/createSignalIfSupported.d.ts +5 -0
- package/link/http/createSignalIfSupported.js +5 -0
- package/link/http/createSignalIfSupported.js.map +1 -1
- package/link/http/http.cjs +14 -12
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +14 -12
- package/link/http/index.js +2 -1
- package/link/http/index.js.map +1 -1
- package/link/http/iterators/async.d.ts +4 -0
- package/link/http/iterators/async.js +4 -0
- package/link/http/iterators/async.js.map +1 -1
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.js +4 -0
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/iterators/promise.d.ts +4 -0
- package/link/http/iterators/promise.js +4 -0
- package/link/http/iterators/promise.js.map +1 -1
- package/link/http/iterators/reader.d.ts +4 -0
- package/link/http/iterators/reader.js +4 -0
- package/link/http/iterators/reader.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +51 -10
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts +4 -0
- package/link/http/responseIterator.js +6 -0
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +1 -1
- package/link/http/rewriteURIForGET.js +10 -0
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +45 -0
- package/link/http/selectHttpOptionsAndBody.js +23 -0
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.js +34 -4
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +4 -4
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +4 -4
- package/link/remove-typename/remove-typename.cjs +12 -9
- package/link/remove-typename/remove-typename.cjs.map +1 -1
- package/link/remove-typename/remove-typename.cjs.native.js +12 -9
- package/link/remove-typename/removeTypenameFromVariables.js +12 -9
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/delayFunction.d.ts +29 -0
- package/link/retry/delayFunction.js +6 -0
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retry.cjs +5 -5
- package/link/retry/retry.cjs.map +1 -1
- package/link/retry/retry.cjs.native.js +5 -5
- package/link/retry/retryFunction.d.ts +20 -0
- package/link/retry/retryLink.d.ts +6 -0
- package/link/retry/retryLink.js +31 -6
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +13 -0
- package/link/schema/index.js +3 -3
- package/link/schema/index.js.map +1 -1
- package/link/schema/schema.cjs +3 -3
- package/link/schema/schema.cjs.map +1 -1
- package/link/schema/schema.cjs.native.js +3 -3
- package/link/subscriptions/index.js +35 -2
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +3 -2
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +3 -2
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/filterOperationVariables.js +4 -0
- package/link/utils/filterOperationVariables.js.map +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/transformOperation.js +3 -2
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +12 -0
- package/link/ws/index.js +1 -1
- package/link/ws/index.js.map +1 -1
- package/link/ws/ws.cjs +1 -1
- package/link/ws/ws.cjs.map +1 -1
- package/link/ws/ws.cjs.native.js +1 -1
- package/package.json +49 -38
- package/react/cache/QueryReference.d.ts +6 -1
- package/react/cache/QueryReference.js +26 -1
- package/react/cache/QueryReference.js.map +1 -1
- package/react/cache/SuspenseCache.d.ts +10 -0
- package/react/cache/SuspenseCache.js +1 -1
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/cache/getSuspenseCache.js.map +1 -1
- package/react/context/ApolloContext.d.ts +5 -0
- package/react/context/ApolloContext.js +10 -3
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/context.cjs +1 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +1 -3
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.js +3 -1
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs +9 -17
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +9 -17
- package/react/hoc/mutation-hoc.js +9 -4
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.js +10 -4
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.js +10 -4
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.js +3 -4
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +30 -22
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +30 -22
- package/react/hooks/internal/__use.js +5 -0
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/internal/index.js +1 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -3
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/useBackgroundQuery.js +6 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +4 -3
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +13 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.js +8 -3
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +11 -0
- package/react/hooks/useQuery.js +137 -5
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReactiveVar.js +5 -0
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +19 -0
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +5 -0
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +11 -5
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +53 -1
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/parser/index.js +4 -5
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +2 -4
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +2 -4
- package/react/ssr/RenderPromises.js +21 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/getDataFromTree.js +18 -3
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/ssr.cjs +6 -4
- package/react/ssr/ssr.cjs.map +1 -1
- package/react/ssr/ssr.cjs.native.js +6 -4
- package/react/types/types.d.ts +66 -0
- package/testing/core/core.cjs +14 -11
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +14 -11
- package/testing/core/itAsync.d.ts +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockFetch.d.ts +2 -2
- package/testing/core/mocking/mockFetch.js +8 -4
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.js +17 -7
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.js +2 -0
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.js +1 -1
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +17 -3
- package/testing/core/observableToPromise.js +5 -0
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/subscribeAndCount.js +3 -0
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/core/wait.js +2 -2
- package/testing/core/wait.js.map +1 -1
- package/testing/core/withConsoleSpy.d.ts +3 -0
- package/testing/core/withConsoleSpy.js +7 -1
- package/testing/core/withConsoleSpy.js.map +1 -1
- package/testing/core/wrap.js +2 -0
- package/testing/core/wrap.js.map +1 -1
- package/testing/internal/ObservableStream.js +14 -14
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/disposables/spyOnConsole.d.ts +1 -0
- package/testing/internal/disposables/spyOnConsole.js +2 -0
- package/testing/internal/disposables/spyOnConsole.js.map +1 -1
- package/testing/internal/disposables/withCleanup.d.ts +1 -0
- package/testing/internal/disposables/withCleanup.js +3 -0
- package/testing/internal/disposables/withCleanup.js.map +1 -1
- package/testing/internal/profile/Render.d.ts +28 -0
- package/testing/internal/profile/Render.js +12 -1
- package/testing/internal/profile/Render.js.map +1 -1
- package/testing/internal/profile/profile.d.ts +44 -7
- package/testing/internal/profile/profile.js +63 -51
- package/testing/internal/profile/profile.js.map +1 -1
- package/testing/internal/profile/traces.d.ts +4 -0
- package/testing/internal/profile/traces.js +9 -5
- package/testing/internal/profile/traces.js.map +1 -1
- package/testing/matchers/ProfiledComponent.js +27 -22
- package/testing/matchers/ProfiledComponent.js.map +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +4 -0
- package/testing/react/MockedProvider.js +6 -2
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +4 -2
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +4 -2
- package/utilities/common/arrays.js +1 -0
- package/utilities/common/arrays.js.map +1 -1
- package/utilities/common/canUse.js +16 -1
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/cloneDeep.d.ts +3 -0
- package/utilities/common/cloneDeep.js +5 -0
- package/utilities/common/cloneDeep.js.map +1 -1
- package/utilities/common/compact.d.ts +4 -0
- package/utilities/common/compact.js +4 -0
- package/utilities/common/compact.js.map +1 -1
- package/utilities/common/errorHandling.js +1 -3
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.js +3 -0
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/makeUniqueId.js +2 -0
- package/utilities/common/makeUniqueId.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +3 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.js +12 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/omitDeep.js.map +1 -1
- package/utilities/globals/global.js +7 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +4 -5
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +4 -5
- package/utilities/globals/index.d.ts +4 -0
- package/utilities/globals/index.js +7 -0
- package/utilities/globals/index.js.map +1 -1
- package/utilities/globals/invariantWrappers.d.ts +40 -0
- package/utilities/globals/invariantWrappers.js +11 -3
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/globals/maybe.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +19 -6
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/directives.js +3 -0
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +25 -0
- package/utilities/graphql/fragments.js +36 -0
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +5 -0
- package/utilities/graphql/getFromAST.js +9 -0
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +14 -0
- package/utilities/graphql/storeUtils.js +7 -2
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.js +106 -7
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/observables/Concast.d.ts +1 -1
- package/utilities/observables/Concast.js +84 -1
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/Observable.js +6 -0
- package/utilities/observables/Observable.js.map +1 -1
- package/utilities/observables/asyncMap.js +12 -3
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/observables/iteration.js +3 -0
- package/utilities/observables/iteration.js.map +1 -1
- package/utilities/observables/subclassing.js +14 -0
- package/utilities/observables/subclassing.js.map +1 -1
- package/utilities/policies/pagination.js +47 -3
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/promises/decoration.js +1 -0
- package/utilities/promises/decoration.js.map +1 -1
- package/utilities/types/DeepOmit.js.map +1 -1
- package/utilities/types/DeepPartial.d.ts +1 -1
- package/utilities/types/DeepPartial.js +4 -0
- package/utilities/types/DeepPartial.js.map +1 -1
- package/utilities/types/IsStrictlyAny.js.map +1 -1
- package/utilities/types/TODO.d.ts +3 -0
- package/utilities/types/TODO.js +2 -0
- package/utilities/types/TODO.js.map +1 -0
- package/utilities/utilities.cjs +31 -27
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +31 -27
- package/version.js +1 -1
- package/cache/core/cache.d.ts.map +0 -1
- package/cache/core/types/Cache.d.ts.map +0 -1
- package/cache/core/types/DataProxy.d.ts.map +0 -1
- package/cache/core/types/common.d.ts.map +0 -1
- package/cache/index.d.ts.map +0 -1
- package/cache/inmemory/entityStore.d.ts.map +0 -1
- package/cache/inmemory/fixPolyfills.d.ts.map +0 -1
- package/cache/inmemory/fixPolyfills.native.d.ts.map +0 -1
- package/cache/inmemory/fragmentRegistry.d.ts.map +0 -1
- package/cache/inmemory/helpers.d.ts.map +0 -1
- package/cache/inmemory/inMemoryCache.d.ts.map +0 -1
- package/cache/inmemory/key-extractor.d.ts.map +0 -1
- package/cache/inmemory/object-canon.d.ts.map +0 -1
- package/cache/inmemory/policies.d.ts.map +0 -1
- package/cache/inmemory/reactiveVars.d.ts.map +0 -1
- package/cache/inmemory/readFromStore.d.ts.map +0 -1
- package/cache/inmemory/types.d.ts.map +0 -1
- package/cache/inmemory/writeToStore.d.ts.map +0 -1
- package/config/jest/setup.d.ts.map +0 -1
- package/core/ApolloClient.d.ts.map +0 -1
- package/core/LocalState.d.ts.map +0 -1
- package/core/ObservableQuery.d.ts.map +0 -1
- package/core/QueryInfo.d.ts.map +0 -1
- package/core/QueryManager.d.ts.map +0 -1
- package/core/equalByQuery.d.ts.map +0 -1
- package/core/index.d.ts.map +0 -1
- package/core/networkStatus.d.ts.map +0 -1
- package/core/types.d.ts.map +0 -1
- package/core/watchQueryOptions.d.ts.map +0 -1
- package/dev/index.d.ts.map +0 -1
- package/dev/loadDevMessages.d.ts.map +0 -1
- package/dev/loadErrorMessageHandler.d.ts.map +0 -1
- package/dev/loadErrorMessages.d.ts.map +0 -1
- package/errors/index.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/invariantErrorCodes.d.ts.map +0 -1
- package/link/batch/batchLink.d.ts.map +0 -1
- package/link/batch/batching.d.ts.map +0 -1
- package/link/batch/index.d.ts.map +0 -1
- package/link/batch-http/batchHttpLink.d.ts.map +0 -1
- package/link/batch-http/index.d.ts.map +0 -1
- package/link/context/index.d.ts.map +0 -1
- package/link/core/ApolloLink.d.ts.map +0 -1
- package/link/core/concat.d.ts.map +0 -1
- package/link/core/empty.d.ts.map +0 -1
- package/link/core/execute.d.ts.map +0 -1
- package/link/core/from.d.ts.map +0 -1
- package/link/core/index.d.ts.map +0 -1
- package/link/core/split.d.ts.map +0 -1
- package/link/core/types.d.ts.map +0 -1
- package/link/error/index.d.ts.map +0 -1
- package/link/http/HttpLink.d.ts.map +0 -1
- package/link/http/checkFetcher.d.ts.map +0 -1
- package/link/http/createHttpLink.d.ts.map +0 -1
- package/link/http/createSignalIfSupported.d.ts.map +0 -1
- package/link/http/index.d.ts.map +0 -1
- package/link/http/iterators/async.d.ts.map +0 -1
- package/link/http/iterators/nodeStream.d.ts.map +0 -1
- package/link/http/iterators/promise.d.ts.map +0 -1
- package/link/http/iterators/reader.d.ts.map +0 -1
- package/link/http/parseAndCheckHttpResponse.d.ts.map +0 -1
- package/link/http/responseIterator.d.ts.map +0 -1
- package/link/http/rewriteURIForGET.d.ts.map +0 -1
- package/link/http/selectHttpOptionsAndBody.d.ts.map +0 -1
- package/link/http/selectURI.d.ts.map +0 -1
- package/link/http/serializeFetchParameter.d.ts.map +0 -1
- package/link/persisted-queries/index.d.ts.map +0 -1
- package/link/remove-typename/index.d.ts.map +0 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts.map +0 -1
- package/link/retry/delayFunction.d.ts.map +0 -1
- package/link/retry/index.d.ts.map +0 -1
- package/link/retry/retryFunction.d.ts.map +0 -1
- package/link/retry/retryLink.d.ts.map +0 -1
- package/link/schema/index.d.ts.map +0 -1
- package/link/subscriptions/index.d.ts.map +0 -1
- package/link/utils/createOperation.d.ts.map +0 -1
- package/link/utils/filterOperationVariables.d.ts.map +0 -1
- package/link/utils/fromError.d.ts.map +0 -1
- package/link/utils/fromPromise.d.ts.map +0 -1
- package/link/utils/index.d.ts.map +0 -1
- package/link/utils/throwServerError.d.ts.map +0 -1
- package/link/utils/toPromise.d.ts.map +0 -1
- package/link/utils/transformOperation.d.ts.map +0 -1
- package/link/utils/validateOperation.d.ts.map +0 -1
- package/link/ws/index.d.ts.map +0 -1
- package/react/cache/QueryReference.d.ts.map +0 -1
- package/react/cache/SuspenseCache.d.ts.map +0 -1
- package/react/cache/getSuspenseCache.d.ts.map +0 -1
- package/react/cache/index.d.ts.map +0 -1
- package/react/cache/types.d.ts.map +0 -1
- package/react/components/Mutation.d.ts.map +0 -1
- package/react/components/Query.d.ts.map +0 -1
- package/react/components/Subscription.d.ts.map +0 -1
- package/react/components/index.d.ts.map +0 -1
- package/react/components/types.d.ts.map +0 -1
- package/react/context/ApolloConsumer.d.ts.map +0 -1
- package/react/context/ApolloContext.d.ts.map +0 -1
- package/react/context/ApolloProvider.d.ts.map +0 -1
- package/react/context/index.d.ts.map +0 -1
- package/react/hoc/graphql.d.ts.map +0 -1
- package/react/hoc/hoc-utils.d.ts.map +0 -1
- package/react/hoc/index.d.ts.map +0 -1
- package/react/hoc/mutation-hoc.d.ts.map +0 -1
- package/react/hoc/query-hoc.d.ts.map +0 -1
- package/react/hoc/subscription-hoc.d.ts.map +0 -1
- package/react/hoc/types.d.ts.map +0 -1
- package/react/hoc/withApollo.d.ts.map +0 -1
- package/react/hooks/constants.d.ts.map +0 -1
- package/react/hooks/index.d.ts.map +0 -1
- package/react/hooks/internal/__use.d.ts.map +0 -1
- package/react/hooks/internal/index.d.ts.map +0 -1
- package/react/hooks/internal/useDeepMemo.d.ts.map +0 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +0 -1
- package/react/hooks/useApolloClient.d.ts.map +0 -1
- package/react/hooks/useBackgroundQuery.d.ts.map +0 -1
- package/react/hooks/useFragment.d.ts.map +0 -1
- package/react/hooks/useLazyQuery.d.ts.map +0 -1
- package/react/hooks/useMutation.d.ts.map +0 -1
- package/react/hooks/useQuery.d.ts.map +0 -1
- package/react/hooks/useReactiveVar.d.ts.map +0 -1
- package/react/hooks/useReadQuery.d.ts.map +0 -1
- package/react/hooks/useSubscription.d.ts.map +0 -1
- package/react/hooks/useSuspenseQuery.d.ts.map +0 -1
- package/react/hooks/useSyncExternalStore.d.ts.map +0 -1
- package/react/index.d.ts.map +0 -1
- package/react/parser/index.d.ts.map +0 -1
- package/react/ssr/RenderPromises.d.ts.map +0 -1
- package/react/ssr/getDataFromTree.d.ts.map +0 -1
- package/react/ssr/index.d.ts.map +0 -1
- package/react/ssr/renderToStringWithData.d.ts.map +0 -1
- package/react/types/types.d.ts.map +0 -1
- package/testing/core/index.d.ts.map +0 -1
- package/testing/core/itAsync.d.ts.map +0 -1
- package/testing/core/mocking/mockClient.d.ts.map +0 -1
- package/testing/core/mocking/mockFetch.d.ts.map +0 -1
- package/testing/core/mocking/mockLink.d.ts.map +0 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +0 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +0 -1
- package/testing/core/mocking/mockWatchQuery.d.ts.map +0 -1
- package/testing/core/observableToPromise.d.ts.map +0 -1
- package/testing/core/subscribeAndCount.d.ts.map +0 -1
- package/testing/core/wait.d.ts.map +0 -1
- package/testing/core/withConsoleSpy.d.ts.map +0 -1
- package/testing/core/wrap.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/internal/ObservableStream.d.ts.map +0 -1
- package/testing/internal/disposables/index.d.ts.map +0 -1
- package/testing/internal/disposables/spyOnConsole.d.ts.map +0 -1
- package/testing/internal/disposables/withCleanup.d.ts.map +0 -1
- package/testing/internal/index.d.ts.map +0 -1
- package/testing/internal/profile/Render.d.ts.map +0 -1
- package/testing/internal/profile/index.d.ts.map +0 -1
- package/testing/internal/profile/profile.d.ts.map +0 -1
- package/testing/internal/profile/traces.d.ts.map +0 -1
- package/testing/matchers/ProfiledComponent.d.ts.map +0 -1
- package/testing/matchers/index.d.ts.map +0 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +0 -1
- package/testing/matchers/toMatchDocument.d.ts.map +0 -1
- package/testing/react/MockedProvider.d.ts.map +0 -1
- package/utilities/common/arrays.d.ts.map +0 -1
- package/utilities/common/canUse.d.ts.map +0 -1
- package/utilities/common/cloneDeep.d.ts.map +0 -1
- package/utilities/common/compact.d.ts.map +0 -1
- package/utilities/common/errorHandling.d.ts.map +0 -1
- package/utilities/common/filterInPlace.d.ts +0 -2
- package/utilities/common/filterInPlace.d.ts.map +0 -1
- package/utilities/common/filterInPlace.js +0 -11
- package/utilities/common/filterInPlace.js.map +0 -1
- package/utilities/common/incrementalResult.d.ts.map +0 -1
- package/utilities/common/makeUniqueId.d.ts.map +0 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +0 -1
- package/utilities/common/mergeDeep.d.ts.map +0 -1
- package/utilities/common/mergeOptions.d.ts.map +0 -1
- package/utilities/common/objects.d.ts.map +0 -1
- package/utilities/common/omitDeep.d.ts.map +0 -1
- package/utilities/common/stringifyForDisplay.d.ts.map +0 -1
- package/utilities/common/stripTypename.d.ts.map +0 -1
- package/utilities/globals/global.d.ts.map +0 -1
- package/utilities/globals/index.d.ts.map +0 -1
- package/utilities/globals/invariantWrappers.d.ts.map +0 -1
- package/utilities/globals/maybe.d.ts.map +0 -1
- package/utilities/graphql/DocumentTransform.d.ts.map +0 -1
- package/utilities/graphql/directives.d.ts.map +0 -1
- package/utilities/graphql/fragments.d.ts.map +0 -1
- package/utilities/graphql/getFromAST.d.ts.map +0 -1
- package/utilities/graphql/operations.d.ts.map +0 -1
- package/utilities/graphql/print.d.ts.map +0 -1
- package/utilities/graphql/storeUtils.d.ts.map +0 -1
- package/utilities/graphql/transform.d.ts.map +0 -1
- package/utilities/index.d.ts.map +0 -1
- package/utilities/observables/Concast.d.ts.map +0 -1
- package/utilities/observables/Observable.d.ts.map +0 -1
- package/utilities/observables/asyncMap.d.ts.map +0 -1
- package/utilities/observables/iteration.d.ts.map +0 -1
- package/utilities/observables/subclassing.d.ts.map +0 -1
- package/utilities/policies/pagination.d.ts.map +0 -1
- package/utilities/promises/decoration.d.ts.map +0 -1
- package/utilities/types/DeepOmit.d.ts.map +0 -1
- package/utilities/types/DeepPartial.d.ts.map +0 -1
- package/utilities/types/IsStrictlyAny.d.ts.map +0 -1
- package/utilities/types/Primitive.d.ts.map +0 -1
- package/version.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQuery.js","sourceRoot":"","sources":["../../src/core/ObservableQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAM7E,OAAO,EACL,SAAS,EACT,OAAO,EACP,sBAAsB,EACtB,UAAU,EACV,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAkB/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEzC,IAAA,MAAM,GAAqB,MAAM,OAA3B,EAAE,cAAc,GAAK,MAAM,eAAX,CAAY;AAyB1C;IAGU,mCAAoC;IAwC5C,yBAAY,EAQX;YAPC,YAAY,kBAAA,EACZ,SAAS,eAAA,EACT,OAAO,aAAA;QAHT,YASE,kBAAM,UAAC,QAA4C;YAGjD,IAAI;gBACF,IAA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graphql\";\nimport { equal } from \"@wry/equality\";\n\nimport { NetworkStatus, isNetworkRequestInFlight } from \"./networkStatus.js\";\nimport type {\n Concast,\n Observer,\n ObservableSubscription,\n} from \"../utilities/index.js\";\nimport {\n cloneDeep,\n compact,\n getOperationDefinition,\n Observable,\n iterateObserversSafely,\n fixObservableSubclass,\n getQueryDefinition,\n} from \"../utilities/index.js\";\nimport type { ApolloError } from \"../errors/index.js\";\nimport type { QueryManager } from \"./QueryManager.js\";\nimport type {\n ApolloQueryResult,\n OperationVariables,\n TypedDocumentNode,\n} from \"./types.js\";\nimport type {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n NextFetchPolicyContext,\n WatchQueryFetchPolicy,\n} from \"./watchQueryOptions.js\";\nimport type { QueryInfo } from \"./QueryInfo.js\";\nimport type { MissingFieldError } from \"../cache/index.js\";\nimport type { MissingTree } from \"../cache/core/types/common.js\";\nimport { equalByQuery } from \"./equalByQuery.js\";\n\nconst { assign, hasOwnProperty } = Object;\n\nexport interface FetchMoreOptions<\n TData = any,\n TVariables = OperationVariables,\n> {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult?: TData;\n variables?: TVariables;\n }\n ) => TData;\n}\n\nexport interface UpdateQueryOptions<TVariables> {\n variables?: TVariables;\n}\n\ninterface Last<TData, TVariables> {\n result: ApolloQueryResult<TData>;\n variables?: TVariables;\n error?: ApolloError;\n}\n\nexport class ObservableQuery<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n> extends Observable<ApolloQueryResult<TData>> {\n public readonly options: WatchQueryOptions<TVariables, TData>;\n public readonly queryId: string;\n public readonly queryName?: string;\n\n // The `query` computed property will always reflect the document transformed\n // by the last run query. `this.options.query` will always reflect the raw\n // untransformed query to ensure document transforms with runtime conditionals\n // are run on the original document.\n public get query(): TypedDocumentNode<TData, TVariables> {\n return this.lastQuery || this.options.query;\n }\n\n // Computed shorthand for this.options.variables, preserved for\n // backwards compatibility.\n public get variables(): TVariables | undefined {\n return this.options.variables;\n }\n\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<ObservableSubscription>();\n\n private waitForOwnResult: boolean;\n private last?: Last<TData, TVariables>;\n private lastQuery?: DocumentNode;\n\n private queryInfo: QueryInfo;\n\n // When this.concast is defined, this.observer is the Observer currently\n // subscribed to that Concast.\n private concast?: Concast<ApolloQueryResult<TData>>;\n private observer?: Observer<ApolloQueryResult<TData>>;\n\n private pollingInfo?: {\n interval: number;\n timeout: ReturnType<typeof setTimeout>;\n };\n\n constructor({\n queryManager,\n queryInfo,\n options,\n }: {\n queryManager: QueryManager<any>;\n queryInfo: QueryInfo;\n options: WatchQueryOptions<TVariables, TData>;\n }) {\n super((observer: Observer<ApolloQueryResult<TData>>) => {\n // Zen Observable has its own error function, so in order to log correctly\n // we need to provide a custom error callback.\n try {\n var subObserver = (observer as any)._subscription._observer;\n if (subObserver && !subObserver.error) {\n subObserver.error = defaultSubscriptionObserverErrorCallback;\n }\n } catch {}\n\n const first = !this.observers.size;\n this.observers.add(observer);\n\n // Deliver most recent error or result.\n const last = this.last;\n if (last && last.error) {\n observer.error && observer.error(last.error);\n } else if (last && last.result) {\n observer.next && observer.next(last.result);\n }\n\n // Initiate observation of this query if it hasn't been reported to\n // the QueryManager yet.\n if (first) {\n // Blindly catching here prevents unhandled promise rejections,\n // and is safe because the ObservableQuery handles this error with\n // this.observer.error, so we're not just swallowing the error by\n // ignoring it here.\n this.reobserve().catch(() => {});\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n });\n\n // related classes\n this.queryInfo = queryInfo;\n this.queryManager = queryManager;\n\n // active state\n this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);\n this.isTornDown = false;\n\n const {\n watchQuery: { fetchPolicy: defaultFetchPolicy = \"cache-first\" } = {},\n } = queryManager.defaultOptions;\n\n const {\n fetchPolicy = defaultFetchPolicy,\n // Make sure we don't store \"standby\" as the initialFetchPolicy.\n initialFetchPolicy = fetchPolicy === \"standby\"\n ? defaultFetchPolicy\n : fetchPolicy,\n } = options;\n\n this.options = {\n ...options,\n\n // Remember the initial options.fetchPolicy so we can revert back to this\n // policy when variables change. This information can also be specified\n // (or overridden) by providing options.initialFetchPolicy explicitly.\n initialFetchPolicy,\n\n // This ensures this.options.fetchPolicy always has a string value, in\n // case options.fetchPolicy was not provided.\n fetchPolicy,\n };\n\n this.queryId = queryInfo.queryId || queryManager.generateQueryId();\n\n const opDef = getOperationDefinition(this.query);\n this.queryName = opDef && opDef.name && opDef.name.value;\n }\n\n public result(): Promise<ApolloQueryResult<TData>> {\n return new Promise((resolve, reject) => {\n // TODO: this code doesn’t actually make sense insofar as the observer\n // will never exist in this.observers due how zen-observable wraps observables.\n // https://github.com/zenparsing/zen-observable/blob/master/src/Observable.js#L169\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result: ApolloQueryResult<TData>) => {\n resolve(result);\n\n // Stop the query within the QueryManager if we can before\n // this function returns.\n //\n // We do this in order to prevent observers piling up within\n // the QueryManager. Notice that we only fully unsubscribe\n // from the subscription in a setTimeout(..., 0) call. This call can\n // actually be handled by the browser at a much later time. If queries\n // are fired in the meantime, observers that should have been removed\n // from the QueryManager will continue to fire, causing an unnecessary\n // performance hit.\n this.observers.delete(observer);\n if (!this.observers.size) {\n this.queryManager.removeQuery(this.queryId);\n }\n\n setTimeout(() => {\n subscription.unsubscribe();\n }, 0);\n },\n error: reject,\n };\n const subscription = this.subscribe(observer);\n });\n }\n\n public getCurrentResult(saveAsLastResult = true): ApolloQueryResult<TData> {\n // Use the last result as long as the variables match this.variables.\n const lastResult = this.getLastResult(true);\n\n const networkStatus =\n this.queryInfo.networkStatus ||\n (lastResult && lastResult.networkStatus) ||\n NetworkStatus.ready;\n\n const result = {\n ...lastResult,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n } as ApolloQueryResult<TData>;\n\n const { fetchPolicy = \"cache-first\" } = this.options;\n if (\n // These fetch policies should never deliver data from the cache, unless\n // redelivering a previously delivered result.\n skipCacheDataFor(fetchPolicy) ||\n // If this.options.query has @client(always: true) fields, we cannot\n // trust diff.result, since it was read from the cache without running\n // local resolvers (and it's too late to run resolvers now, since we must\n // return a result synchronously).\n this.queryManager.getDocumentInfo(this.query).hasForcedResolvers\n ) {\n // Fall through.\n } else if (this.waitForOwnResult) {\n // This would usually be a part of `QueryInfo.getDiff()`.\n // which we skip in the waitForOwnResult case since we are not\n // interested in the diff.\n this.queryInfo[\"updateWatch\"]();\n } else {\n const diff = this.queryInfo.getDiff();\n\n if (diff.complete || this.options.returnPartialData) {\n result.data = diff.result;\n }\n\n if (equal(result.data, {})) {\n result.data = void 0 as any;\n }\n\n if (diff.complete) {\n // Similar to setting result.partial to false, but taking advantage of the\n // falsiness of missing fields.\n delete result.partial;\n\n // If the diff is complete, and we're using a FetchPolicy that\n // terminates after a complete cache read, we can assume the next result\n // we receive will have NetworkStatus.ready and !loading.\n if (\n diff.complete &&\n result.networkStatus === NetworkStatus.loading &&\n (fetchPolicy === \"cache-first\" || fetchPolicy === \"cache-only\")\n ) {\n result.networkStatus = NetworkStatus.ready;\n result.loading = false;\n }\n } else {\n result.partial = true;\n }\n\n if (\n __DEV__ &&\n !diff.complete &&\n !this.options.partialRefetch &&\n !result.loading &&\n !result.data &&\n !result.error\n ) {\n logMissingFieldErrors(diff.missing);\n }\n }\n\n if (saveAsLastResult) {\n this.updateLastResult(result);\n }\n\n return result;\n }\n\n // Compares newResult to the snapshot we took of this.lastResult when it was\n // first received.\n public isDifferentFromLastResult(\n newResult: ApolloQueryResult<TData>,\n variables?: TVariables\n ) {\n if (!this.last) {\n return true;\n }\n\n const resultIsDifferent = this.queryManager.getDocumentInfo(this.query)\n .hasNonreactiveDirective\n ? !equalByQuery(this.query, this.last.result, newResult, this.variables)\n : !equal(this.last.result, newResult);\n\n return (\n resultIsDifferent || (variables && !equal(this.last.variables, variables))\n );\n }\n\n private getLast<K extends keyof Last<TData, TVariables>>(\n key: K,\n variablesMustMatch?: boolean\n ) {\n const last = this.last;\n if (\n last &&\n last[key] &&\n (!variablesMustMatch || equal(last.variables, this.variables))\n ) {\n return last[key];\n }\n }\n\n public getLastResult(\n variablesMustMatch?: boolean\n ): ApolloQueryResult<TData> | undefined {\n return this.getLast(\"result\", variablesMustMatch);\n }\n\n public getLastError(variablesMustMatch?: boolean): ApolloError | undefined {\n return this.getLast(\"error\", variablesMustMatch);\n }\n\n public resetLastResults(): void {\n delete this.last;\n this.isTornDown = false;\n }\n\n public resetQueryStoreErrors() {\n this.queryManager.resetErrors(this.queryId);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results.\n * This method should be preferred over `setVariables` in most use cases.\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public refetch(\n variables?: Partial<TVariables>\n ): Promise<ApolloQueryResult<TData>> {\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n // Always disable polling for refetches.\n pollInterval: 0,\n };\n\n // Unless the provided fetchPolicy always consults the network\n // (no-cache, network-only, or cache-and-network), override it with\n // network-only to force the refetch for this fetchQuery call.\n const { fetchPolicy } = this.options;\n if (fetchPolicy === \"cache-and-network\") {\n reobserveOptions.fetchPolicy = fetchPolicy;\n } else if (fetchPolicy === \"no-cache\") {\n reobserveOptions.fetchPolicy = \"no-cache\";\n } else {\n reobserveOptions.fetchPolicy = \"network-only\";\n }\n\n if (__DEV__ && variables && hasOwnProperty.call(variables, \"variables\")) {\n const queryDef = getQueryDefinition(this.query);\n const vars = queryDef.variableDefinitions;\n if (!vars || !vars.some((v) => v.variable.name.value === \"variables\")) {\n invariant.warn(\n `Called refetch(%o) for query %o, which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?`,\n variables,\n queryDef.name?.value || queryDef\n );\n }\n }\n\n if (variables && !equal(this.options.variables, variables)) {\n // Update the existing options with new variables\n reobserveOptions.variables = this.options.variables = {\n ...this.options.variables,\n ...variables,\n } as TVariables;\n }\n\n this.queryInfo.resetLastWrite();\n return this.reobserve(reobserveOptions, NetworkStatus.refetch);\n }\n\n public fetchMore<\n TFetchData = TData,\n TFetchVars extends OperationVariables = TVariables,\n >(\n fetchMoreOptions: FetchMoreQueryOptions<TFetchVars, TFetchData> & {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult: TFetchData;\n variables: TFetchVars;\n }\n ) => TData;\n }\n ): Promise<ApolloQueryResult<TFetchData>> {\n const combinedOptions = {\n ...(fetchMoreOptions.query\n ? fetchMoreOptions\n : {\n ...this.options,\n query: this.options.query,\n ...fetchMoreOptions,\n variables: {\n ...this.options.variables,\n ...fetchMoreOptions.variables,\n },\n }),\n // The fetchMore request goes immediately to the network and does\n // not automatically write its result to the cache (hence no-cache\n // instead of network-only), because we allow the caller of\n // fetchMore to provide an updateQuery callback that determines how\n // the data gets written to the cache.\n fetchPolicy: \"no-cache\",\n } as WatchQueryOptions<TFetchVars, TFetchData>;\n\n combinedOptions.query = this.transformDocument(combinedOptions.query);\n\n const qid = this.queryManager.generateQueryId();\n\n // If a temporary query is passed to `fetchMore`, we don't want to store\n // it as the last query result since it may be an optimized query for\n // pagination. We will however run the transforms on the original document\n // as well as the document passed in `fetchMoreOptions` to ensure the cache\n // uses the most up-to-date document which may rely on runtime conditionals.\n this.lastQuery = fetchMoreOptions.query\n ? this.transformDocument(this.options.query)\n : combinedOptions.query;\n\n // Simulate a loading result for the original query with\n // result.networkStatus === NetworkStatus.fetchMore.\n const { queryInfo } = this;\n const originalNetworkStatus = queryInfo.networkStatus;\n queryInfo.networkStatus = NetworkStatus.fetchMore;\n if (combinedOptions.notifyOnNetworkStatusChange) {\n this.observe();\n }\n\n const updatedQuerySet = new Set<DocumentNode>();\n\n return this.queryManager\n .fetchQuery(qid, combinedOptions, NetworkStatus.fetchMore)\n .then((fetchMoreResult) => {\n this.queryManager.removeQuery(qid);\n\n if (queryInfo.networkStatus === NetworkStatus.fetchMore) {\n queryInfo.networkStatus = originalNetworkStatus;\n }\n\n // Performing this cache update inside a cache.batch transaction ensures\n // any affected cache.watch watchers are notified at most once about any\n // updates. Most watchers will be using the QueryInfo class, which\n // responds to notifications by calling reobserveCacheFirst to deliver\n // fetchMore cache results back to this ObservableQuery.\n this.queryManager.cache.batch({\n update: (cache) => {\n const { updateQuery } = fetchMoreOptions;\n if (updateQuery) {\n cache.updateQuery(\n {\n query: this.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n },\n (previous) =>\n updateQuery(previous!, {\n fetchMoreResult: fetchMoreResult.data,\n variables: combinedOptions.variables as TFetchVars,\n })\n );\n } else {\n // If we're using a field policy instead of updateQuery, the only\n // thing we need to do is write the new data to the cache using\n // combinedOptions.variables (instead of this.variables, which is\n // what this.updateQuery uses, because it works by abusing the\n // original field value, keyed by the original variables).\n cache.writeQuery({\n query: combinedOptions.query,\n variables: combinedOptions.variables,\n data: fetchMoreResult.data,\n });\n }\n },\n\n onWatchUpdated: (watch) => {\n // Record the DocumentNode associated with any watched query whose\n // data were updated by the cache writes above.\n updatedQuerySet.add(watch.query);\n },\n });\n\n return fetchMoreResult;\n })\n .finally(() => {\n // In case the cache writes above did not generate a broadcast\n // notification (which would have been intercepted by onWatchUpdated),\n // likely because the written data were the same as what was already in\n // the cache, we still want fetchMore to deliver its final loading:false\n // result with the unchanged data.\n if (!updatedQuerySet.has(this.query)) {\n reobserveCacheFirst(this);\n }\n });\n }\n\n // XXX the subscription variables are separate from the query variables.\n // if you want to update subscription variables, right now you have to do that separately,\n // and you can only do it by stopping the subscription and then subscribing again with new variables.\n public subscribeToMore<\n TSubscriptionData = TData,\n TSubscriptionVariables extends OperationVariables = TVariables,\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >\n ) {\n const subscription = this.queryManager\n .startGraphQLSubscription({\n query: options.document,\n variables: options.variables,\n context: options.context,\n })\n .subscribe({\n next: (subscriptionData: { data: TSubscriptionData }) => {\n const { updateQuery } = options;\n if (updateQuery) {\n this.updateQuery<TSubscriptionVariables>(\n (previous, { variables }) =>\n updateQuery(previous, {\n subscriptionData,\n variables,\n })\n );\n }\n },\n error: (err: any) => {\n if (options.onError) {\n options.onError(err);\n return;\n }\n invariant.error(\"Unhandled GraphQL subscription error\", err);\n },\n });\n\n this.subscriptions.add(subscription);\n\n return () => {\n if (this.subscriptions.delete(subscription)) {\n subscription.unsubscribe();\n }\n };\n }\n\n public setOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserve(newOptions);\n }\n\n public silentSetOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>\n ) {\n const mergedOptions = compact(this.options, newOptions || {});\n assign(this.options, mergedOptions);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results\n * if they've changed. Most users should prefer `refetch` instead of\n * `setVariables` in order to to be properly notified of results even when\n * they come from the cache.\n *\n * Note: the `next` callback will *not* fire if the variables have not changed\n * or if the result is coming from cache.\n *\n * Note: the promise will return the old results immediately if the variables\n * have not changed.\n *\n * Note: the promise will return null immediately if the query is not active\n * (there are no subscribers).\n *\n * @private\n *\n * @param variables: The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public setVariables(\n variables: TVariables\n ): Promise<ApolloQueryResult<TData> | void> {\n if (equal(this.variables, variables)) {\n // If we have no observers, then we don't actually want to make a network\n // request. As soon as someone observes the query, the request will kick\n // off. For now, we just store any changes. (See #1077)\n return this.observers.size ? this.result() : Promise.resolve();\n }\n\n this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n return this.reobserve(\n {\n // Reset options.fetchPolicy to its original value.\n fetchPolicy: this.options.initialFetchPolicy,\n variables,\n },\n NetworkStatus.setVariables\n );\n }\n\n public updateQuery<TVars extends OperationVariables = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: Pick<WatchQueryOptions<TVars, TData>, \"variables\">\n ) => TData\n ): void {\n const { queryManager } = this;\n const { result } = queryManager.cache.diff<TData>({\n query: this.options.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n });\n\n const newResult = mapFn(result!, {\n variables: (this as any).variables,\n });\n\n if (newResult) {\n queryManager.cache.writeQuery({\n query: this.options.query,\n data: newResult,\n variables: this.variables,\n });\n\n queryManager.broadcastQueries();\n }\n }\n\n public startPolling(pollInterval: number) {\n this.options.pollInterval = pollInterval;\n this.updatePolling();\n }\n\n public stopPolling() {\n this.options.pollInterval = 0;\n this.updatePolling();\n }\n\n // Update options.fetchPolicy according to options.nextFetchPolicy.\n private applyNextFetchPolicy(\n reason: NextFetchPolicyContext<TData, TVariables>[\"reason\"],\n // It's possible to use this method to apply options.nextFetchPolicy to\n // options.fetchPolicy even if options !== this.options, though that happens\n // most often when the options are temporary, used for only one request and\n // then thrown away, so nextFetchPolicy may not end up mattering.\n options: WatchQueryOptions<TVariables, TData>\n ) {\n if (options.nextFetchPolicy) {\n const { fetchPolicy = \"cache-first\", initialFetchPolicy = fetchPolicy } =\n options;\n\n if (fetchPolicy === \"standby\") {\n // Do nothing, leaving options.fetchPolicy unchanged.\n } else if (typeof options.nextFetchPolicy === \"function\") {\n // When someone chooses \"cache-and-network\" or \"network-only\" as their\n // initial FetchPolicy, they often do not want future cache updates to\n // trigger unconditional network requests, which is what repeatedly\n // applying the \"cache-and-network\" or \"network-only\" policies would\n // seem to imply. Instead, when the cache reports an update after the\n // initial network request, it may be desirable for subsequent network\n // requests to be triggered only if the cache result is incomplete. To\n // that end, the options.nextFetchPolicy option provides an easy way to\n // update options.fetchPolicy after the initial network request, without\n // having to call observableQuery.setOptions.\n options.fetchPolicy = options.nextFetchPolicy(fetchPolicy, {\n reason,\n options,\n observable: this,\n initialFetchPolicy,\n });\n } else if (reason === \"variables-changed\") {\n options.fetchPolicy = initialFetchPolicy;\n } else {\n options.fetchPolicy = options.nextFetchPolicy;\n }\n }\n\n return options.fetchPolicy;\n }\n\n private fetch(\n options: WatchQueryOptions<TVariables, TData>,\n newNetworkStatus?: NetworkStatus,\n query?: DocumentNode\n ) {\n // TODO Make sure we update the networkStatus (and infer fetchVariables)\n // before actually committing to the fetch.\n this.queryManager.setObservableQuery(this);\n return this.queryManager[\"fetchConcastWithInfo\"](\n this.queryId,\n options,\n newNetworkStatus,\n query\n );\n }\n\n // Turns polling on or off based on this.options.pollInterval.\n private updatePolling() {\n // Avoid polling in SSR mode\n if (this.queryManager.ssrMode) {\n return;\n }\n\n const {\n pollingInfo,\n options: { pollInterval },\n } = this;\n\n if (!pollInterval) {\n if (pollingInfo) {\n clearTimeout(pollingInfo.timeout);\n delete this.pollingInfo;\n }\n return;\n }\n\n if (pollingInfo && pollingInfo.interval === pollInterval) {\n return;\n }\n\n invariant(\n pollInterval,\n \"Attempted to start a polling query without a polling interval.\"\n );\n\n const info = pollingInfo || (this.pollingInfo = {} as any);\n info.interval = pollInterval;\n\n const maybeFetch = () => {\n if (this.pollingInfo) {\n if (!isNetworkRequestInFlight(this.queryInfo.networkStatus)) {\n this.reobserve(\n {\n // Most fetchPolicy options don't make sense to use in a polling context, as\n // users wouldn't want to be polling the cache directly. However, network-only and\n // no-cache are both useful for when the user wants to control whether or not the\n // polled results are written to the cache.\n fetchPolicy:\n this.options.initialFetchPolicy === \"no-cache\"\n ? \"no-cache\"\n : \"network-only\",\n },\n NetworkStatus.poll\n ).then(poll, poll);\n } else {\n poll();\n }\n }\n };\n\n const poll = () => {\n const info = this.pollingInfo;\n if (info) {\n clearTimeout(info.timeout);\n info.timeout = setTimeout(maybeFetch, info.interval);\n }\n };\n\n poll();\n }\n\n private updateLastResult(\n newResult: ApolloQueryResult<TData>,\n variables = this.variables\n ) {\n let error: ApolloError | undefined = this.getLastError();\n // Preserve this.last.error unless the variables have changed.\n if (error && this.last && !equal(variables, this.last.variables)) {\n error = void 0;\n }\n return (this.last = {\n result: this.queryManager.assumeImmutableResults\n ? newResult\n : cloneDeep(newResult),\n variables,\n ...(error ? { error } : null),\n });\n }\n\n public reobserveAsConcast(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus\n ): Concast<ApolloQueryResult<TData>> {\n this.isTornDown = false;\n\n const useDisposableConcast =\n // Refetching uses a disposable Concast to allow refetches using different\n // options/variables, without permanently altering the options of the\n // original ObservableQuery.\n newNetworkStatus === NetworkStatus.refetch ||\n // The fetchMore method does not actually call the reobserve method, but,\n // if it did, it would definitely use a disposable Concast.\n newNetworkStatus === NetworkStatus.fetchMore ||\n // Polling uses a disposable Concast so the polling options (which force\n // fetchPolicy to be \"network-only\" or \"no-cache\") won't override the original options.\n newNetworkStatus === NetworkStatus.poll;\n\n // Save the old variables, since Object.assign may modify them below.\n const oldVariables = this.options.variables;\n const oldFetchPolicy = this.options.fetchPolicy;\n\n const mergedOptions = compact(this.options, newOptions || {});\n const options = useDisposableConcast\n ? // Disposable Concast fetches receive a shallow copy of this.options\n // (merged with newOptions), leaving this.options unmodified.\n mergedOptions\n : assign(this.options, mergedOptions);\n\n // Don't update options.query with the transformed query to avoid\n // overwriting this.options.query when we aren't using a disposable concast.\n // We want to ensure we can re-run the custom document transforms the next\n // time a request is made against the original query.\n const query = this.transformDocument(options.query);\n\n this.lastQuery = query;\n\n if (!useDisposableConcast) {\n // We can skip calling updatePolling if we're not changing this.options.\n this.updatePolling();\n\n // Reset options.fetchPolicy to its original value when variables change,\n // unless a new fetchPolicy was provided by newOptions.\n if (\n newOptions &&\n newOptions.variables &&\n !equal(newOptions.variables, oldVariables) &&\n // Don't mess with the fetchPolicy if it's currently \"standby\".\n options.fetchPolicy !== \"standby\" &&\n // If we're changing the fetchPolicy anyway, don't try to change it here\n // using applyNextFetchPolicy. The explicit options.fetchPolicy wins.\n options.fetchPolicy === oldFetchPolicy\n ) {\n this.applyNextFetchPolicy(\"variables-changed\", options);\n if (newNetworkStatus === void 0) {\n newNetworkStatus = NetworkStatus.setVariables;\n }\n }\n }\n\n this.waitForOwnResult &&= skipCacheDataFor(options.fetchPolicy);\n const finishWaitingForOwnResult = () => {\n if (this.concast === concast) {\n this.waitForOwnResult = false;\n }\n };\n\n const variables = options.variables && { ...options.variables };\n const { concast, fromLink } = this.fetch(options, newNetworkStatus, query);\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result) => {\n finishWaitingForOwnResult();\n this.reportResult(result, variables);\n },\n error: (error) => {\n finishWaitingForOwnResult();\n this.reportError(error, variables);\n },\n };\n\n if (!useDisposableConcast && (fromLink || !this.concast)) {\n // We use the {add,remove}Observer methods directly to avoid wrapping\n // observer with an unnecessary SubscriptionObserver object.\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n }\n\n this.concast = concast;\n this.observer = observer;\n }\n\n concast.addObserver(observer);\n\n return concast;\n }\n\n public reobserve(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus\n ) {\n return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;\n }\n\n public resubscribeAfterError(\n onNext: (value: ApolloQueryResult<TData>) => void,\n onError?: (error: any) => void,\n onComplete?: () => void\n ): ObservableSubscription;\n\n public resubscribeAfterError(\n observer: Observer<ApolloQueryResult<TData>>\n ): ObservableSubscription;\n\n public resubscribeAfterError(...args: [any, any?, any?]) {\n // If `lastError` is set in the current when the subscription is re-created,\n // the subscription will immediately receive the error, which will\n // cause it to terminate again. To avoid this, we first clear\n // the last error/result from the `observableQuery` before re-starting\n // the subscription, and restore the last value afterwards so that the\n // subscription has a chance to stay open.\n const last = this.last;\n this.resetLastResults();\n\n const subscription = this.subscribe(...args);\n this.last = last;\n\n return subscription;\n }\n\n // (Re)deliver the current result to this.observers without applying fetch\n // policies or making network requests.\n private observe() {\n this.reportResult(\n // Passing false is important so that this.getCurrentResult doesn't\n // save the fetchMore result as this.lastResult, causing it to be\n // ignored due to the this.isDifferentFromLastResult check in\n // this.reportResult.\n this.getCurrentResult(false),\n this.variables\n );\n }\n\n private reportResult(\n result: ApolloQueryResult<TData>,\n variables: TVariables | undefined\n ) {\n const lastError = this.getLastError();\n const isDifferent = this.isDifferentFromLastResult(result, variables);\n // Update the last result even when isDifferentFromLastResult returns false,\n // because the query may be using the @nonreactive directive, and we want to\n // save the the latest version of any nonreactive subtrees (in case\n // getCurrentResult is called), even though we skip broadcasting changes.\n if (lastError || !result.partial || this.options.returnPartialData) {\n this.updateLastResult(result, variables);\n }\n if (lastError || isDifferent) {\n iterateObserversSafely(this.observers, \"next\", result);\n }\n }\n\n private reportError(error: ApolloError, variables: TVariables | undefined) {\n // Since we don't get the current result on errors, only the error, we\n // must mirror the updates that occur in QueryStore.markQueryError here\n const errorResult = {\n ...this.getLastResult(),\n error,\n errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n } as ApolloQueryResult<TData>;\n\n this.updateLastResult(errorResult, variables);\n\n iterateObserversSafely(this.observers, \"error\", (this.last!.error = error));\n }\n\n public hasObservers() {\n return this.observers.size > 0;\n }\n\n private tearDownQuery() {\n if (this.isTornDown) return;\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n delete this.concast;\n delete this.observer;\n }\n\n this.stopPolling();\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach((sub) => sub.unsubscribe());\n this.subscriptions.clear();\n this.queryManager.stopQuery(this.queryId);\n this.observers.clear();\n this.isTornDown = true;\n }\n\n private transformDocument(document: DocumentNode) {\n return this.queryManager.transform(document);\n }\n}\n\n// Necessary because the ObservableQuery constructor has a different\n// signature than the Observable constructor.\nfixObservableSubclass(ObservableQuery);\n\n// Reobserve with fetchPolicy effectively set to \"cache-first\", triggering\n// delivery of any new data from the cache, possibly falling back to the network\n// if any cache data are missing. This allows _complete_ cache results to be\n// delivered without also kicking off unnecessary network requests when\n// this.options.fetchPolicy is \"cache-and-network\" or \"network-only\". When\n// this.options.fetchPolicy is any other policy (\"cache-first\", \"cache-only\",\n// \"standby\", or \"no-cache\"), we call this.reobserve() as usual.\nexport function reobserveCacheFirst<TData, TVars extends OperationVariables>(\n obsQuery: ObservableQuery<TData, TVars>\n) {\n const { fetchPolicy, nextFetchPolicy } = obsQuery.options;\n\n if (fetchPolicy === \"cache-and-network\" || fetchPolicy === \"network-only\") {\n return obsQuery.reobserve({\n fetchPolicy: \"cache-first\",\n // Use a temporary nextFetchPolicy function that replaces itself with the\n // previous nextFetchPolicy value and returns the original fetchPolicy.\n nextFetchPolicy(this: WatchQueryOptions<TVars, TData>) {\n // Replace this nextFetchPolicy function in the options object with the\n // original this.options.nextFetchPolicy value.\n this.nextFetchPolicy = nextFetchPolicy;\n // If the original nextFetchPolicy value was a function, give it a\n // chance to decide what happens here.\n if (typeof nextFetchPolicy === \"function\") {\n return nextFetchPolicy.apply(this, arguments);\n }\n // Otherwise go back to the original this.options.fetchPolicy.\n return fetchPolicy!;\n },\n });\n }\n\n return obsQuery.reobserve();\n}\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error(\"Unhandled error\", error.message, error.stack);\n}\n\nexport function logMissingFieldErrors(\n missing: MissingFieldError[] | MissingTree | undefined\n) {\n if (__DEV__ && missing) {\n invariant.debug(`Missing cache result fields: %o`, missing);\n }\n}\n\nfunction skipCacheDataFor(\n fetchPolicy?: WatchQueryFetchPolicy /* `undefined` would mean `\"cache-first\"` */\n) {\n return (\n fetchPolicy === \"network-only\" ||\n fetchPolicy === \"no-cache\" ||\n fetchPolicy === \"standby\"\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ObservableQuery.js","sourceRoot":"","sources":["../../src/core/ObservableQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAM7E,OAAO,EACL,SAAS,EACT,OAAO,EACP,sBAAsB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;AACH,CAAC;AAED,SAAS,gBAAgB,CACvB,WAAmC,CAAC,4CAA4C;IAEhF,OAAO,CACL,WAAW,KAAK,cAAc;QAC9B,WAAW,KAAK,UAAU;QAC1B,WAAW,KAAK,SAAS,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../utilities/globals/index.js\";\nimport type { DocumentNode } from \"graphql\";\nimport { equal } from \"@wry/equality\";\n\nimport { NetworkStatus, isNetworkRequestInFlight } from \"./networkStatus.js\";\nimport type {\n Concast,\n Observer,\n ObservableSubscription,\n} from \"../utilities/index.js\";\nimport {\n cloneDeep,\n compact,\n getOperationDefinition,\n Observable,\n iterateObserversSafely,\n fixObservableSubclass,\n getQueryDefinition,\n} from \"../utilities/index.js\";\nimport type { ApolloError } from \"../errors/index.js\";\nimport type { QueryManager } from \"./QueryManager.js\";\nimport type {\n ApolloQueryResult,\n OperationVariables,\n TypedDocumentNode,\n} from \"./types.js\";\nimport type {\n WatchQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n NextFetchPolicyContext,\n WatchQueryFetchPolicy,\n} from \"./watchQueryOptions.js\";\nimport type { QueryInfo } from \"./QueryInfo.js\";\nimport type { MissingFieldError } from \"../cache/index.js\";\nimport type { MissingTree } from \"../cache/core/types/common.js\";\nimport { equalByQuery } from \"./equalByQuery.js\";\nimport type { TODO } from \"../utilities/types/TODO.js\";\n\nconst { assign, hasOwnProperty } = Object;\n\nexport interface FetchMoreOptions<\n TData = any,\n TVariables = OperationVariables,\n> {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult?: TData;\n variables?: TVariables;\n }\n ) => TData;\n}\n\nexport interface UpdateQueryOptions<TVariables> {\n variables?: TVariables;\n}\n\ninterface Last<TData, TVariables> {\n result: ApolloQueryResult<TData>;\n variables?: TVariables;\n error?: ApolloError;\n}\n\nexport class ObservableQuery<\n TData = any,\n TVariables extends OperationVariables = OperationVariables,\n> extends Observable<ApolloQueryResult<TData>> {\n public readonly options: WatchQueryOptions<TVariables, TData>;\n public readonly queryId: string;\n public readonly queryName?: string;\n\n // The `query` computed property will always reflect the document transformed\n // by the last run query. `this.options.query` will always reflect the raw\n // untransformed query to ensure document transforms with runtime conditionals\n // are run on the original document.\n public get query(): TypedDocumentNode<TData, TVariables> {\n return this.lastQuery || this.options.query;\n }\n\n // Computed shorthand for this.options.variables, preserved for\n // backwards compatibility.\n public get variables(): TVariables | undefined {\n return this.options.variables;\n }\n\n private isTornDown: boolean;\n private queryManager: QueryManager<any>;\n private observers = new Set<Observer<ApolloQueryResult<TData>>>();\n private subscriptions = new Set<ObservableSubscription>();\n\n private waitForOwnResult: boolean;\n private last?: Last<TData, TVariables>;\n private lastQuery?: DocumentNode;\n\n private queryInfo: QueryInfo;\n\n // When this.concast is defined, this.observer is the Observer currently\n // subscribed to that Concast.\n private concast?: Concast<ApolloQueryResult<TData>>;\n private observer?: Observer<ApolloQueryResult<TData>>;\n\n private pollingInfo?: {\n interval: number;\n timeout: ReturnType<typeof setTimeout>;\n };\n\n constructor({\n queryManager,\n queryInfo,\n options,\n }: {\n queryManager: QueryManager<any>;\n queryInfo: QueryInfo;\n options: WatchQueryOptions<TVariables, TData>;\n }) {\n super((observer: Observer<ApolloQueryResult<TData>>) => {\n // Zen Observable has its own error function, so in order to log correctly\n // we need to provide a custom error callback.\n try {\n var subObserver = (observer as any)._subscription._observer;\n if (subObserver && !subObserver.error) {\n subObserver.error = defaultSubscriptionObserverErrorCallback;\n }\n } catch {}\n\n const first = !this.observers.size;\n this.observers.add(observer);\n\n // Deliver most recent error or result.\n const last = this.last;\n if (last && last.error) {\n observer.error && observer.error(last.error);\n } else if (last && last.result) {\n observer.next && observer.next(last.result);\n }\n\n // Initiate observation of this query if it hasn't been reported to\n // the QueryManager yet.\n if (first) {\n // Blindly catching here prevents unhandled promise rejections,\n // and is safe because the ObservableQuery handles this error with\n // this.observer.error, so we're not just swallowing the error by\n // ignoring it here.\n this.reobserve().catch(() => {});\n }\n\n return () => {\n if (this.observers.delete(observer) && !this.observers.size) {\n this.tearDownQuery();\n }\n };\n });\n\n // related classes\n this.queryInfo = queryInfo;\n this.queryManager = queryManager;\n\n // active state\n this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);\n this.isTornDown = false;\n\n const {\n watchQuery: { fetchPolicy: defaultFetchPolicy = \"cache-first\" } = {},\n } = queryManager.defaultOptions;\n\n const {\n fetchPolicy = defaultFetchPolicy,\n // Make sure we don't store \"standby\" as the initialFetchPolicy.\n initialFetchPolicy = fetchPolicy === \"standby\" ? defaultFetchPolicy : (\n fetchPolicy\n ),\n } = options;\n\n this.options = {\n ...options,\n\n // Remember the initial options.fetchPolicy so we can revert back to this\n // policy when variables change. This information can also be specified\n // (or overridden) by providing options.initialFetchPolicy explicitly.\n initialFetchPolicy,\n\n // This ensures this.options.fetchPolicy always has a string value, in\n // case options.fetchPolicy was not provided.\n fetchPolicy,\n };\n\n this.queryId = queryInfo.queryId || queryManager.generateQueryId();\n\n const opDef = getOperationDefinition(this.query);\n this.queryName = opDef && opDef.name && opDef.name.value;\n }\n\n public result(): Promise<ApolloQueryResult<TData>> {\n return new Promise((resolve, reject) => {\n // TODO: this code doesn’t actually make sense insofar as the observer\n // will never exist in this.observers due how zen-observable wraps observables.\n // https://github.com/zenparsing/zen-observable/blob/master/src/Observable.js#L169\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result: ApolloQueryResult<TData>) => {\n resolve(result);\n\n // Stop the query within the QueryManager if we can before\n // this function returns.\n //\n // We do this in order to prevent observers piling up within\n // the QueryManager. Notice that we only fully unsubscribe\n // from the subscription in a setTimeout(..., 0) call. This call can\n // actually be handled by the browser at a much later time. If queries\n // are fired in the meantime, observers that should have been removed\n // from the QueryManager will continue to fire, causing an unnecessary\n // performance hit.\n this.observers.delete(observer);\n if (!this.observers.size) {\n this.queryManager.removeQuery(this.queryId);\n }\n\n setTimeout(() => {\n subscription.unsubscribe();\n }, 0);\n },\n error: reject,\n };\n const subscription = this.subscribe(observer);\n });\n }\n\n public getCurrentResult(saveAsLastResult = true): ApolloQueryResult<TData> {\n // Use the last result as long as the variables match this.variables.\n const lastResult = this.getLastResult(true);\n\n const networkStatus =\n this.queryInfo.networkStatus ||\n (lastResult && lastResult.networkStatus) ||\n NetworkStatus.ready;\n\n const result = {\n ...lastResult,\n loading: isNetworkRequestInFlight(networkStatus),\n networkStatus,\n } as ApolloQueryResult<TData>;\n\n const { fetchPolicy = \"cache-first\" } = this.options;\n if (\n // These fetch policies should never deliver data from the cache, unless\n // redelivering a previously delivered result.\n skipCacheDataFor(fetchPolicy) ||\n // If this.options.query has @client(always: true) fields, we cannot\n // trust diff.result, since it was read from the cache without running\n // local resolvers (and it's too late to run resolvers now, since we must\n // return a result synchronously).\n this.queryManager.getDocumentInfo(this.query).hasForcedResolvers\n ) {\n // Fall through.\n } else if (this.waitForOwnResult) {\n // This would usually be a part of `QueryInfo.getDiff()`.\n // which we skip in the waitForOwnResult case since we are not\n // interested in the diff.\n this.queryInfo[\"updateWatch\"]();\n } else {\n const diff = this.queryInfo.getDiff();\n\n if (diff.complete || this.options.returnPartialData) {\n result.data = diff.result;\n }\n\n if (equal(result.data, {})) {\n result.data = void 0 as any;\n }\n\n if (diff.complete) {\n // Similar to setting result.partial to false, but taking advantage of the\n // falsiness of missing fields.\n delete result.partial;\n\n // If the diff is complete, and we're using a FetchPolicy that\n // terminates after a complete cache read, we can assume the next result\n // we receive will have NetworkStatus.ready and !loading.\n if (\n diff.complete &&\n result.networkStatus === NetworkStatus.loading &&\n (fetchPolicy === \"cache-first\" || fetchPolicy === \"cache-only\")\n ) {\n result.networkStatus = NetworkStatus.ready;\n result.loading = false;\n }\n } else {\n result.partial = true;\n }\n\n if (\n __DEV__ &&\n !diff.complete &&\n !this.options.partialRefetch &&\n !result.loading &&\n !result.data &&\n !result.error\n ) {\n logMissingFieldErrors(diff.missing);\n }\n }\n\n if (saveAsLastResult) {\n this.updateLastResult(result);\n }\n\n return result;\n }\n\n // Compares newResult to the snapshot we took of this.lastResult when it was\n // first received.\n public isDifferentFromLastResult(\n newResult: ApolloQueryResult<TData>,\n variables?: TVariables\n ) {\n if (!this.last) {\n return true;\n }\n\n const resultIsDifferent =\n this.queryManager.getDocumentInfo(this.query).hasNonreactiveDirective ?\n !equalByQuery(this.query, this.last.result, newResult, this.variables)\n : !equal(this.last.result, newResult);\n\n return (\n resultIsDifferent || (variables && !equal(this.last.variables, variables))\n );\n }\n\n private getLast<K extends keyof Last<TData, TVariables>>(\n key: K,\n variablesMustMatch?: boolean\n ) {\n const last = this.last;\n if (\n last &&\n last[key] &&\n (!variablesMustMatch || equal(last.variables, this.variables))\n ) {\n return last[key];\n }\n }\n\n public getLastResult(\n variablesMustMatch?: boolean\n ): ApolloQueryResult<TData> | undefined {\n return this.getLast(\"result\", variablesMustMatch);\n }\n\n public getLastError(variablesMustMatch?: boolean): ApolloError | undefined {\n return this.getLast(\"error\", variablesMustMatch);\n }\n\n public resetLastResults(): void {\n delete this.last;\n this.isTornDown = false;\n }\n\n public resetQueryStoreErrors() {\n this.queryManager.resetErrors(this.queryId);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results.\n * This method should be preferred over `setVariables` in most use cases.\n *\n * @param variables - The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public refetch(\n variables?: Partial<TVariables>\n ): Promise<ApolloQueryResult<TData>> {\n const reobserveOptions: Partial<WatchQueryOptions<TVariables, TData>> = {\n // Always disable polling for refetches.\n pollInterval: 0,\n };\n\n // Unless the provided fetchPolicy always consults the network\n // (no-cache, network-only, or cache-and-network), override it with\n // network-only to force the refetch for this fetchQuery call.\n const { fetchPolicy } = this.options;\n if (fetchPolicy === \"cache-and-network\") {\n reobserveOptions.fetchPolicy = fetchPolicy;\n } else if (fetchPolicy === \"no-cache\") {\n reobserveOptions.fetchPolicy = \"no-cache\";\n } else {\n reobserveOptions.fetchPolicy = \"network-only\";\n }\n\n if (__DEV__ && variables && hasOwnProperty.call(variables, \"variables\")) {\n const queryDef = getQueryDefinition(this.query);\n const vars = queryDef.variableDefinitions;\n if (!vars || !vars.some((v) => v.variable.name.value === \"variables\")) {\n invariant.warn(\n `Called refetch(%o) for query %o, which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?`,\n variables,\n queryDef.name?.value || queryDef\n );\n }\n }\n\n if (variables && !equal(this.options.variables, variables)) {\n // Update the existing options with new variables\n reobserveOptions.variables = this.options.variables = {\n ...this.options.variables,\n ...variables,\n } as TVariables;\n }\n\n this.queryInfo.resetLastWrite();\n return this.reobserve(reobserveOptions, NetworkStatus.refetch);\n }\n\n public fetchMore<\n TFetchData = TData,\n TFetchVars extends OperationVariables = TVariables,\n >(\n fetchMoreOptions: FetchMoreQueryOptions<TFetchVars, TFetchData> & {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult: TFetchData;\n variables: TFetchVars;\n }\n ) => TData;\n }\n ): Promise<ApolloQueryResult<TFetchData>> {\n const combinedOptions = {\n ...(fetchMoreOptions.query ? fetchMoreOptions : (\n {\n ...this.options,\n query: this.options.query,\n ...fetchMoreOptions,\n variables: {\n ...this.options.variables,\n ...fetchMoreOptions.variables,\n },\n }\n )),\n // The fetchMore request goes immediately to the network and does\n // not automatically write its result to the cache (hence no-cache\n // instead of network-only), because we allow the caller of\n // fetchMore to provide an updateQuery callback that determines how\n // the data gets written to the cache.\n fetchPolicy: \"no-cache\",\n } as WatchQueryOptions<TFetchVars, TFetchData>;\n\n combinedOptions.query = this.transformDocument(combinedOptions.query);\n\n const qid = this.queryManager.generateQueryId();\n\n // If a temporary query is passed to `fetchMore`, we don't want to store\n // it as the last query result since it may be an optimized query for\n // pagination. We will however run the transforms on the original document\n // as well as the document passed in `fetchMoreOptions` to ensure the cache\n // uses the most up-to-date document which may rely on runtime conditionals.\n this.lastQuery =\n fetchMoreOptions.query ?\n this.transformDocument(this.options.query)\n : combinedOptions.query;\n\n // Simulate a loading result for the original query with\n // result.networkStatus === NetworkStatus.fetchMore.\n const { queryInfo } = this;\n const originalNetworkStatus = queryInfo.networkStatus;\n queryInfo.networkStatus = NetworkStatus.fetchMore;\n if (combinedOptions.notifyOnNetworkStatusChange) {\n this.observe();\n }\n\n const updatedQuerySet = new Set<DocumentNode>();\n\n return this.queryManager\n .fetchQuery(qid, combinedOptions, NetworkStatus.fetchMore)\n .then((fetchMoreResult) => {\n this.queryManager.removeQuery(qid);\n\n if (queryInfo.networkStatus === NetworkStatus.fetchMore) {\n queryInfo.networkStatus = originalNetworkStatus;\n }\n\n // Performing this cache update inside a cache.batch transaction ensures\n // any affected cache.watch watchers are notified at most once about any\n // updates. Most watchers will be using the QueryInfo class, which\n // responds to notifications by calling reobserveCacheFirst to deliver\n // fetchMore cache results back to this ObservableQuery.\n this.queryManager.cache.batch({\n update: (cache) => {\n const { updateQuery } = fetchMoreOptions;\n if (updateQuery) {\n cache.updateQuery(\n {\n query: this.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n },\n (previous) =>\n updateQuery(previous!, {\n fetchMoreResult: fetchMoreResult.data,\n variables: combinedOptions.variables as TFetchVars,\n })\n );\n } else {\n // If we're using a field policy instead of updateQuery, the only\n // thing we need to do is write the new data to the cache using\n // combinedOptions.variables (instead of this.variables, which is\n // what this.updateQuery uses, because it works by abusing the\n // original field value, keyed by the original variables).\n cache.writeQuery({\n query: combinedOptions.query,\n variables: combinedOptions.variables,\n data: fetchMoreResult.data,\n });\n }\n },\n\n onWatchUpdated: (watch) => {\n // Record the DocumentNode associated with any watched query whose\n // data were updated by the cache writes above.\n updatedQuerySet.add(watch.query);\n },\n });\n\n return fetchMoreResult;\n })\n .finally(() => {\n // In case the cache writes above did not generate a broadcast\n // notification (which would have been intercepted by onWatchUpdated),\n // likely because the written data were the same as what was already in\n // the cache, we still want fetchMore to deliver its final loading:false\n // result with the unchanged data.\n if (!updatedQuerySet.has(this.query)) {\n reobserveCacheFirst(this);\n }\n });\n }\n\n // XXX the subscription variables are separate from the query variables.\n // if you want to update subscription variables, right now you have to do that separately,\n // and you can only do it by stopping the subscription and then subscribing again with new variables.\n public subscribeToMore<\n TSubscriptionData = TData,\n TSubscriptionVariables extends OperationVariables = TVariables,\n >(\n options: SubscribeToMoreOptions<\n TData,\n TSubscriptionVariables,\n TSubscriptionData\n >\n ) {\n const subscription = this.queryManager\n .startGraphQLSubscription({\n query: options.document,\n variables: options.variables,\n context: options.context,\n })\n .subscribe({\n next: (subscriptionData: { data: TSubscriptionData }) => {\n const { updateQuery } = options;\n if (updateQuery) {\n this.updateQuery<TSubscriptionVariables>(\n (previous, { variables }) =>\n updateQuery(previous, {\n subscriptionData,\n variables,\n })\n );\n }\n },\n error: (err: any) => {\n if (options.onError) {\n options.onError(err);\n return;\n }\n invariant.error(\"Unhandled GraphQL subscription error\", err);\n },\n });\n\n this.subscriptions.add(subscription);\n\n return () => {\n if (this.subscriptions.delete(subscription)) {\n subscription.unsubscribe();\n }\n };\n }\n\n public setOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserve(newOptions);\n }\n\n public silentSetOptions(\n newOptions: Partial<WatchQueryOptions<TVariables, TData>>\n ) {\n const mergedOptions = compact(this.options, newOptions || {});\n assign(this.options, mergedOptions);\n }\n\n /**\n * Update the variables of this observable query, and fetch the new results\n * if they've changed. Most users should prefer `refetch` instead of\n * `setVariables` in order to to be properly notified of results even when\n * they come from the cache.\n *\n * Note: the `next` callback will *not* fire if the variables have not changed\n * or if the result is coming from cache.\n *\n * Note: the promise will return the old results immediately if the variables\n * have not changed.\n *\n * Note: the promise will return null immediately if the query is not active\n * (there are no subscribers).\n *\n * @param variables - The new set of variables. If there are missing variables,\n * the previous values of those variables will be used.\n */\n public setVariables(\n variables: TVariables\n ): Promise<ApolloQueryResult<TData> | void> {\n if (equal(this.variables, variables)) {\n // If we have no observers, then we don't actually want to make a network\n // request. As soon as someone observes the query, the request will kick\n // off. For now, we just store any changes. (See #1077)\n return this.observers.size ? this.result() : Promise.resolve();\n }\n\n this.options.variables = variables;\n\n // See comment above\n if (!this.observers.size) {\n return Promise.resolve();\n }\n\n return this.reobserve(\n {\n // Reset options.fetchPolicy to its original value.\n fetchPolicy: this.options.initialFetchPolicy,\n variables,\n },\n NetworkStatus.setVariables\n );\n }\n\n public updateQuery<TVars extends OperationVariables = TVariables>(\n mapFn: (\n previousQueryResult: TData,\n options: Pick<WatchQueryOptions<TVars, TData>, \"variables\">\n ) => TData\n ): void {\n const { queryManager } = this;\n const { result } = queryManager.cache.diff<TData>({\n query: this.options.query,\n variables: this.variables,\n returnPartialData: true,\n optimistic: false,\n });\n\n const newResult = mapFn(result!, {\n variables: (this as any).variables,\n });\n\n if (newResult) {\n queryManager.cache.writeQuery({\n query: this.options.query,\n data: newResult,\n variables: this.variables,\n });\n\n queryManager.broadcastQueries();\n }\n }\n\n public startPolling(pollInterval: number) {\n this.options.pollInterval = pollInterval;\n this.updatePolling();\n }\n\n public stopPolling() {\n this.options.pollInterval = 0;\n this.updatePolling();\n }\n\n // Update options.fetchPolicy according to options.nextFetchPolicy.\n private applyNextFetchPolicy(\n reason: NextFetchPolicyContext<TData, TVariables>[\"reason\"],\n // It's possible to use this method to apply options.nextFetchPolicy to\n // options.fetchPolicy even if options !== this.options, though that happens\n // most often when the options are temporary, used for only one request and\n // then thrown away, so nextFetchPolicy may not end up mattering.\n options: WatchQueryOptions<TVariables, TData>\n ) {\n if (options.nextFetchPolicy) {\n const { fetchPolicy = \"cache-first\", initialFetchPolicy = fetchPolicy } =\n options;\n\n if (fetchPolicy === \"standby\") {\n // Do nothing, leaving options.fetchPolicy unchanged.\n } else if (typeof options.nextFetchPolicy === \"function\") {\n // When someone chooses \"cache-and-network\" or \"network-only\" as their\n // initial FetchPolicy, they often do not want future cache updates to\n // trigger unconditional network requests, which is what repeatedly\n // applying the \"cache-and-network\" or \"network-only\" policies would\n // seem to imply. Instead, when the cache reports an update after the\n // initial network request, it may be desirable for subsequent network\n // requests to be triggered only if the cache result is incomplete. To\n // that end, the options.nextFetchPolicy option provides an easy way to\n // update options.fetchPolicy after the initial network request, without\n // having to call observableQuery.setOptions.\n options.fetchPolicy = options.nextFetchPolicy(fetchPolicy, {\n reason,\n options,\n observable: this,\n initialFetchPolicy,\n });\n } else if (reason === \"variables-changed\") {\n options.fetchPolicy = initialFetchPolicy;\n } else {\n options.fetchPolicy = options.nextFetchPolicy;\n }\n }\n\n return options.fetchPolicy;\n }\n\n private fetch(\n options: WatchQueryOptions<TVariables, TData>,\n newNetworkStatus?: NetworkStatus,\n query?: DocumentNode\n ) {\n // TODO Make sure we update the networkStatus (and infer fetchVariables)\n // before actually committing to the fetch.\n this.queryManager.setObservableQuery(this);\n return this.queryManager[\"fetchConcastWithInfo\"](\n this.queryId,\n options,\n newNetworkStatus,\n query\n );\n }\n\n // Turns polling on or off based on this.options.pollInterval.\n private updatePolling() {\n // Avoid polling in SSR mode\n if (this.queryManager.ssrMode) {\n return;\n }\n\n const {\n pollingInfo,\n options: { pollInterval },\n } = this;\n\n if (!pollInterval) {\n if (pollingInfo) {\n clearTimeout(pollingInfo.timeout);\n delete this.pollingInfo;\n }\n return;\n }\n\n if (pollingInfo && pollingInfo.interval === pollInterval) {\n return;\n }\n\n invariant(\n pollInterval,\n \"Attempted to start a polling query without a polling interval.\"\n );\n\n const info = pollingInfo || (this.pollingInfo = {} as any);\n info.interval = pollInterval;\n\n const maybeFetch = () => {\n if (this.pollingInfo) {\n if (!isNetworkRequestInFlight(this.queryInfo.networkStatus)) {\n this.reobserve(\n {\n // Most fetchPolicy options don't make sense to use in a polling context, as\n // users wouldn't want to be polling the cache directly. However, network-only and\n // no-cache are both useful for when the user wants to control whether or not the\n // polled results are written to the cache.\n fetchPolicy:\n this.options.initialFetchPolicy === \"no-cache\" ?\n \"no-cache\"\n : \"network-only\",\n },\n NetworkStatus.poll\n ).then(poll, poll);\n } else {\n poll();\n }\n }\n };\n\n const poll = () => {\n const info = this.pollingInfo;\n if (info) {\n clearTimeout(info.timeout);\n info.timeout = setTimeout(maybeFetch, info.interval);\n }\n };\n\n poll();\n }\n\n private updateLastResult(\n newResult: ApolloQueryResult<TData>,\n variables = this.variables\n ) {\n let error: ApolloError | undefined = this.getLastError();\n // Preserve this.last.error unless the variables have changed.\n if (error && this.last && !equal(variables, this.last.variables)) {\n error = void 0;\n }\n return (this.last = {\n result:\n this.queryManager.assumeImmutableResults ?\n newResult\n : cloneDeep(newResult),\n variables,\n ...(error ? { error } : null),\n });\n }\n\n public reobserveAsConcast(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus\n ): Concast<ApolloQueryResult<TData>> {\n this.isTornDown = false;\n\n const useDisposableConcast =\n // Refetching uses a disposable Concast to allow refetches using different\n // options/variables, without permanently altering the options of the\n // original ObservableQuery.\n newNetworkStatus === NetworkStatus.refetch ||\n // The fetchMore method does not actually call the reobserve method, but,\n // if it did, it would definitely use a disposable Concast.\n newNetworkStatus === NetworkStatus.fetchMore ||\n // Polling uses a disposable Concast so the polling options (which force\n // fetchPolicy to be \"network-only\" or \"no-cache\") won't override the original options.\n newNetworkStatus === NetworkStatus.poll;\n\n // Save the old variables, since Object.assign may modify them below.\n const oldVariables = this.options.variables;\n const oldFetchPolicy = this.options.fetchPolicy;\n\n const mergedOptions = compact(this.options, newOptions || {});\n const options =\n useDisposableConcast ?\n // Disposable Concast fetches receive a shallow copy of this.options\n // (merged with newOptions), leaving this.options unmodified.\n mergedOptions\n : assign(this.options, mergedOptions);\n\n // Don't update options.query with the transformed query to avoid\n // overwriting this.options.query when we aren't using a disposable concast.\n // We want to ensure we can re-run the custom document transforms the next\n // time a request is made against the original query.\n const query = this.transformDocument(options.query);\n\n this.lastQuery = query;\n\n if (!useDisposableConcast) {\n // We can skip calling updatePolling if we're not changing this.options.\n this.updatePolling();\n\n // Reset options.fetchPolicy to its original value when variables change,\n // unless a new fetchPolicy was provided by newOptions.\n if (\n newOptions &&\n newOptions.variables &&\n !equal(newOptions.variables, oldVariables) &&\n // Don't mess with the fetchPolicy if it's currently \"standby\".\n options.fetchPolicy !== \"standby\" &&\n // If we're changing the fetchPolicy anyway, don't try to change it here\n // using applyNextFetchPolicy. The explicit options.fetchPolicy wins.\n options.fetchPolicy === oldFetchPolicy\n ) {\n this.applyNextFetchPolicy(\"variables-changed\", options);\n if (newNetworkStatus === void 0) {\n newNetworkStatus = NetworkStatus.setVariables;\n }\n }\n }\n\n this.waitForOwnResult &&= skipCacheDataFor(options.fetchPolicy);\n const finishWaitingForOwnResult = () => {\n if (this.concast === concast) {\n this.waitForOwnResult = false;\n }\n };\n\n const variables = options.variables && { ...options.variables };\n const { concast, fromLink } = this.fetch(options, newNetworkStatus, query);\n const observer: Observer<ApolloQueryResult<TData>> = {\n next: (result) => {\n finishWaitingForOwnResult();\n this.reportResult(result, variables);\n },\n error: (error) => {\n finishWaitingForOwnResult();\n this.reportError(error, variables);\n },\n };\n\n if (!useDisposableConcast && (fromLink || !this.concast)) {\n // We use the {add,remove}Observer methods directly to avoid wrapping\n // observer with an unnecessary SubscriptionObserver object.\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n }\n\n this.concast = concast;\n this.observer = observer;\n }\n\n concast.addObserver(observer);\n\n return concast;\n }\n\n public reobserve(\n newOptions?: Partial<WatchQueryOptions<TVariables, TData>>,\n newNetworkStatus?: NetworkStatus\n ): Promise<ApolloQueryResult<TData>> {\n return this.reobserveAsConcast(newOptions, newNetworkStatus)\n .promise as TODO;\n }\n\n public resubscribeAfterError(\n onNext: (value: ApolloQueryResult<TData>) => void,\n onError?: (error: any) => void,\n onComplete?: () => void\n ): ObservableSubscription;\n\n public resubscribeAfterError(\n observer: Observer<ApolloQueryResult<TData>>\n ): ObservableSubscription;\n\n public resubscribeAfterError(...args: [any, any?, any?]) {\n // If `lastError` is set in the current when the subscription is re-created,\n // the subscription will immediately receive the error, which will\n // cause it to terminate again. To avoid this, we first clear\n // the last error/result from the `observableQuery` before re-starting\n // the subscription, and restore the last value afterwards so that the\n // subscription has a chance to stay open.\n const last = this.last;\n this.resetLastResults();\n\n const subscription = this.subscribe(...args);\n this.last = last;\n\n return subscription;\n }\n\n // (Re)deliver the current result to this.observers without applying fetch\n // policies or making network requests.\n private observe() {\n this.reportResult(\n // Passing false is important so that this.getCurrentResult doesn't\n // save the fetchMore result as this.lastResult, causing it to be\n // ignored due to the this.isDifferentFromLastResult check in\n // this.reportResult.\n this.getCurrentResult(false),\n this.variables\n );\n }\n\n private reportResult(\n result: ApolloQueryResult<TData>,\n variables: TVariables | undefined\n ) {\n const lastError = this.getLastError();\n const isDifferent = this.isDifferentFromLastResult(result, variables);\n // Update the last result even when isDifferentFromLastResult returns false,\n // because the query may be using the @nonreactive directive, and we want to\n // save the the latest version of any nonreactive subtrees (in case\n // getCurrentResult is called), even though we skip broadcasting changes.\n if (lastError || !result.partial || this.options.returnPartialData) {\n this.updateLastResult(result, variables);\n }\n if (lastError || isDifferent) {\n iterateObserversSafely(this.observers, \"next\", result);\n }\n }\n\n private reportError(error: ApolloError, variables: TVariables | undefined) {\n // Since we don't get the current result on errors, only the error, we\n // must mirror the updates that occur in QueryStore.markQueryError here\n const errorResult = {\n ...this.getLastResult(),\n error,\n errors: error.graphQLErrors,\n networkStatus: NetworkStatus.error,\n loading: false,\n } as ApolloQueryResult<TData>;\n\n this.updateLastResult(errorResult, variables);\n\n iterateObserversSafely(this.observers, \"error\", (this.last!.error = error));\n }\n\n public hasObservers() {\n return this.observers.size > 0;\n }\n\n private tearDownQuery() {\n if (this.isTornDown) return;\n if (this.concast && this.observer) {\n this.concast.removeObserver(this.observer);\n delete this.concast;\n delete this.observer;\n }\n\n this.stopPolling();\n // stop all active GraphQL subscriptions\n this.subscriptions.forEach((sub) => sub.unsubscribe());\n this.subscriptions.clear();\n this.queryManager.stopQuery(this.queryId);\n this.observers.clear();\n this.isTornDown = true;\n }\n\n private transformDocument(document: DocumentNode) {\n return this.queryManager.transform(document);\n }\n}\n\n// Necessary because the ObservableQuery constructor has a different\n// signature than the Observable constructor.\nfixObservableSubclass(ObservableQuery);\n\n// Reobserve with fetchPolicy effectively set to \"cache-first\", triggering\n// delivery of any new data from the cache, possibly falling back to the network\n// if any cache data are missing. This allows _complete_ cache results to be\n// delivered without also kicking off unnecessary network requests when\n// this.options.fetchPolicy is \"cache-and-network\" or \"network-only\". When\n// this.options.fetchPolicy is any other policy (\"cache-first\", \"cache-only\",\n// \"standby\", or \"no-cache\"), we call this.reobserve() as usual.\nexport function reobserveCacheFirst<TData, TVars extends OperationVariables>(\n obsQuery: ObservableQuery<TData, TVars>\n) {\n const { fetchPolicy, nextFetchPolicy } = obsQuery.options;\n\n if (fetchPolicy === \"cache-and-network\" || fetchPolicy === \"network-only\") {\n return obsQuery.reobserve({\n fetchPolicy: \"cache-first\",\n // Use a temporary nextFetchPolicy function that replaces itself with the\n // previous nextFetchPolicy value and returns the original fetchPolicy.\n nextFetchPolicy(\n this: WatchQueryOptions<TVars, TData>,\n currentFetchPolicy: WatchQueryFetchPolicy,\n context: NextFetchPolicyContext<TData, TVars>\n ) {\n // Replace this nextFetchPolicy function in the options object with the\n // original this.options.nextFetchPolicy value.\n this.nextFetchPolicy = nextFetchPolicy;\n // If the original nextFetchPolicy value was a function, give it a\n // chance to decide what happens here.\n if (typeof this.nextFetchPolicy === \"function\") {\n return this.nextFetchPolicy(currentFetchPolicy, context);\n }\n // Otherwise go back to the original this.options.fetchPolicy.\n return fetchPolicy!;\n },\n });\n }\n\n return obsQuery.reobserve();\n}\n\nfunction defaultSubscriptionObserverErrorCallback(error: ApolloError) {\n invariant.error(\"Unhandled error\", error.message, error.stack);\n}\n\nexport function logMissingFieldErrors(\n missing: MissingFieldError[] | MissingTree | undefined\n) {\n if (__DEV__ && missing) {\n invariant.debug(`Missing cache result fields: %o`, missing);\n }\n}\n\nfunction skipCacheDataFor(\n fetchPolicy?: WatchQueryFetchPolicy /* `undefined` would mean `\"cache-first\"` */\n) {\n return (\n fetchPolicy === \"network-only\" ||\n fetchPolicy === \"no-cache\" ||\n fetchPolicy === \"standby\"\n );\n}\n"]}
|
package/core/QueryInfo.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare class QueryInfo {
|
|
|
29
29
|
document: DocumentNode;
|
|
30
30
|
variables: Record<string, any> | undefined;
|
|
31
31
|
networkStatus?: NetworkStatus;
|
|
32
|
-
observableQuery?: ObservableQuery<any>;
|
|
32
|
+
observableQuery?: ObservableQuery<any, any>;
|
|
33
33
|
lastRequestId?: number;
|
|
34
34
|
}): this;
|
|
35
35
|
private dirty;
|
|
@@ -40,9 +40,9 @@ export declare class QueryInfo {
|
|
|
40
40
|
private updateLastDiff;
|
|
41
41
|
private getDiffOptions;
|
|
42
42
|
setDiff(diff: Cache.DiffResult<any> | null): void;
|
|
43
|
-
readonly observableQuery: ObservableQuery<any> | null;
|
|
43
|
+
readonly observableQuery: ObservableQuery<any, any> | null;
|
|
44
44
|
private oqListener?;
|
|
45
|
-
setObservableQuery(oq: ObservableQuery<any> | null): void;
|
|
45
|
+
setObservableQuery(oq: ObservableQuery<any, any> | null): void;
|
|
46
46
|
notify(): void;
|
|
47
47
|
private shouldNotify;
|
|
48
48
|
stop(): void;
|
package/core/QueryInfo.js
CHANGED
|
@@ -10,7 +10,13 @@ function wrapDestructiveCacheMethod(cache, methodName) {
|
|
|
10
10
|
var original = cache[methodName];
|
|
11
11
|
if (typeof original === "function") {
|
|
12
12
|
cache[methodName] = function () {
|
|
13
|
-
destructiveMethodCounts.set(cache,
|
|
13
|
+
destructiveMethodCounts.set(cache,
|
|
14
|
+
// The %1e15 allows the count to wrap around to 0 safely every
|
|
15
|
+
// quadrillion evictions, so there's no risk of overflow. To be
|
|
16
|
+
// clear, this is more of a pedantic principle than something
|
|
17
|
+
// that matters in any conceivable practical scenario.
|
|
18
|
+
(destructiveMethodCounts.get(cache) + 1) % 1e15);
|
|
19
|
+
// @ts-expect-error this is just too generic to be typed correctly
|
|
14
20
|
return original.apply(this, arguments);
|
|
15
21
|
};
|
|
16
22
|
}
|
|
@@ -21,7 +27,19 @@ function cancelNotifyTimeout(info) {
|
|
|
21
27
|
info["notifyTimeout"] = void 0;
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
|
-
|
|
30
|
+
// A QueryInfo object represents a single query managed by the
|
|
31
|
+
// QueryManager, which tracks all QueryInfo objects by queryId in its
|
|
32
|
+
// this.queries Map. QueryInfo objects store the latest results and errors
|
|
33
|
+
// for the given query, and are responsible for reporting those results to
|
|
34
|
+
// the corresponding ObservableQuery, via the QueryInfo.notify method.
|
|
35
|
+
// Results are reported asynchronously whenever setDiff marks the
|
|
36
|
+
// QueryInfo object as dirty, though a call to the QueryManager's
|
|
37
|
+
// broadcastQueries method may trigger the notification before it happens
|
|
38
|
+
// automatically. This class used to be a simple interface type without
|
|
39
|
+
// any field privacy or meaningful methods, which is why it still has so
|
|
40
|
+
// many public fields. The effort to lock down and simplify the QueryInfo
|
|
41
|
+
// interface is ongoing, and further improvements are welcome.
|
|
42
|
+
var QueryInfo = /** @class */ (function () {
|
|
25
43
|
function QueryInfo(queryManager, queryId) {
|
|
26
44
|
if (queryId === void 0) { queryId = queryManager.generateQueryId(); }
|
|
27
45
|
this.queryId = queryId;
|
|
@@ -32,6 +50,11 @@ var QueryInfo = (function () {
|
|
|
32
50
|
this.dirty = false;
|
|
33
51
|
this.observableQuery = null;
|
|
34
52
|
var cache = (this.cache = queryManager.cache);
|
|
53
|
+
// Track how often cache.evict is called, since we want eviction to
|
|
54
|
+
// override the feud-stopping logic in the markResult method, by
|
|
55
|
+
// causing shouldWrite to return true. Wrapping the cache.evict method
|
|
56
|
+
// is a bit of a hack, but it saves us from having to make eviction
|
|
57
|
+
// counting an official part of the ApolloCache API.
|
|
35
58
|
if (!destructiveMethodCounts.has(cache)) {
|
|
36
59
|
destructiveMethodCounts.set(cache, 0);
|
|
37
60
|
wrapDestructiveCacheMethod(cache, "evict");
|
|
@@ -83,12 +106,13 @@ var QueryInfo = (function () {
|
|
|
83
106
|
return diff;
|
|
84
107
|
};
|
|
85
108
|
QueryInfo.prototype.updateLastDiff = function (diff, options) {
|
|
86
|
-
this.lastDiff =
|
|
87
|
-
?
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
109
|
+
this.lastDiff =
|
|
110
|
+
diff ?
|
|
111
|
+
{
|
|
112
|
+
diff: diff,
|
|
113
|
+
options: options || this.getDiffOptions(),
|
|
114
|
+
}
|
|
115
|
+
: void 0;
|
|
92
116
|
};
|
|
93
117
|
QueryInfo.prototype.getDiffOptions = function (variables) {
|
|
94
118
|
var _a;
|
|
@@ -125,9 +149,22 @@ var QueryInfo = (function () {
|
|
|
125
149
|
this.listeners.add((this.oqListener = function () {
|
|
126
150
|
var diff = _this.getDiff();
|
|
127
151
|
if (diff.fromOptimisticTransaction) {
|
|
152
|
+
// If this diff came from an optimistic transaction, deliver the
|
|
153
|
+
// current cache data to the ObservableQuery, but don't perform a
|
|
154
|
+
// reobservation, since oq.reobserveCacheFirst might make a network
|
|
155
|
+
// request, and we never want to trigger network requests in the
|
|
156
|
+
// middle of optimistic updates.
|
|
128
157
|
oq["observe"]();
|
|
129
158
|
}
|
|
130
159
|
else {
|
|
160
|
+
// Otherwise, make the ObservableQuery "reobserve" the latest data
|
|
161
|
+
// using a temporary fetch policy of "cache-first", so complete cache
|
|
162
|
+
// results have a chance to be delivered without triggering additional
|
|
163
|
+
// network requests, even when options.fetchPolicy is "network-only"
|
|
164
|
+
// or "cache-and-network". All other fetch policies are preserved by
|
|
165
|
+
// this method, and are handled by calling oq.reobserve(). If this
|
|
166
|
+
// reobservation is spurious, isDifferentFromLastResult still has a
|
|
167
|
+
// chance to catch it before delivery to ObservableQuery subscribers.
|
|
131
168
|
reobserveCacheFirst(oq);
|
|
132
169
|
}
|
|
133
170
|
}));
|
|
@@ -159,14 +196,19 @@ var QueryInfo = (function () {
|
|
|
159
196
|
QueryInfo.prototype.stop = function () {
|
|
160
197
|
if (!this.stopped) {
|
|
161
198
|
this.stopped = true;
|
|
199
|
+
// Cancel the pending notify timeout
|
|
162
200
|
this.reset();
|
|
163
201
|
this.cancel();
|
|
202
|
+
// Revert back to the no-op version of cancel inherited from
|
|
203
|
+
// QueryInfo.prototype.
|
|
164
204
|
this.cancel = QueryInfo.prototype.cancel;
|
|
165
205
|
var oq = this.observableQuery;
|
|
166
206
|
if (oq)
|
|
167
207
|
oq.stopPolling();
|
|
168
208
|
}
|
|
169
209
|
};
|
|
210
|
+
// This method is a no-op by default, until/unless overridden by the
|
|
211
|
+
// updateWatch method.
|
|
170
212
|
QueryInfo.prototype.cancel = function () { };
|
|
171
213
|
QueryInfo.prototype.updateWatch = function (variables) {
|
|
172
214
|
var _this = this;
|
|
@@ -187,6 +229,9 @@ var QueryInfo = (function () {
|
|
|
187
229
|
QueryInfo.prototype.shouldWrite = function (result, variables) {
|
|
188
230
|
var lastWrite = this.lastWrite;
|
|
189
231
|
return !(lastWrite &&
|
|
232
|
+
// If cache.evict has been called since the last time we wrote this
|
|
233
|
+
// data into the cache, there's a chance writing this result into
|
|
234
|
+
// the cache will repair what was evicted.
|
|
190
235
|
lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
|
|
191
236
|
equal(variables, lastWrite.variables) &&
|
|
192
237
|
equal(result.data, lastWrite.result.data));
|
|
@@ -194,13 +239,18 @@ var QueryInfo = (function () {
|
|
|
194
239
|
QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
|
|
195
240
|
var _this = this;
|
|
196
241
|
var merger = new DeepMerger();
|
|
197
|
-
var graphQLErrors = isNonEmptyArray(result.errors)
|
|
198
|
-
|
|
199
|
-
|
|
242
|
+
var graphQLErrors = isNonEmptyArray(result.errors) ? result.errors.slice(0) : [];
|
|
243
|
+
// Cancel the pending notify timeout (if it exists) to prevent extraneous network
|
|
244
|
+
// requests. To allow future notify timeouts, diff and dirty are reset as well.
|
|
200
245
|
this.reset();
|
|
201
246
|
if ("incremental" in result && isNonEmptyArray(result.incremental)) {
|
|
202
247
|
var mergedData = mergeIncrementalData(this.getDiff().result, result);
|
|
203
248
|
result.data = mergedData;
|
|
249
|
+
// Detect the first chunk of a deferred query and merge it with existing
|
|
250
|
+
// cache data. This ensures a `cache-first` fetch policy that returns
|
|
251
|
+
// partial cache data or a `cache-and-network` fetch policy that already
|
|
252
|
+
// has full data in the cache does not complain when trying to merge the
|
|
253
|
+
// initial deferred server data with existing cache data.
|
|
204
254
|
}
|
|
205
255
|
else if ("hasNext" in result && result.hasNext) {
|
|
206
256
|
var diff = this.getDiff();
|
|
@@ -210,15 +260,19 @@ var QueryInfo = (function () {
|
|
|
210
260
|
if (options.fetchPolicy === "no-cache") {
|
|
211
261
|
this.updateLastDiff({ result: result.data, complete: true }, this.getDiffOptions(options.variables));
|
|
212
262
|
}
|
|
213
|
-
else if (cacheWriteBehavior !== 0) {
|
|
263
|
+
else if (cacheWriteBehavior !== 0 /* CacheWriteBehavior.FORBID */) {
|
|
214
264
|
if (shouldWriteResult(result, options.errorPolicy)) {
|
|
265
|
+
// Using a transaction here so we have a chance to read the result
|
|
266
|
+
// back from the cache before the watch callback fires as a result
|
|
267
|
+
// of writeQuery, so we can store the new diff quietly and ignore
|
|
268
|
+
// it when we receive it redundantly from the watch callback.
|
|
215
269
|
this.cache.performTransaction(function (cache) {
|
|
216
270
|
if (_this.shouldWrite(result, options.variables)) {
|
|
217
271
|
cache.writeQuery({
|
|
218
272
|
query: document,
|
|
219
273
|
data: result.data,
|
|
220
274
|
variables: options.variables,
|
|
221
|
-
overwrite: cacheWriteBehavior === 1
|
|
275
|
+
overwrite: cacheWriteBehavior === 1 /* CacheWriteBehavior.OVERWRITE */,
|
|
222
276
|
});
|
|
223
277
|
_this.lastWrite = {
|
|
224
278
|
result: result,
|
|
@@ -227,16 +281,65 @@ var QueryInfo = (function () {
|
|
|
227
281
|
};
|
|
228
282
|
}
|
|
229
283
|
else {
|
|
284
|
+
// If result is the same as the last result we received from
|
|
285
|
+
// the network (and the variables match too), avoid writing
|
|
286
|
+
// result into the cache again. The wisdom of skipping this
|
|
287
|
+
// cache write is far from obvious, since any cache write
|
|
288
|
+
// could be the one that puts the cache back into a desired
|
|
289
|
+
// state, fixing corruption or missing data. However, if we
|
|
290
|
+
// always write every network result into the cache, we enable
|
|
291
|
+
// feuds between queries competing to update the same data in
|
|
292
|
+
// incompatible ways, which can lead to an endless cycle of
|
|
293
|
+
// cache broadcasts and useless network requests. As with any
|
|
294
|
+
// feud, eventually one side must step back from the brink,
|
|
295
|
+
// letting the other side(s) have the last word(s). There may
|
|
296
|
+
// be other points where we could break this cycle, such as
|
|
297
|
+
// silencing the broadcast for cache.writeQuery (not a good
|
|
298
|
+
// idea, since it just delays the feud a bit) or somehow
|
|
299
|
+
// avoiding the network request that just happened (also bad,
|
|
300
|
+
// because the server could return useful new data). All
|
|
301
|
+
// options considered, skipping this cache write seems to be
|
|
302
|
+
// the least damaging place to break the cycle, because it
|
|
303
|
+
// reflects the intuition that we recently wrote this exact
|
|
304
|
+
// result into the cache, so the cache *should* already/still
|
|
305
|
+
// contain this data. If some other query has clobbered that
|
|
306
|
+
// data in the meantime, that's too bad, but there will be no
|
|
307
|
+
// winners if every query blindly reverts to its own version
|
|
308
|
+
// of the data. This approach also gives the network a chance
|
|
309
|
+
// to return new data, which will be written into the cache as
|
|
310
|
+
// usual, notifying only those queries that are directly
|
|
311
|
+
// affected by the cache updates, as usual. In the future, an
|
|
312
|
+
// even more sophisticated cache could perhaps prevent or
|
|
313
|
+
// mitigate the clobbering somehow, but that would make this
|
|
314
|
+
// particular cache write even less important, and thus
|
|
315
|
+
// skipping it would be even safer than it is today.
|
|
230
316
|
if (_this.lastDiff && _this.lastDiff.diff.complete) {
|
|
317
|
+
// Reuse data from the last good (complete) diff that we
|
|
318
|
+
// received, when possible.
|
|
231
319
|
result.data = _this.lastDiff.diff.result;
|
|
232
320
|
return;
|
|
233
321
|
}
|
|
322
|
+
// If the previous this.diff was incomplete, fall through to
|
|
323
|
+
// re-reading the latest data with cache.diff, below.
|
|
234
324
|
}
|
|
235
325
|
var diffOptions = _this.getDiffOptions(options.variables);
|
|
236
326
|
var diff = cache.diff(diffOptions);
|
|
327
|
+
// In case the QueryManager stops this QueryInfo before its
|
|
328
|
+
// results are delivered, it's important to avoid restarting the
|
|
329
|
+
// cache watch when markResult is called. We also avoid updating
|
|
330
|
+
// the watch if we are writing a result that doesn't match the current
|
|
331
|
+
// variables to avoid race conditions from broadcasting the wrong
|
|
332
|
+
// result.
|
|
237
333
|
if (!_this.stopped && equal(_this.variables, options.variables)) {
|
|
334
|
+
// Any time we're about to update this.diff, we need to make
|
|
335
|
+
// sure we've started watching the cache.
|
|
238
336
|
_this.updateWatch(options.variables);
|
|
239
337
|
}
|
|
338
|
+
// If we're allowed to write to the cache, and we can read a
|
|
339
|
+
// complete result from the cache, update result.data to be the
|
|
340
|
+
// result from the cache, rather than the raw network result.
|
|
341
|
+
// Set without setDiff to avoid triggering a notify call, since
|
|
342
|
+
// we have other ways of notifying for this result.
|
|
240
343
|
_this.updateLastDiff(diff, diffOptions);
|
|
241
344
|
if (diff.complete) {
|
|
242
345
|
result.data = diff.result;
|