@apollo/client 3.8.0 → 3.8.2
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/apollo-client.cjs +715 -587
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +253 -191
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +253 -191
- package/cache/core/cache.d.ts +4 -4
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js +10 -7
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +3 -3
- package/cache/core/types/Cache.d.ts.map +1 -1
- package/cache/core/types/Cache.js +0 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +6 -6
- package/cache/core/types/DataProxy.d.ts.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +3 -3
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/index.d.ts +20 -20
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +13 -13
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +6 -6
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +38 -30
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fixPolyfills.native.d.ts.map +1 -1
- package/cache/inmemory/fixPolyfills.native.js +10 -9
- package/cache/inmemory/fixPolyfills.native.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +6 -4
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +6 -6
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +16 -14
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -9
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +29 -33
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.d.ts.map +1 -1
- package/cache/inmemory/key-extractor.js +55 -49
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +5 -5
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts +6 -6
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +74 -45
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.d.ts.map +1 -1
- package/cache/inmemory/reactiveVars.js +5 -5
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +7 -7
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +21 -17
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +7 -7
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/types.js +0 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +7 -7
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +40 -30
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/setup.d.ts +2 -2
- package/config/jest/setup.js +5 -5
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +11 -11
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +64 -50
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +6 -6
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +17 -16
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +12 -10
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +57 -38
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +11 -11
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +28 -34
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +10 -10
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +117 -93
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +255 -199
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +255 -199
- package/core/networkStatus.js.map +1 -1
- package/core/types.d.ts +13 -13
- package/core/types.d.ts.map +1 -1
- package/core/types.js +0 -1
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +11 -11
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +44 -40
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +44 -40
- package/errors/errors.cjs +7 -5
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +7 -5
- package/errors/index.d.ts +4 -4
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +9 -7
- package/errors/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/invariantErrorCodes.d.ts.map +1 -1
- package/invariantErrorCodes.js +36 -36
- package/invariantErrorCodes.js.map +1 -1
- package/link/batch/batch.cjs +4 -4
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +4 -4
- package/link/batch/batchLink.d.ts +6 -6
- package/link/batch/batchLink.d.ts.map +1 -1
- package/link/batch/batchLink.js +4 -4
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +2 -2
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +4 -4
- package/link/batch/batching.js.map +1 -1
- package/link/batch/index.d.ts +1 -1
- package/link/batch/index.js +1 -1
- package/link/batch/index.js.map +1 -1
- package/link/batch-http/batch-http.cjs +13 -11
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +13 -11
- package/link/batch-http/batchHttpLink.d.ts +6 -6
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +17 -15
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +1 -1
- package/link/batch-http/index.js +1 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/context/context.cjs.map +1 -1
- package/link/context/index.d.ts +3 -3
- package/link/context/index.js +2 -2
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +3 -3
- package/link/core/ApolloLink.js +4 -4
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/concat.d.ts +1 -1
- package/link/core/concat.js +1 -1
- package/link/core/concat.js.map +1 -1
- package/link/core/core.cjs +1 -1
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +1 -1
- package/link/core/empty.d.ts +1 -1
- package/link/core/empty.js +1 -1
- package/link/core/empty.js.map +1 -1
- package/link/core/execute.d.ts +1 -1
- package/link/core/execute.js +1 -1
- package/link/core/execute.js.map +1 -1
- package/link/core/from.d.ts +1 -1
- package/link/core/from.js +1 -1
- package/link/core/from.js.map +1 -1
- package/link/core/index.d.ts +8 -8
- package/link/core/index.js +8 -8
- package/link/core/index.js.map +1 -1
- package/link/core/split.d.ts +1 -1
- package/link/core/split.js +1 -1
- package/link/core/split.js.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/error/error.cjs.map +1 -1
- package/link/error/index.d.ts +5 -5
- package/link/error/index.js +2 -2
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +3 -3
- package/link/http/HttpLink.js +2 -2
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.d.ts +1 -1
- package/link/http/checkFetcher.d.ts.map +1 -1
- package/link/http/checkFetcher.js +2 -2
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.d.ts +2 -2
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +27 -26
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/createSignalIfSupported.js +1 -1
- package/link/http/createSignalIfSupported.js.map +1 -1
- package/link/http/http.cjs +64 -41
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +64 -41
- package/link/http/index.d.ts +13 -13
- package/link/http/index.js +10 -10
- package/link/http/index.js.map +1 -1
- package/link/http/iterators/nodeStream.d.ts.map +1 -1
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +2 -2
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts.map +1 -1
- package/link/http/responseIterator.js +20 -1
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +1 -1
- package/link/http/rewriteURIForGET.js +12 -12
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +5 -5
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +8 -7
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.d.ts +1 -1
- package/link/http/selectURI.js +2 -2
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.d.ts +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts +4 -4
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +26 -25
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +22 -17
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +22 -17
- package/link/retry/delayFunction.d.ts +1 -1
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/index.d.ts +1 -1
- package/link/retry/index.js +1 -1
- package/link/retry/index.js.map +1 -1
- package/link/retry/retry.cjs +2 -2
- package/link/retry/retry.cjs.map +1 -1
- package/link/retry/retry.cjs.native.js +2 -2
- package/link/retry/retryFunction.d.ts +1 -1
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.d.ts +5 -5
- package/link/retry/retryLink.d.ts.map +1 -1
- package/link/retry/retryLink.js +6 -6
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +4 -4
- package/link/schema/index.d.ts.map +1 -1
- package/link/schema/index.js +13 -8
- package/link/schema/index.js.map +1 -1
- package/link/schema/schema.cjs +10 -5
- package/link/schema/schema.cjs.map +1 -1
- package/link/schema/schema.cjs.native.js +10 -5
- package/link/subscriptions/index.js +1 -1
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/utils/createOperation.d.ts +1 -1
- package/link/utils/createOperation.js +3 -3
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/filterOperationVariables.d.ts +1 -1
- package/link/utils/filterOperationVariables.js +2 -2
- package/link/utils/filterOperationVariables.js.map +1 -1
- package/link/utils/fromError.d.ts +1 -1
- package/link/utils/fromError.js +1 -1
- package/link/utils/fromError.js.map +1 -1
- package/link/utils/fromPromise.d.ts +1 -1
- package/link/utils/fromPromise.js +1 -1
- package/link/utils/fromPromise.js.map +1 -1
- package/link/utils/index.d.ts +10 -10
- package/link/utils/index.js +9 -9
- package/link/utils/index.js.map +1 -1
- package/link/utils/throwServerError.js +1 -1
- package/link/utils/throwServerError.js.map +1 -1
- package/link/utils/toPromise.d.ts +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/transformOperation.d.ts +1 -1
- package/link/utils/transformOperation.js +3 -3
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +12 -12
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +12 -12
- package/link/utils/validateOperation.d.ts +1 -1
- package/link/utils/validateOperation.js +6 -6
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +5 -5
- package/link/ws/index.js +2 -2
- package/link/ws/index.js.map +1 -1
- package/link/ws/ws.cjs.map +1 -1
- package/package.json +27 -27
- package/react/cache/QueryReference.d.ts +1 -1
- package/react/cache/QueryReference.d.ts.map +1 -1
- package/react/cache/QueryReference.js +2 -0
- package/react/cache/QueryReference.js.map +1 -1
- package/react/hooks/constants.js +1 -1
- package/react/hooks/constants.js.map +1 -1
- package/react/hooks/hooks.cjs +10 -21
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +10 -21
- package/react/hooks/useBackgroundQuery.d.ts +1 -1
- package/react/hooks/useBackgroundQuery.d.ts.map +1 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +1 -8
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts.map +1 -1
- package/react/hooks/useReactiveVar.js +7 -12
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.d.ts.map +1 -1
- package/react/hooks/useReadQuery.js +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +1 -1
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/react.cjs +2 -0
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +2 -0
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +37 -28
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +37 -28
- package/testing/core/itAsync.d.ts.map +1 -1
- package/testing/core/itAsync.js +8 -4
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockClient.d.ts +3 -3
- package/testing/core/mocking/mockClient.d.ts.map +1 -1
- package/testing/core/mocking/mockClient.js +6 -4
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockFetch.d.ts +1 -1
- package/testing/core/mocking/mockFetch.d.ts.map +1 -1
- package/testing/core/mocking/mockFetch.js +3 -3
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +3 -3
- package/testing/core/mocking/mockLink.d.ts.map +1 -1
- package/testing/core/mocking/mockLink.js +24 -23
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +2 -2
- package/testing/core/mocking/mockQueryManager.js +3 -3
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -3
- package/testing/core/mocking/mockSubscriptionLink.js +4 -4
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts +2 -2
- package/testing/core/mocking/mockWatchQuery.js +2 -2
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +3 -3
- package/testing/core/observableToPromise.d.ts.map +1 -1
- package/testing/core/observableToPromise.js +8 -4
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/subscribeAndCount.d.ts +1 -1
- package/testing/core/subscribeAndCount.d.ts.map +1 -1
- package/testing/core/subscribeAndCount.js +5 -3
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/core/wait.js.map +1 -1
- package/testing/core/withConsoleSpy.d.ts.map +1 -1
- package/testing/core/withConsoleSpy.js.map +1 -1
- package/testing/core/wrap.d.ts.map +1 -1
- package/testing/core/wrap.js +14 -12
- package/testing/core/wrap.js.map +1 -1
- package/testing/index.d.ts +4 -4
- package/testing/index.js +3 -3
- package/testing/index.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +7 -7
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +10 -11
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +3 -5
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +3 -5
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +4 -5
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/cloneDeep.js +2 -2
- package/utilities/common/cloneDeep.js.map +1 -1
- package/utilities/common/compact.d.ts +1 -1
- package/utilities/common/compact.js.map +1 -1
- package/utilities/common/filterInPlace.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +1 -1
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeDeep.js +3 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/objects.js +2 -2
- package/utilities/common/objects.js.map +1 -1
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -1
- package/utilities/common/stringifyForDisplay.js +3 -1
- package/utilities/common/stringifyForDisplay.js.map +1 -1
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js +3 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +8 -4
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +8 -4
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +1 -1
- package/utilities/globals/index.js.map +1 -1
- package/utilities/globals/invariantWrappers.js +1 -1
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/globals/maybe.d.ts.map +1 -1
- package/utilities/globals/maybe.js.map +1 -1
- package/utilities/graphql/directives.d.ts +1 -1
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +17 -13
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +12 -12
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +1 -1
- package/utilities/graphql/getFromAST.js +16 -16
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +2 -2
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +36 -34
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +48 -32
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +0 -1
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +0 -1
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +5 -9
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/Observable.d.ts +4 -4
- package/utilities/observables/Observable.d.ts.map +1 -1
- package/utilities/observables/Observable.js +6 -4
- package/utilities/observables/Observable.js.map +1 -1
- package/utilities/observables/asyncMap.d.ts.map +1 -1
- package/utilities/observables/asyncMap.js +5 -2
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/observables/iteration.js.map +1 -1
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +9 -7
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/types/IsStrictlyAny.d.ts +2 -2
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -1
- package/utilities/types/IsStrictlyAny.js.map +1 -1
- package/utilities/utilities.cjs +147 -147
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +147 -147
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/utilities/common/responseIterator.d.ts +0 -10
- package/utilities/common/responseIterator.d.ts.map +0 -1
- package/utilities/common/responseIterator.js +0 -21
- package/utilities/common/responseIterator.js.map +0 -1
package/core/QueryManager.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
|
-
import { invariant, newInvariantError } from
|
|
3
|
-
import { equal } from
|
|
4
|
-
import { execute } from
|
|
5
|
-
import { hasDirectives, isExecutionPatchIncrementalResult, isExecutionPatchResult, removeDirectivesFromDocument, } from
|
|
6
|
-
import { canonicalStringify } from
|
|
7
|
-
import { getDefaultValues, getOperationDefinition, getOperationName, hasClientExports, graphQLResultHasError, getGraphQLErrorsFromResult, canUseWeakMap, Observable, asyncMap, isNonEmptyArray, Concast, makeUniqueId, isDocumentNode, isNonNullObject, DocumentTransform, } from
|
|
8
|
-
import { mergeIncrementalData } from
|
|
9
|
-
import { ApolloError, isApolloError, graphQLResultHasProtocolErrors } from
|
|
10
|
-
import { ObservableQuery, logMissingFieldErrors } from
|
|
11
|
-
import { NetworkStatus, isNetworkRequestInFlight } from
|
|
12
|
-
import { LocalState } from
|
|
13
|
-
import { QueryInfo, shouldWriteResult, } from
|
|
14
|
-
import { PROTOCOL_ERRORS_SYMBOL } from
|
|
15
|
-
import { print } from
|
|
2
|
+
import { invariant, newInvariantError } from "../utilities/globals/index.js";
|
|
3
|
+
import { equal } from "@wry/equality";
|
|
4
|
+
import { execute } from "../link/core/index.js";
|
|
5
|
+
import { hasDirectives, isExecutionPatchIncrementalResult, isExecutionPatchResult, removeDirectivesFromDocument, } from "../utilities/index.js";
|
|
6
|
+
import { canonicalStringify } from "../cache/index.js";
|
|
7
|
+
import { getDefaultValues, getOperationDefinition, getOperationName, hasClientExports, graphQLResultHasError, getGraphQLErrorsFromResult, canUseWeakMap, Observable, asyncMap, isNonEmptyArray, Concast, makeUniqueId, isDocumentNode, isNonNullObject, DocumentTransform, } from "../utilities/index.js";
|
|
8
|
+
import { mergeIncrementalData } from "../utilities/common/incrementalResult.js";
|
|
9
|
+
import { ApolloError, isApolloError, graphQLResultHasProtocolErrors, } from "../errors/index.js";
|
|
10
|
+
import { ObservableQuery, logMissingFieldErrors } from "./ObservableQuery.js";
|
|
11
|
+
import { NetworkStatus, isNetworkRequestInFlight } from "./networkStatus.js";
|
|
12
|
+
import { LocalState } from "./LocalState.js";
|
|
13
|
+
import { QueryInfo, shouldWriteResult, } from "./QueryInfo.js";
|
|
14
|
+
import { PROTOCOL_ERRORS_SYMBOL } from "../errors/index.js";
|
|
15
|
+
import { print } from "../utilities/index.js";
|
|
16
16
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
17
17
|
var QueryManager = (function () {
|
|
18
18
|
function QueryManager(_a) {
|
|
19
|
-
var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, documentTransform = _a.documentTransform, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, _e = _a.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? !!cache.assumeImmutableResults : _e;
|
|
20
19
|
var _this = this;
|
|
20
|
+
var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, documentTransform = _a.documentTransform, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, _e = _a.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? !!cache.assumeImmutableResults : _e;
|
|
21
21
|
this.clientAwareness = {};
|
|
22
22
|
this.queries = new Map();
|
|
23
23
|
this.fetchCancelFns = new Map();
|
|
@@ -64,8 +64,7 @@ var QueryManager = (function () {
|
|
|
64
64
|
switch (_h.label) {
|
|
65
65
|
case 0:
|
|
66
66
|
invariant(mutation, 24);
|
|
67
|
-
invariant(fetchPolicy ===
|
|
68
|
-
fetchPolicy === 'no-cache', 25);
|
|
67
|
+
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 25);
|
|
69
68
|
mutationId = this.generateMutationId();
|
|
70
69
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
71
70
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -100,7 +99,7 @@ var QueryManager = (function () {
|
|
|
100
99
|
self = this;
|
|
101
100
|
return [2, new Promise(function (resolve, reject) {
|
|
102
101
|
return asyncMap(self.getObservableFromLink(mutation, __assign(__assign({}, context), { optimisticResponse: optimisticResponse }), variables, false), function (result) {
|
|
103
|
-
if (graphQLResultHasError(result) && errorPolicy ===
|
|
102
|
+
if (graphQLResultHasError(result) && errorPolicy === "none") {
|
|
104
103
|
throw new ApolloError({
|
|
105
104
|
graphQLErrors: getGraphQLErrorsFromResult(result),
|
|
106
105
|
});
|
|
@@ -113,8 +112,7 @@ var QueryManager = (function () {
|
|
|
113
112
|
if (typeof refetchQueries === "function") {
|
|
114
113
|
refetchQueries = refetchQueries(storeResult);
|
|
115
114
|
}
|
|
116
|
-
if (errorPolicy ===
|
|
117
|
-
graphQLResultHasError(storeResult)) {
|
|
115
|
+
if (errorPolicy === "ignore" && graphQLResultHasError(storeResult)) {
|
|
118
116
|
delete storeResult.errors;
|
|
119
117
|
}
|
|
120
118
|
return self.markMutationResult({
|
|
@@ -136,7 +134,7 @@ var QueryManager = (function () {
|
|
|
136
134
|
}).subscribe({
|
|
137
135
|
next: function (storeResult) {
|
|
138
136
|
self.broadcastQueries();
|
|
139
|
-
if (!(
|
|
137
|
+
if (!("hasNext" in storeResult) || storeResult.hasNext === false) {
|
|
140
138
|
resolve(storeResult);
|
|
141
139
|
}
|
|
142
140
|
},
|
|
@@ -149,9 +147,11 @@ var QueryManager = (function () {
|
|
|
149
147
|
self.cache.removeOptimistic(mutationId);
|
|
150
148
|
}
|
|
151
149
|
self.broadcastQueries();
|
|
152
|
-
reject(err instanceof ApolloError
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
reject(err instanceof ApolloError
|
|
151
|
+
? err
|
|
152
|
+
: new ApolloError({
|
|
153
|
+
networkError: err,
|
|
154
|
+
}));
|
|
155
155
|
},
|
|
156
156
|
});
|
|
157
157
|
})];
|
|
@@ -169,12 +169,13 @@ var QueryManager = (function () {
|
|
|
169
169
|
if (!isExecutionPatchIncrementalResult(result)) {
|
|
170
170
|
cacheWrites.push({
|
|
171
171
|
result: result.data,
|
|
172
|
-
dataId:
|
|
172
|
+
dataId: "ROOT_MUTATION",
|
|
173
173
|
query: mutation.document,
|
|
174
174
|
variables: mutation.variables,
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
-
if (isExecutionPatchIncrementalResult(result) &&
|
|
177
|
+
if (isExecutionPatchIncrementalResult(result) &&
|
|
178
|
+
isNonEmptyArray(result.incremental)) {
|
|
178
179
|
var diff = cache.diff({
|
|
179
180
|
id: "ROOT_MUTATION",
|
|
180
181
|
query: this.getDocumentInfo(mutation.document).asQuery,
|
|
@@ -186,11 +187,11 @@ var QueryManager = (function () {
|
|
|
186
187
|
if (diff.result) {
|
|
187
188
|
mergedData = mergeIncrementalData(diff.result, result);
|
|
188
189
|
}
|
|
189
|
-
if (typeof mergedData !==
|
|
190
|
+
if (typeof mergedData !== "undefined") {
|
|
190
191
|
result.data = mergedData;
|
|
191
192
|
cacheWrites.push({
|
|
192
193
|
result: mergedData,
|
|
193
|
-
dataId:
|
|
194
|
+
dataId: "ROOT_MUTATION",
|
|
194
195
|
query: mutation.document,
|
|
195
196
|
variables: mutation.variables,
|
|
196
197
|
});
|
|
@@ -215,13 +216,13 @@ var QueryManager = (function () {
|
|
|
215
216
|
if (complete && currentQueryResult) {
|
|
216
217
|
var nextQueryResult = updater(currentQueryResult, {
|
|
217
218
|
mutationResult: result,
|
|
218
|
-
queryName: document && getOperationName(document) || void 0,
|
|
219
|
+
queryName: (document && getOperationName(document)) || void 0,
|
|
219
220
|
queryVariables: variables,
|
|
220
221
|
});
|
|
221
222
|
if (nextQueryResult) {
|
|
222
223
|
cacheWrites.push({
|
|
223
224
|
result: nextQueryResult,
|
|
224
|
-
dataId:
|
|
225
|
+
dataId: "ROOT_QUERY",
|
|
225
226
|
query: document,
|
|
226
227
|
variables: variables,
|
|
227
228
|
});
|
|
@@ -255,10 +256,10 @@ var QueryManager = (function () {
|
|
|
255
256
|
});
|
|
256
257
|
if (diff.complete) {
|
|
257
258
|
result = __assign(__assign({}, result), { data: diff.result });
|
|
258
|
-
if (
|
|
259
|
+
if ("incremental" in result) {
|
|
259
260
|
delete result.incremental;
|
|
260
261
|
}
|
|
261
|
-
if (
|
|
262
|
+
if ("hasNext" in result) {
|
|
262
263
|
delete result.hasNext;
|
|
263
264
|
}
|
|
264
265
|
}
|
|
@@ -272,7 +273,7 @@ var QueryManager = (function () {
|
|
|
272
273
|
}
|
|
273
274
|
if (!skipCache && !mutation.keepRootFields && isFinalResult) {
|
|
274
275
|
cache.modify({
|
|
275
|
-
id:
|
|
276
|
+
id: "ROOT_MUTATION",
|
|
276
277
|
fields: function (value, _a) {
|
|
277
278
|
var fieldName = _a.fieldName, DELETE = _a.DELETE;
|
|
278
279
|
return fieldName === "__typename" ? value : DELETE;
|
|
@@ -306,7 +307,8 @@ var QueryManager = (function () {
|
|
|
306
307
|
}, mutation.mutationId);
|
|
307
308
|
};
|
|
308
309
|
QueryManager.prototype.fetchQuery = function (queryId, options, networkStatus) {
|
|
309
|
-
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast
|
|
310
|
+
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast
|
|
311
|
+
.promise;
|
|
310
312
|
};
|
|
311
313
|
QueryManager.prototype.getQueryStore = function () {
|
|
312
314
|
var store = Object.create(null);
|
|
@@ -336,12 +338,12 @@ var QueryManager = (function () {
|
|
|
336
338
|
var cacheEntry = {
|
|
337
339
|
hasClientExports: hasClientExports(document),
|
|
338
340
|
hasForcedResolvers: this.localState.shouldForceResolvers(document),
|
|
339
|
-
hasNonreactiveDirective: hasDirectives([
|
|
341
|
+
hasNonreactiveDirective: hasDirectives(["nonreactive"], document),
|
|
340
342
|
clientQuery: this.localState.clientQuery(document),
|
|
341
343
|
serverQuery: removeDirectivesFromDocument([
|
|
342
|
-
{ name:
|
|
343
|
-
{ name:
|
|
344
|
-
{ name:
|
|
344
|
+
{ name: "client", remove: true },
|
|
345
|
+
{ name: "connection" },
|
|
346
|
+
{ name: "nonreactive" },
|
|
345
347
|
], document),
|
|
346
348
|
defaultVars: getDefaultValues(getOperationDefinition(document)),
|
|
347
349
|
asQuery: __assign(__assign({}, document), { definitions: document.definitions.map(function (def) {
|
|
@@ -350,7 +352,7 @@ var QueryManager = (function () {
|
|
|
350
352
|
return __assign(__assign({}, def), { operation: "query" });
|
|
351
353
|
}
|
|
352
354
|
return def;
|
|
353
|
-
}) })
|
|
355
|
+
}) }),
|
|
354
356
|
};
|
|
355
357
|
transformCache.set(document, cacheEntry);
|
|
356
358
|
}
|
|
@@ -362,7 +364,7 @@ var QueryManager = (function () {
|
|
|
362
364
|
QueryManager.prototype.watchQuery = function (options) {
|
|
363
365
|
var query = this.transform(options.query);
|
|
364
366
|
options = __assign(__assign({}, options), { variables: this.getVariables(query, options.variables) });
|
|
365
|
-
if (typeof options.notifyOnNetworkStatusChange ===
|
|
367
|
+
if (typeof options.notifyOnNetworkStatusChange === "undefined") {
|
|
366
368
|
options.notifyOnNetworkStatusChange = false;
|
|
367
369
|
}
|
|
368
370
|
var queryInfo = new QueryInfo(this);
|
|
@@ -371,7 +373,7 @@ var QueryManager = (function () {
|
|
|
371
373
|
queryInfo: queryInfo,
|
|
372
374
|
options: options,
|
|
373
375
|
});
|
|
374
|
-
observable[
|
|
376
|
+
observable["lastQuery"] = query;
|
|
375
377
|
this.queries.set(observable.queryId, queryInfo);
|
|
376
378
|
queryInfo.init({
|
|
377
379
|
document: query,
|
|
@@ -384,7 +386,7 @@ var QueryManager = (function () {
|
|
|
384
386
|
var _this = this;
|
|
385
387
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
386
388
|
invariant(options.query, 26);
|
|
387
|
-
invariant(options.query.kind ===
|
|
389
|
+
invariant(options.query.kind === "Document", 27);
|
|
388
390
|
invariant(!options.returnPartialData, 28);
|
|
389
391
|
invariant(!options.pollInterval, 29);
|
|
390
392
|
return this.fetchQuery(queryId, __assign(__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
|
|
@@ -501,8 +503,7 @@ var QueryManager = (function () {
|
|
|
501
503
|
var fetchPolicy = observableQuery.options.fetchPolicy;
|
|
502
504
|
observableQuery.resetLastResults();
|
|
503
505
|
if (includeStandby ||
|
|
504
|
-
(fetchPolicy !== "standby" &&
|
|
505
|
-
fetchPolicy !== "cache-only")) {
|
|
506
|
+
(fetchPolicy !== "standby" && fetchPolicy !== "cache-only")) {
|
|
506
507
|
observableQueryPromises.push(observableQuery.refetch());
|
|
507
508
|
}
|
|
508
509
|
_this.getQuery(queryId).setDiff(null);
|
|
@@ -515,17 +516,17 @@ var QueryManager = (function () {
|
|
|
515
516
|
};
|
|
516
517
|
QueryManager.prototype.startGraphQLSubscription = function (_a) {
|
|
517
518
|
var _this = this;
|
|
518
|
-
var query = _a.query, fetchPolicy = _a.fetchPolicy,
|
|
519
|
+
var query = _a.query, fetchPolicy = _a.fetchPolicy, _b = _a.errorPolicy, errorPolicy = _b === void 0 ? "none" : _b, variables = _a.variables, _c = _a.context, context = _c === void 0 ? {} : _c;
|
|
519
520
|
query = this.transform(query);
|
|
520
521
|
variables = this.getVariables(query, variables);
|
|
521
522
|
var makeObservable = function (variables) {
|
|
522
523
|
return _this.getObservableFromLink(query, context, variables).map(function (result) {
|
|
523
|
-
if (fetchPolicy !==
|
|
524
|
+
if (fetchPolicy !== "no-cache") {
|
|
524
525
|
if (shouldWriteResult(result, errorPolicy)) {
|
|
525
526
|
_this.cache.write({
|
|
526
527
|
query: query,
|
|
527
528
|
result: result.data,
|
|
528
|
-
dataId:
|
|
529
|
+
dataId: "ROOT_SUBSCRIPTION",
|
|
529
530
|
variables: variables,
|
|
530
531
|
});
|
|
531
532
|
}
|
|
@@ -541,16 +542,23 @@ var QueryManager = (function () {
|
|
|
541
542
|
if (hasProtocolErrors) {
|
|
542
543
|
errors.protocolErrors = result.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
543
544
|
}
|
|
544
|
-
|
|
545
|
+
if (errorPolicy === "none" || hasProtocolErrors) {
|
|
546
|
+
throw new ApolloError(errors);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (errorPolicy === "ignore") {
|
|
550
|
+
delete result.errors;
|
|
545
551
|
}
|
|
546
552
|
return result;
|
|
547
553
|
});
|
|
548
554
|
};
|
|
549
555
|
if (this.getDocumentInfo(query).hasClientExports) {
|
|
550
|
-
var observablePromise_1 = this.localState
|
|
556
|
+
var observablePromise_1 = this.localState
|
|
557
|
+
.addExportedVariables(query, variables, context)
|
|
558
|
+
.then(makeObservable);
|
|
551
559
|
return new Observable(function (observer) {
|
|
552
560
|
var sub = null;
|
|
553
|
-
observablePromise_1.then(function (observable) { return sub = observable.subscribe(observer); }, observer.error);
|
|
561
|
+
observablePromise_1.then(function (observable) { return (sub = observable.subscribe(observer)); }, observer.error);
|
|
554
562
|
return function () { return sub && sub.unsubscribe(); };
|
|
555
563
|
});
|
|
556
564
|
}
|
|
@@ -602,12 +610,11 @@ var QueryManager = (function () {
|
|
|
602
610
|
observable = byVariables_1.get(varJson_1);
|
|
603
611
|
if (!observable) {
|
|
604
612
|
var concast = new Concast([
|
|
605
|
-
execute(link, operation)
|
|
613
|
+
execute(link, operation),
|
|
606
614
|
]);
|
|
607
|
-
byVariables_1.set(varJson_1, observable = concast);
|
|
615
|
+
byVariables_1.set(varJson_1, (observable = concast));
|
|
608
616
|
concast.beforeNext(function () {
|
|
609
|
-
if (byVariables_1.delete(varJson_1) &&
|
|
610
|
-
byVariables_1.size < 1) {
|
|
617
|
+
if (byVariables_1.delete(varJson_1) && byVariables_1.size < 1) {
|
|
611
618
|
inFlightLinkObservables_1.delete(printedServerQuery_1);
|
|
612
619
|
}
|
|
613
620
|
});
|
|
@@ -615,14 +622,12 @@ var QueryManager = (function () {
|
|
|
615
622
|
}
|
|
616
623
|
else {
|
|
617
624
|
observable = new Concast([
|
|
618
|
-
execute(link, operation)
|
|
625
|
+
execute(link, operation),
|
|
619
626
|
]);
|
|
620
627
|
}
|
|
621
628
|
}
|
|
622
629
|
else {
|
|
623
|
-
observable = new Concast([
|
|
624
|
-
Observable.of({ data: {} })
|
|
625
|
-
]);
|
|
630
|
+
observable = new Concast([Observable.of({ data: {} })]);
|
|
626
631
|
context = this.prepareContext(context);
|
|
627
632
|
}
|
|
628
633
|
if (clientQuery) {
|
|
@@ -638,7 +643,7 @@ var QueryManager = (function () {
|
|
|
638
643
|
return observable;
|
|
639
644
|
};
|
|
640
645
|
QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
|
|
641
|
-
var requestId = queryInfo.lastRequestId = this.generateRequestId();
|
|
646
|
+
var requestId = (queryInfo.lastRequestId = this.generateRequestId());
|
|
642
647
|
var linkDocument = this.cache.transformForLink(options.query);
|
|
643
648
|
return asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
644
649
|
var graphQLErrors = getGraphQLErrorsFromResult(result);
|
|
@@ -679,7 +684,7 @@ var QueryManager = (function () {
|
|
|
679
684
|
var variables = this.getVariables(query, options.variables);
|
|
680
685
|
var queryInfo = this.getQuery(queryId);
|
|
681
686
|
var defaults = this.defaultOptions.watchQuery;
|
|
682
|
-
var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? defaults && defaults.fetchPolicy || "cache-first" : _a, _b = options.errorPolicy, errorPolicy = _b === void 0 ? defaults && defaults.errorPolicy || "none" : _b, _c = options.returnPartialData, returnPartialData = _c === void 0 ? false : _c, _d = options.notifyOnNetworkStatusChange, notifyOnNetworkStatusChange = _d === void 0 ? false : _d, _e = options.context, context = _e === void 0 ? {} : _e;
|
|
687
|
+
var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? (defaults && defaults.fetchPolicy) || "cache-first" : _a, _b = options.errorPolicy, errorPolicy = _b === void 0 ? (defaults && defaults.errorPolicy) || "none" : _b, _c = options.returnPartialData, returnPartialData = _c === void 0 ? false : _c, _d = options.notifyOnNetworkStatusChange, notifyOnNetworkStatusChange = _d === void 0 ? false : _d, _e = options.context, context = _e === void 0 ? {} : _e;
|
|
683
688
|
var normalized = Object.assign({}, options, {
|
|
684
689
|
query: query,
|
|
685
690
|
variables: variables,
|
|
@@ -708,7 +713,8 @@ var QueryManager = (function () {
|
|
|
708
713
|
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
709
714
|
concast = new Concast(this.localState
|
|
710
715
|
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
711
|
-
.then(fromVariables)
|
|
716
|
+
.then(fromVariables)
|
|
717
|
+
.then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
712
718
|
containsDataFromLink = true;
|
|
713
719
|
}
|
|
714
720
|
else {
|
|
@@ -734,15 +740,14 @@ var QueryManager = (function () {
|
|
|
734
740
|
});
|
|
735
741
|
});
|
|
736
742
|
}
|
|
737
|
-
var results = new Map;
|
|
743
|
+
var results = new Map();
|
|
738
744
|
if (updateCache) {
|
|
739
745
|
this.cache.batch({
|
|
740
746
|
update: updateCache,
|
|
741
|
-
optimistic: optimistic && removeOptimistic || false,
|
|
747
|
+
optimistic: (optimistic && removeOptimistic) || false,
|
|
742
748
|
removeOptimistic: removeOptimistic,
|
|
743
749
|
onWatchUpdated: function (watch, diff, lastDiff) {
|
|
744
|
-
var oq = watch.watcher instanceof QueryInfo &&
|
|
745
|
-
watch.watcher.observableQuery;
|
|
750
|
+
var oq = watch.watcher instanceof QueryInfo && watch.watcher.observableQuery;
|
|
746
751
|
if (oq) {
|
|
747
752
|
if (onQueryUpdated) {
|
|
748
753
|
includedQueriesById.delete(oq.queryId);
|
|
@@ -799,43 +804,50 @@ var QueryManager = (function () {
|
|
|
799
804
|
variables: variables,
|
|
800
805
|
networkStatus: networkStatus,
|
|
801
806
|
});
|
|
802
|
-
var readCache = function () { return queryInfo.getDiff(
|
|
807
|
+
var readCache = function () { return queryInfo.getDiff(); };
|
|
803
808
|
var resultsFromCache = function (diff, networkStatus) {
|
|
804
809
|
if (networkStatus === void 0) { networkStatus = queryInfo.networkStatus || NetworkStatus.loading; }
|
|
805
810
|
var data = diff.result;
|
|
806
|
-
if (globalThis.__DEV__ !== false &&
|
|
807
|
-
!returnPartialData &&
|
|
808
|
-
!equal(data, {})) {
|
|
811
|
+
if (globalThis.__DEV__ !== false && !returnPartialData && !equal(data, {})) {
|
|
809
812
|
logMissingFieldErrors(diff.missing);
|
|
810
813
|
}
|
|
811
|
-
var fromData = function (data) {
|
|
814
|
+
var fromData = function (data) {
|
|
815
|
+
return Observable.of(__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true })));
|
|
816
|
+
};
|
|
812
817
|
if (data && _this.getDocumentInfo(query).hasForcedResolvers) {
|
|
813
|
-
return _this.localState
|
|
818
|
+
return _this.localState
|
|
819
|
+
.runResolvers({
|
|
814
820
|
document: query,
|
|
815
821
|
remoteResult: { data: data },
|
|
816
822
|
context: context,
|
|
817
823
|
variables: variables,
|
|
818
824
|
onlyRunForcedResolvers: true,
|
|
819
|
-
})
|
|
825
|
+
})
|
|
826
|
+
.then(function (resolved) { return fromData(resolved.data || void 0); });
|
|
820
827
|
}
|
|
821
|
-
if (errorPolicy ===
|
|
828
|
+
if (errorPolicy === "none" &&
|
|
822
829
|
networkStatus === NetworkStatus.refetch &&
|
|
823
830
|
Array.isArray(diff.missing)) {
|
|
824
831
|
return fromData(void 0);
|
|
825
832
|
}
|
|
826
833
|
return fromData(data);
|
|
827
834
|
};
|
|
828
|
-
var cacheWriteBehavior = fetchPolicy === "no-cache"
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
835
|
+
var cacheWriteBehavior = fetchPolicy === "no-cache"
|
|
836
|
+
? 0
|
|
837
|
+
:
|
|
838
|
+
networkStatus === NetworkStatus.refetch &&
|
|
839
|
+
refetchWritePolicy !== "merge"
|
|
840
|
+
? 1
|
|
841
|
+
: 2;
|
|
842
|
+
var resultsFromLink = function () {
|
|
843
|
+
return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
|
|
844
|
+
query: query,
|
|
845
|
+
variables: variables,
|
|
846
|
+
context: context,
|
|
847
|
+
fetchPolicy: fetchPolicy,
|
|
848
|
+
errorPolicy: errorPolicy,
|
|
849
|
+
});
|
|
850
|
+
};
|
|
839
851
|
var shouldNotify = notifyOnNetworkStatusChange &&
|
|
840
852
|
typeof oldNetworkStatus === "number" &&
|
|
841
853
|
oldNetworkStatus !== networkStatus &&
|
|
@@ -845,35 +857,47 @@ var QueryManager = (function () {
|
|
|
845
857
|
case "cache-first": {
|
|
846
858
|
var diff = readCache();
|
|
847
859
|
if (diff.complete) {
|
|
848
|
-
return {
|
|
860
|
+
return {
|
|
861
|
+
fromLink: false,
|
|
862
|
+
sources: [resultsFromCache(diff, queryInfo.markReady())],
|
|
863
|
+
};
|
|
849
864
|
}
|
|
850
865
|
if (returnPartialData || shouldNotify) {
|
|
851
|
-
return {
|
|
866
|
+
return {
|
|
867
|
+
fromLink: true,
|
|
868
|
+
sources: [resultsFromCache(diff), resultsFromLink()],
|
|
869
|
+
};
|
|
852
870
|
}
|
|
853
871
|
return { fromLink: true, sources: [resultsFromLink()] };
|
|
854
872
|
}
|
|
855
873
|
case "cache-and-network": {
|
|
856
874
|
var diff = readCache();
|
|
857
875
|
if (diff.complete || returnPartialData || shouldNotify) {
|
|
858
|
-
return {
|
|
876
|
+
return {
|
|
877
|
+
fromLink: true,
|
|
878
|
+
sources: [resultsFromCache(diff), resultsFromLink()],
|
|
879
|
+
};
|
|
859
880
|
}
|
|
860
881
|
return { fromLink: true, sources: [resultsFromLink()] };
|
|
861
882
|
}
|
|
862
883
|
case "cache-only":
|
|
863
|
-
return {
|
|
884
|
+
return {
|
|
885
|
+
fromLink: false,
|
|
886
|
+
sources: [resultsFromCache(readCache(), queryInfo.markReady())],
|
|
887
|
+
};
|
|
864
888
|
case "network-only":
|
|
865
889
|
if (shouldNotify) {
|
|
866
|
-
return {
|
|
890
|
+
return {
|
|
891
|
+
fromLink: true,
|
|
892
|
+
sources: [resultsFromCache(readCache()), resultsFromLink()],
|
|
893
|
+
};
|
|
867
894
|
}
|
|
868
895
|
return { fromLink: true, sources: [resultsFromLink()] };
|
|
869
896
|
case "no-cache":
|
|
870
897
|
if (shouldNotify) {
|
|
871
898
|
return {
|
|
872
899
|
fromLink: true,
|
|
873
|
-
sources: [
|
|
874
|
-
resultsFromCache(queryInfo.getDiff()),
|
|
875
|
-
resultsFromLink(),
|
|
876
|
-
],
|
|
900
|
+
sources: [resultsFromCache(queryInfo.getDiff()), resultsFromLink()],
|
|
877
901
|
};
|
|
878
902
|
}
|
|
879
903
|
return { fromLink: true, sources: [resultsFromLink()] };
|