@apollo/client 0.0.0-pr-10521-20230206180228
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/LICENSE +22 -0
- package/README.md +45 -0
- package/apollo-client.cjs +7614 -0
- package/apollo-client.cjs.map +1 -0
- package/apollo-client.min.cjs +1 -0
- package/cache/cache.cjs +2425 -0
- package/cache/cache.cjs.map +1 -0
- package/cache/cache.cjs.native.js +2425 -0
- package/cache/core/cache.d.ts +32 -0
- package/cache/core/cache.d.ts.map +1 -0
- package/cache/core/cache.js +84 -0
- package/cache/core/cache.js.map +1 -0
- package/cache/core/types/Cache.d.ts +55 -0
- package/cache/core/types/Cache.d.ts.map +1 -0
- package/cache/core/types/Cache.js +4 -0
- package/cache/core/types/Cache.js.map +1 -0
- package/cache/core/types/DataProxy.d.ts +52 -0
- package/cache/core/types/DataProxy.d.ts.map +1 -0
- package/cache/core/types/DataProxy.js +2 -0
- package/cache/core/types/DataProxy.js.map +1 -0
- package/cache/core/types/common.d.ts +47 -0
- package/cache/core/types/common.d.ts.map +1 -0
- package/cache/core/types/common.js +26 -0
- package/cache/core/types/common.js.map +1 -0
- package/cache/index.d.ts +15 -0
- package/cache/index.d.ts.map +1 -0
- package/cache/index.js +14 -0
- package/cache/index.js.map +1 -0
- package/cache/inmemory/__mocks__/optimism.d.ts +2 -0
- package/cache/inmemory/__mocks__/optimism.d.ts.map +1 -0
- package/cache/inmemory/__mocks__/optimism.js +14 -0
- package/cache/inmemory/__mocks__/optimism.js.map +1 -0
- package/cache/inmemory/entityStore.d.ts +83 -0
- package/cache/inmemory/entityStore.d.ts.map +1 -0
- package/cache/inmemory/entityStore.js +467 -0
- package/cache/inmemory/entityStore.js.map +1 -0
- package/cache/inmemory/fixPolyfills.d.ts +1 -0
- package/cache/inmemory/fixPolyfills.d.ts.map +1 -0
- package/cache/inmemory/fixPolyfills.js +1 -0
- package/cache/inmemory/fixPolyfills.js.map +1 -0
- package/cache/inmemory/fixPolyfills.native.d.ts +2 -0
- package/cache/inmemory/fixPolyfills.native.d.ts.map +1 -0
- package/cache/inmemory/fixPolyfills.native.js +48 -0
- package/cache/inmemory/fixPolyfills.native.js.map +1 -0
- package/cache/inmemory/fragmentRegistry.d.ts +8 -0
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -0
- package/cache/inmemory/fragmentRegistry.js +113 -0
- package/cache/inmemory/fragmentRegistry.js.map +1 -0
- package/cache/inmemory/helpers.d.ts +27 -0
- package/cache/inmemory/helpers.d.ts.map +1 -0
- package/cache/inmemory/helpers.js +85 -0
- package/cache/inmemory/helpers.js.map +1 -0
- package/cache/inmemory/inMemoryCache.d.ts +52 -0
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -0
- package/cache/inmemory/inMemoryCache.js +316 -0
- package/cache/inmemory/inMemoryCache.js.map +1 -0
- package/cache/inmemory/key-extractor.d.ts +9 -0
- package/cache/inmemory/key-extractor.d.ts.map +1 -0
- package/cache/inmemory/key-extractor.js +118 -0
- package/cache/inmemory/key-extractor.js.map +1 -0
- package/cache/inmemory/object-canon.d.ts +17 -0
- package/cache/inmemory/object-canon.d.ts.map +1 -0
- package/cache/inmemory/object-canon.js +120 -0
- package/cache/inmemory/object-canon.js.map +1 -0
- package/cache/inmemory/policies.d.ts +96 -0
- package/cache/inmemory/policies.d.ts.map +1 -0
- package/cache/inmemory/policies.js +416 -0
- package/cache/inmemory/policies.js.map +1 -0
- package/cache/inmemory/reactiveVars.d.ts +18 -0
- package/cache/inmemory/reactiveVars.d.ts.map +1 -0
- package/cache/inmemory/reactiveVars.js +65 -0
- package/cache/inmemory/reactiveVars.js.map +1 -0
- package/cache/inmemory/readFromStore.d.ts +36 -0
- package/cache/inmemory/readFromStore.d.ts.map +1 -0
- package/cache/inmemory/readFromStore.js +267 -0
- package/cache/inmemory/readFromStore.js.map +1 -0
- package/cache/inmemory/types.d.ts +81 -0
- package/cache/inmemory/types.d.ts.map +1 -0
- package/cache/inmemory/types.js +4 -0
- package/cache/inmemory/types.js.map +1 -0
- package/cache/inmemory/writeToStore.d.ts +37 -0
- package/cache/inmemory/writeToStore.d.ts.map +1 -0
- package/cache/inmemory/writeToStore.js +394 -0
- package/cache/inmemory/writeToStore.js.map +1 -0
- package/cache/package.json +8 -0
- package/config/jest/setup.d.ts +2 -0
- package/config/jest/setup.d.ts.map +1 -0
- package/config/jest/setup.js +5 -0
- package/config/jest/setup.js.map +1 -0
- package/core/ApolloClient.d.ts +76 -0
- package/core/ApolloClient.d.ts.map +1 -0
- package/core/ApolloClient.js +240 -0
- package/core/ApolloClient.js.map +1 -0
- package/core/LocalState.d.ts +69 -0
- package/core/LocalState.d.ts.map +1 -0
- package/core/LocalState.js +321 -0
- package/core/LocalState.js.map +1 -0
- package/core/ObservableQuery.d.ts +74 -0
- package/core/ObservableQuery.d.ts.map +1 -0
- package/core/ObservableQuery.js +507 -0
- package/core/ObservableQuery.js.map +1 -0
- package/core/QueryInfo.d.ts +62 -0
- package/core/QueryInfo.d.ts.map +1 -0
- package/core/QueryInfo.js +287 -0
- package/core/QueryInfo.js.map +1 -0
- package/core/QueryManager.d.ts +120 -0
- package/core/QueryManager.d.ts.map +1 -0
- package/core/QueryManager.js +890 -0
- package/core/QueryManager.js.map +1 -0
- package/core/core.cjs +2349 -0
- package/core/core.cjs.map +1 -0
- package/core/core.cjs.native.js +2349 -0
- package/core/index.d.ts +17 -0
- package/core/index.d.ts.map +1 -0
- package/core/index.js +17 -0
- package/core/index.js.map +1 -0
- package/core/networkStatus.d.ts +11 -0
- package/core/networkStatus.d.ts.map +1 -0
- package/core/networkStatus.js +14 -0
- package/core/networkStatus.js.map +1 -0
- package/core/package.json +8 -0
- package/core/types.d.ts +74 -0
- package/core/types.d.ts.map +1 -0
- package/core/types.js +3 -0
- package/core/types.js.map +1 -0
- package/core/watchQueryOptions.d.ts +78 -0
- package/core/watchQueryOptions.d.ts.map +1 -0
- package/core/watchQueryOptions.js +2 -0
- package/core/watchQueryOptions.js.map +1 -0
- package/errors/errors.cjs +49 -0
- package/errors/errors.cjs.map +1 -0
- package/errors/errors.cjs.native.js +49 -0
- package/errors/index.d.ts +23 -0
- package/errors/index.d.ts.map +1 -0
- package/errors/index.js +42 -0
- package/errors/index.js.map +1 -0
- package/errors/package.json +8 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -0
- package/invariantErrorCodes.js +339 -0
- package/link/batch/batch.cjs +159 -0
- package/link/batch/batch.cjs.map +1 -0
- package/link/batch/batch.cjs.native.js +159 -0
- package/link/batch/batchLink.d.ts +19 -0
- package/link/batch/batchLink.d.ts.map +1 -0
- package/link/batch/batchLink.js +31 -0
- package/link/batch/batchLink.js.map +1 -0
- package/link/batch/batching.d.ts +27 -0
- package/link/batch/batching.d.ts.map +1 -0
- package/link/batch/batching.js +125 -0
- package/link/batch/batching.js.map +1 -0
- package/link/batch/index.d.ts +2 -0
- package/link/batch/index.d.ts.map +1 -0
- package/link/batch/index.js +2 -0
- package/link/batch/index.js.map +1 -0
- package/link/batch/package.json +8 -0
- package/link/batch-http/batch-http.cjs +137 -0
- package/link/batch-http/batch-http.cjs.map +1 -0
- package/link/batch-http/batch-http.cjs.native.js +137 -0
- package/link/batch-http/batchHttpLink.d.ts +16 -0
- package/link/batch-http/batchHttpLink.d.ts.map +1 -0
- package/link/batch-http/batchHttpLink.js +131 -0
- package/link/batch-http/batchHttpLink.js.map +1 -0
- package/link/batch-http/index.d.ts +2 -0
- package/link/batch-http/index.d.ts.map +1 -0
- package/link/batch-http/index.js +2 -0
- package/link/batch-http/index.js.map +1 -0
- package/link/batch-http/package.json +8 -0
- package/link/context/context.cjs +38 -0
- package/link/context/context.cjs.map +1 -0
- package/link/context/context.cjs.native.js +38 -0
- package/link/context/index.d.ts +5 -0
- package/link/context/index.d.ts.map +1 -0
- package/link/context/index.js +31 -0
- package/link/context/index.js.map +1 -0
- package/link/context/package.json +8 -0
- package/link/core/ApolloLink.d.ts +16 -0
- package/link/core/ApolloLink.d.ts.map +1 -0
- package/link/core/ApolloLink.js +100 -0
- package/link/core/ApolloLink.js.map +1 -0
- package/link/core/concat.d.ts +3 -0
- package/link/core/concat.d.ts.map +1 -0
- package/link/core/concat.js +3 -0
- package/link/core/concat.js.map +1 -0
- package/link/core/core.cjs +121 -0
- package/link/core/core.cjs.map +1 -0
- package/link/core/core.cjs.native.js +121 -0
- package/link/core/empty.d.ts +3 -0
- package/link/core/empty.d.ts.map +1 -0
- package/link/core/empty.js +3 -0
- package/link/core/empty.js.map +1 -0
- package/link/core/execute.d.ts +3 -0
- package/link/core/execute.d.ts.map +1 -0
- package/link/core/execute.js +3 -0
- package/link/core/execute.js.map +1 -0
- package/link/core/from.d.ts +3 -0
- package/link/core/from.d.ts.map +1 -0
- package/link/core/from.js +3 -0
- package/link/core/from.js.map +1 -0
- package/link/core/index.d.ts +9 -0
- package/link/core/index.d.ts.map +1 -0
- package/link/core/index.js +9 -0
- package/link/core/index.js.map +1 -0
- package/link/core/package.json +8 -0
- package/link/core/split.d.ts +3 -0
- package/link/core/split.d.ts.map +1 -0
- package/link/core/split.js +3 -0
- package/link/core/split.js.map +1 -0
- package/link/core/types.d.ts +52 -0
- package/link/core/types.d.ts.map +1 -0
- package/link/core/types.js +2 -0
- package/link/core/types.js.map +1 -0
- package/link/error/error.cjs +90 -0
- package/link/error/error.cjs.map +1 -0
- package/link/error/error.cjs.native.js +90 -0
- package/link/error/index.d.ts +24 -0
- package/link/error/index.d.ts.map +1 -0
- package/link/error/index.js +83 -0
- package/link/error/index.js.map +1 -0
- package/link/error/package.json +8 -0
- package/link/http/HttpLink.d.ts +8 -0
- package/link/http/HttpLink.d.ts.map +1 -0
- package/link/http/HttpLink.js +15 -0
- package/link/http/HttpLink.js.map +1 -0
- package/link/http/checkFetcher.d.ts +2 -0
- package/link/http/checkFetcher.d.ts.map +1 -0
- package/link/http/checkFetcher.js +7 -0
- package/link/http/checkFetcher.js.map +1 -0
- package/link/http/createHttpLink.d.ts +4 -0
- package/link/http/createHttpLink.d.ts.map +1 -0
- package/link/http/createHttpLink.js +127 -0
- package/link/http/createHttpLink.js.map +1 -0
- package/link/http/createSignalIfSupported.d.ts +8 -0
- package/link/http/createSignalIfSupported.d.ts.map +1 -0
- package/link/http/createSignalIfSupported.js +8 -0
- package/link/http/createSignalIfSupported.js.map +1 -0
- package/link/http/http.cjs +593 -0
- package/link/http/http.cjs.map +1 -0
- package/link/http/http.cjs.native.js +593 -0
- package/link/http/index.d.ts +11 -0
- package/link/http/index.d.ts.map +1 -0
- package/link/http/index.js +11 -0
- package/link/http/index.js.map +1 -0
- package/link/http/iterators/async.d.ts +2 -0
- package/link/http/iterators/async.d.ts.map +1 -0
- package/link/http/iterators/async.js +14 -0
- package/link/http/iterators/async.js.map +1 -0
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.d.ts.map +1 -0
- package/link/http/iterators/nodeStream.js +71 -0
- package/link/http/iterators/nodeStream.js.map +1 -0
- package/link/http/iterators/promise.d.ts +2 -0
- package/link/http/iterators/promise.d.ts.map +1 -0
- package/link/http/iterators/promise.js +28 -0
- package/link/http/iterators/promise.js.map +1 -0
- package/link/http/iterators/reader.d.ts +2 -0
- package/link/http/iterators/reader.d.ts.map +1 -0
- package/link/http/iterators/reader.js +15 -0
- package/link/http/iterators/reader.js.map +1 -0
- package/link/http/package.json +8 -0
- package/link/http/parseAndCheckHttpResponse.d.ts +14 -0
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -0
- package/link/http/parseAndCheckHttpResponse.js +148 -0
- package/link/http/parseAndCheckHttpResponse.js.map +1 -0
- package/link/http/responseIterator.d.ts +3 -0
- package/link/http/responseIterator.d.ts.map +1 -0
- package/link/http/responseIterator.js +23 -0
- package/link/http/responseIterator.js.map +1 -0
- package/link/http/rewriteURIForGET.d.ts +9 -0
- package/link/http/rewriteURIForGET.d.ts.map +1 -0
- package/link/http/rewriteURIForGET.js +43 -0
- package/link/http/rewriteURIForGET.js.map +1 -0
- package/link/http/selectHttpOptionsAndBody.d.ts +57 -0
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -0
- package/link/http/selectHttpOptionsAndBody.js +78 -0
- package/link/http/selectHttpOptionsAndBody.js.map +1 -0
- package/link/http/selectURI.d.ts +3 -0
- package/link/http/selectURI.d.ts.map +1 -0
- package/link/http/selectURI.js +14 -0
- package/link/http/selectURI.js.map +1 -0
- package/link/http/serializeFetchParameter.d.ts +6 -0
- package/link/http/serializeFetchParameter.d.ts.map +1 -0
- package/link/http/serializeFetchParameter.js +14 -0
- package/link/http/serializeFetchParameter.js.map +1 -0
- package/link/persisted-queries/index.d.ts +31 -0
- package/link/persisted-queries/index.d.ts.map +1 -0
- package/link/persisted-queries/index.js +170 -0
- package/link/persisted-queries/index.js.map +1 -0
- package/link/persisted-queries/package.json +8 -0
- package/link/persisted-queries/persisted-queries.cjs +174 -0
- package/link/persisted-queries/persisted-queries.cjs.map +1 -0
- package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
- package/link/retry/delayFunction.d.ts +11 -0
- package/link/retry/delayFunction.d.ts.map +1 -0
- package/link/retry/delayFunction.js +12 -0
- package/link/retry/delayFunction.js.map +1 -0
- package/link/retry/index.d.ts +2 -0
- package/link/retry/index.d.ts.map +1 -0
- package/link/retry/index.js +2 -0
- package/link/retry/index.js.map +1 -0
- package/link/retry/package.json +8 -0
- package/link/retry/retry.cjs +170 -0
- package/link/retry/retry.cjs.map +1 -0
- package/link/retry/retry.cjs.native.js +170 -0
- package/link/retry/retryFunction.d.ts +10 -0
- package/link/retry/retryFunction.d.ts.map +1 -0
- package/link/retry/retryFunction.js +9 -0
- package/link/retry/retryFunction.js.map +1 -0
- package/link/retry/retryLink.d.ts +17 -0
- package/link/retry/retryLink.d.ts.map +1 -0
- package/link/retry/retryLink.js +145 -0
- package/link/retry/retryLink.js.map +1 -0
- package/link/schema/index.d.ts +22 -0
- package/link/schema/index.d.ts.map +1 -0
- package/link/schema/index.js +50 -0
- package/link/schema/index.js.map +1 -0
- package/link/schema/package.json +8 -0
- package/link/schema/schema.cjs +56 -0
- package/link/schema/schema.cjs.map +1 -0
- package/link/schema/schema.cjs.native.js +56 -0
- package/link/subscriptions/index.d.ts +9 -0
- package/link/subscriptions/index.d.ts.map +1 -0
- package/link/subscriptions/index.js +39 -0
- package/link/subscriptions/index.js.map +1 -0
- package/link/subscriptions/package.json +8 -0
- package/link/subscriptions/subscriptions.cjs +45 -0
- package/link/subscriptions/subscriptions.cjs.map +1 -0
- package/link/subscriptions/subscriptions.cjs.native.js +45 -0
- package/link/utils/createOperation.d.ts +3 -0
- package/link/utils/createOperation.d.ts.map +1 -0
- package/link/utils/createOperation.js +23 -0
- package/link/utils/createOperation.js.map +1 -0
- package/link/utils/fromError.d.ts +3 -0
- package/link/utils/fromError.d.ts.map +1 -0
- package/link/utils/fromError.js +7 -0
- package/link/utils/fromError.js.map +1 -0
- package/link/utils/fromPromise.d.ts +3 -0
- package/link/utils/fromPromise.d.ts.map +1 -0
- package/link/utils/fromPromise.js +12 -0
- package/link/utils/fromPromise.js.map +1 -0
- package/link/utils/index.d.ts +9 -0
- package/link/utils/index.d.ts.map +1 -0
- package/link/utils/index.js +9 -0
- package/link/utils/index.js.map +1 -0
- package/link/utils/package.json +8 -0
- package/link/utils/throwServerError.d.ts +7 -0
- package/link/utils/throwServerError.d.ts.map +1 -0
- package/link/utils/throwServerError.js +9 -0
- package/link/utils/throwServerError.js.map +1 -0
- package/link/utils/toPromise.d.ts +3 -0
- package/link/utils/toPromise.d.ts.map +1 -0
- package/link/utils/toPromise.js +19 -0
- package/link/utils/toPromise.js.map +1 -0
- package/link/utils/transformOperation.d.ts +3 -0
- package/link/utils/transformOperation.d.ts.map +1 -0
- package/link/utils/transformOperation.js +17 -0
- package/link/utils/transformOperation.js.map +1 -0
- package/link/utils/utils.cjs +115 -0
- package/link/utils/utils.cjs.map +1 -0
- package/link/utils/utils.cjs.native.js +115 -0
- package/link/utils/validateOperation.d.ts +3 -0
- package/link/utils/validateOperation.d.ts.map +1 -0
- package/link/utils/validateOperation.js +18 -0
- package/link/utils/validateOperation.js.map +1 -0
- package/link/ws/index.d.ts +17 -0
- package/link/ws/index.d.ts.map +1 -0
- package/link/ws/index.js +22 -0
- package/link/ws/index.js.map +1 -0
- package/link/ws/package.json +8 -0
- package/link/ws/ws.cjs +28 -0
- package/link/ws/ws.cjs.map +1 -0
- package/link/ws/ws.cjs.native.js +28 -0
- package/main.cjs +16 -0
- package/main.cjs.map +1 -0
- package/main.cjs.native.js +16 -0
- package/package.json +141 -0
- package/react/cache/SuspenseCache.d.ts +18 -0
- package/react/cache/SuspenseCache.d.ts.map +1 -0
- package/react/cache/SuspenseCache.js +49 -0
- package/react/cache/SuspenseCache.js.map +1 -0
- package/react/cache/index.d.ts +2 -0
- package/react/cache/index.d.ts.map +1 -0
- package/react/cache/index.js +2 -0
- package/react/cache/index.js.map +1 -0
- package/react/components/Mutation.d.ts +12 -0
- package/react/components/Mutation.d.ts.map +1 -0
- package/react/components/Mutation.js +22 -0
- package/react/components/Mutation.js.map +1 -0
- package/react/components/Query.d.ts +12 -0
- package/react/components/Query.d.ts.map +1 -0
- package/react/components/Query.js +23 -0
- package/react/components/Query.js.map +1 -0
- package/react/components/Subscription.d.ts +12 -0
- package/react/components/Subscription.d.ts.map +1 -0
- package/react/components/Subscription.js +17 -0
- package/react/components/Subscription.js.map +1 -0
- package/react/components/components.cjs +81 -0
- package/react/components/components.cjs.map +1 -0
- package/react/components/components.cjs.native.js +81 -0
- package/react/components/index.d.ts +5 -0
- package/react/components/index.d.ts.map +1 -0
- package/react/components/index.js +5 -0
- package/react/components/index.js.map +1 -0
- package/react/components/package.json +8 -0
- package/react/components/types.d.ts +18 -0
- package/react/components/types.d.ts.map +1 -0
- package/react/components/types.js +2 -0
- package/react/components/types.js.map +1 -0
- package/react/context/ApolloConsumer.d.ts +7 -0
- package/react/context/ApolloConsumer.d.ts.map +1 -0
- package/react/context/ApolloConsumer.js +12 -0
- package/react/context/ApolloConsumer.js.map +1 -0
- package/react/context/ApolloContext.d.ts +12 -0
- package/react/context/ApolloContext.d.ts.map +1 -0
- package/react/context/ApolloContext.js +20 -0
- package/react/context/ApolloContext.js.map +1 -0
- package/react/context/ApolloProvider.d.ts +10 -0
- package/react/context/ApolloProvider.d.ts.map +1 -0
- package/react/context/ApolloProvider.js +20 -0
- package/react/context/ApolloProvider.js.map +1 -0
- package/react/context/context.cjs +70 -0
- package/react/context/context.cjs.map +1 -0
- package/react/context/context.cjs.native.js +70 -0
- package/react/context/index.d.ts +5 -0
- package/react/context/index.d.ts.map +1 -0
- package/react/context/index.js +5 -0
- package/react/context/index.js.map +1 -0
- package/react/context/package.json +8 -0
- package/react/hoc/graphql.d.ts +6 -0
- package/react/hoc/graphql.d.ts.map +1 -0
- package/react/hoc/graphql.js +17 -0
- package/react/hoc/graphql.js.map +1 -0
- package/react/hoc/hoc-utils.d.ts +17 -0
- package/react/hoc/hoc-utils.d.ts.map +1 -0
- package/react/hoc/hoc-utils.js +47 -0
- package/react/hoc/hoc-utils.js.map +1 -0
- package/react/hoc/hoc.cjs +325 -0
- package/react/hoc/hoc.cjs.map +1 -0
- package/react/hoc/hoc.cjs.native.js +325 -0
- package/react/hoc/index.d.ts +8 -0
- package/react/hoc/index.d.ts.map +1 -0
- package/react/hoc/index.js +8 -0
- package/react/hoc/index.js.map +1 -0
- package/react/hoc/mutation-hoc.d.ts +7 -0
- package/react/hoc/mutation-hoc.d.ts.map +1 -0
- package/react/hoc/mutation-hoc.js +63 -0
- package/react/hoc/mutation-hoc.js.map +1 -0
- package/react/hoc/package.json +8 -0
- package/react/hoc/query-hoc.d.ts +5 -0
- package/react/hoc/query-hoc.d.ts.map +1 -0
- package/react/hoc/query-hoc.js +70 -0
- package/react/hoc/query-hoc.js.map +1 -0
- package/react/hoc/subscription-hoc.d.ts +5 -0
- package/react/hoc/subscription-hoc.d.ts.map +1 -0
- package/react/hoc/subscription-hoc.js +80 -0
- package/react/hoc/subscription-hoc.js.map +1 -0
- package/react/hoc/types.d.ts +43 -0
- package/react/hoc/types.d.ts.map +1 -0
- package/react/hoc/types.js +2 -0
- package/react/hoc/types.js.map +1 -0
- package/react/hoc/withApollo.d.ts +4 -0
- package/react/hoc/withApollo.d.ts.map +1 -0
- package/react/hoc/withApollo.js +45 -0
- package/react/hoc/withApollo.js.map +1 -0
- package/react/hooks/compareResults.d.ts +3 -0
- package/react/hooks/compareResults.d.ts.map +1 -0
- package/react/hooks/compareResults.js +63 -0
- package/react/hooks/compareResults.js.map +1 -0
- package/react/hooks/hooks.cjs +913 -0
- package/react/hooks/hooks.cjs.map +1 -0
- package/react/hooks/hooks.cjs.native.js +913 -0
- package/react/hooks/index.d.ts +10 -0
- package/react/hooks/index.d.ts.map +1 -0
- package/react/hooks/index.js +10 -0
- package/react/hooks/index.js.map +1 -0
- package/react/hooks/internal/index.d.ts +3 -0
- package/react/hooks/internal/index.d.ts.map +1 -0
- package/react/hooks/internal/index.js +3 -0
- package/react/hooks/internal/index.js.map +1 -0
- package/react/hooks/internal/useDeepMemo.d.ts +3 -0
- package/react/hooks/internal/useDeepMemo.d.ts.map +1 -0
- package/react/hooks/internal/useDeepMemo.js +10 -0
- package/react/hooks/internal/useDeepMemo.js.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +3 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -0
- package/react/hooks/package.json +8 -0
- package/react/hooks/useApolloClient.d.ts +3 -0
- package/react/hooks/useApolloClient.d.ts.map +1 -0
- package/react/hooks/useApolloClient.js +12 -0
- package/react/hooks/useApolloClient.js.map +1 -0
- package/react/hooks/useFragment.d.ts +13 -0
- package/react/hooks/useFragment.d.ts.map +1 -0
- package/react/hooks/useFragment.js +39 -0
- package/react/hooks/useFragment.js.map +1 -0
- package/react/hooks/useLazyQuery.d.ts +6 -0
- package/react/hooks/useLazyQuery.d.ts.map +1 -0
- package/react/hooks/useLazyQuery.js +71 -0
- package/react/hooks/useLazyQuery.js.map +1 -0
- package/react/hooks/useMutation.d.ts +6 -0
- package/react/hooks/useMutation.d.ts.map +1 -0
- package/react/hooks/useMutation.js +100 -0
- package/react/hooks/useMutation.js.map +1 -0
- package/react/hooks/useQuery.d.ts +41 -0
- package/react/hooks/useQuery.d.ts.map +1 -0
- package/react/hooks/useQuery.js +302 -0
- package/react/hooks/useQuery.js.map +1 -0
- package/react/hooks/useReactiveVar.d.ts +3 -0
- package/react/hooks/useReactiveVar.d.ts.map +1 -0
- package/react/hooks/useReactiveVar.js +16 -0
- package/react/hooks/useReactiveVar.js.map +1 -0
- package/react/hooks/useSubscription.d.ts +6 -0
- package/react/hooks/useSubscription.d.ts.map +1 -0
- package/react/hooks/useSubscription.js +141 -0
- package/react/hooks/useSubscription.js.map +1 -0
- package/react/hooks/useSuspenseCache.d.ts +2 -0
- package/react/hooks/useSuspenseCache.d.ts.map +1 -0
- package/react/hooks/useSuspenseCache.js +10 -0
- package/react/hooks/useSuspenseCache.js.map +1 -0
- package/react/hooks/useSuspenseQuery.d.ts +12 -0
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -0
- package/react/hooks/useSuspenseQuery.js +181 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -0
- package/react/hooks/useSyncExternalStore.d.ts +4 -0
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
- package/react/hooks/useSyncExternalStore.js +48 -0
- package/react/hooks/useSyncExternalStore.js.map +1 -0
- package/react/index.d.ts +7 -0
- package/react/index.d.ts.map +1 -0
- package/react/index.js +7 -0
- package/react/index.js.map +1 -0
- package/react/package.json +8 -0
- package/react/parser/index.d.ts +15 -0
- package/react/parser/index.d.ts.map +1 -0
- package/react/parser/index.js +94 -0
- package/react/parser/index.js.map +1 -0
- package/react/parser/package.json +8 -0
- package/react/parser/parser.cjs +103 -0
- package/react/parser/parser.cjs.map +1 -0
- package/react/parser/parser.cjs.native.js +103 -0
- package/react/react.cjs +69 -0
- package/react/react.cjs.map +1 -0
- package/react/react.cjs.native.js +69 -0
- package/react/ssr/RenderPromises.d.ts +22 -0
- package/react/ssr/RenderPromises.d.ts.map +1 -0
- package/react/ssr/RenderPromises.js +90 -0
- package/react/ssr/RenderPromises.js.map +1 -0
- package/react/ssr/getDataFromTree.d.ts +13 -0
- package/react/ssr/getDataFromTree.d.ts.map +1 -0
- package/react/ssr/getDataFromTree.js +32 -0
- package/react/ssr/getDataFromTree.js.map +1 -0
- package/react/ssr/index.d.ts +4 -0
- package/react/ssr/index.d.ts.map +1 -0
- package/react/ssr/index.js +4 -0
- package/react/ssr/index.js.map +1 -0
- package/react/ssr/package.json +8 -0
- package/react/ssr/renderToStringWithData.d.ts +3 -0
- package/react/ssr/renderToStringWithData.d.ts.map +1 -0
- package/react/ssr/renderToStringWithData.js +9 -0
- package/react/ssr/renderToStringWithData.js.map +1 -0
- package/react/ssr/ssr.cjs +151 -0
- package/react/ssr/ssr.cjs.map +1 -0
- package/react/ssr/ssr.cjs.native.js +151 -0
- package/react/types/types.d.ts +130 -0
- package/react/types/types.d.ts.map +1 -0
- package/react/types/types.js +2 -0
- package/react/types/types.js.map +1 -0
- package/testing/core/core.cjs +315 -0
- package/testing/core/core.cjs.map +1 -0
- package/testing/core/core.cjs.native.js +315 -0
- package/testing/core/index.d.ts +8 -0
- package/testing/core/index.d.ts.map +1 -0
- package/testing/core/index.js +8 -0
- package/testing/core/index.js.map +1 -0
- package/testing/core/itAsync.d.ts +6 -0
- package/testing/core/itAsync.d.ts.map +1 -0
- package/testing/core/itAsync.js +19 -0
- package/testing/core/itAsync.js.map +1 -0
- package/testing/core/mocking/mockClient.d.ts +5 -0
- package/testing/core/mocking/mockClient.d.ts.map +1 -0
- package/testing/core/mocking/mockClient.js +14 -0
- package/testing/core/mocking/mockClient.js.map +1 -0
- package/testing/core/mocking/mockFetch.d.ts +24 -0
- package/testing/core/mocking/mockFetch.d.ts.map +1 -0
- package/testing/core/mocking/mockFetch.js +83 -0
- package/testing/core/mocking/mockFetch.js.map +1 -0
- package/testing/core/mocking/mockLink.d.ts +28 -0
- package/testing/core/mocking/mockLink.d.ts.map +1 -0
- package/testing/core/mocking/mockLink.js +139 -0
- package/testing/core/mocking/mockLink.js.map +1 -0
- package/testing/core/mocking/mockQueryManager.d.ts +5 -0
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -0
- package/testing/core/mocking/mockQueryManager.js +14 -0
- package/testing/core/mocking/mockQueryManager.js.map +1 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts +24 -0
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -0
- package/testing/core/mocking/mockSubscriptionLink.js +62 -0
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -0
- package/testing/core/mocking/mockWatchQuery.d.ts +5 -0
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -0
- package/testing/core/mocking/mockWatchQuery.js +15 -0
- package/testing/core/mocking/mockWatchQuery.js.map +1 -0
- package/testing/core/observableToPromise.d.ts +15 -0
- package/testing/core/observableToPromise.d.ts.map +1 -0
- package/testing/core/observableToPromise.js +65 -0
- package/testing/core/observableToPromise.js.map +1 -0
- package/testing/core/package.json +8 -0
- package/testing/core/subscribeAndCount.d.ts +3 -0
- package/testing/core/subscribeAndCount.d.ts.map +1 -0
- package/testing/core/subscribeAndCount.js +16 -0
- package/testing/core/subscribeAndCount.js.map +1 -0
- package/testing/core/wait.d.ts +3 -0
- package/testing/core/wait.d.ts.map +1 -0
- package/testing/core/wait.js +16 -0
- package/testing/core/wait.js.map +1 -0
- package/testing/core/withConsoleSpy.d.ts +4 -0
- package/testing/core/withConsoleSpy.d.ts.map +1 -0
- package/testing/core/withConsoleSpy.js +39 -0
- package/testing/core/withConsoleSpy.js.map +1 -0
- package/testing/core/wrap.d.ts +4 -0
- package/testing/core/wrap.d.ts.map +1 -0
- package/testing/core/wrap.js +26 -0
- package/testing/core/wrap.js.map +1 -0
- package/testing/index.d.ts +4 -0
- package/testing/index.d.ts.map +1 -0
- package/testing/index.js +4 -0
- package/testing/index.js.map +1 -0
- package/testing/package.json +8 -0
- package/testing/react/MockedProvider.d.ts +30 -0
- package/testing/react/MockedProvider.d.ts.map +1 -0
- package/testing/react/MockedProvider.js +39 -0
- package/testing/react/MockedProvider.js.map +1 -0
- package/testing/testing.cjs +109 -0
- package/testing/testing.cjs.map +1 -0
- package/testing/testing.cjs.native.js +109 -0
- package/utilities/common/arrays.d.ts +2 -0
- package/utilities/common/arrays.d.ts.map +1 -0
- package/utilities/common/arrays.js +4 -0
- package/utilities/common/arrays.js.map +1 -0
- package/utilities/common/canUse.d.ts +7 -0
- package/utilities/common/canUse.d.ts.map +1 -0
- package/utilities/common/canUse.js +11 -0
- package/utilities/common/canUse.js.map +1 -0
- package/utilities/common/cloneDeep.d.ts +2 -0
- package/utilities/common/cloneDeep.d.ts.map +1 -0
- package/utilities/common/cloneDeep.js +33 -0
- package/utilities/common/cloneDeep.js.map +1 -0
- package/utilities/common/compact.d.ts +3 -0
- package/utilities/common/compact.d.ts.map +1 -0
- package/utilities/common/compact.js +19 -0
- package/utilities/common/compact.js.map +1 -0
- package/utilities/common/errorHandling.d.ts +4 -0
- package/utilities/common/errorHandling.d.ts.map +1 -0
- package/utilities/common/errorHandling.js +21 -0
- package/utilities/common/errorHandling.js.map +1 -0
- package/utilities/common/filterInPlace.d.ts +2 -0
- package/utilities/common/filterInPlace.d.ts.map +1 -0
- package/utilities/common/filterInPlace.js +11 -0
- package/utilities/common/filterInPlace.js.map +1 -0
- package/utilities/common/incrementalResult.d.ts +6 -0
- package/utilities/common/incrementalResult.d.ts.map +1 -0
- package/utilities/common/incrementalResult.js +32 -0
- package/utilities/common/incrementalResult.js.map +1 -0
- package/utilities/common/makeUniqueId.d.ts +2 -0
- package/utilities/common/makeUniqueId.d.ts.map +1 -0
- package/utilities/common/makeUniqueId.js +7 -0
- package/utilities/common/makeUniqueId.js.map +1 -0
- package/utilities/common/maybeDeepFreeze.d.ts +2 -0
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -0
- package/utilities/common/maybeDeepFreeze.js +34 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -0
- package/utilities/common/mergeDeep.d.ts +14 -0
- package/utilities/common/mergeDeep.d.ts.map +1 -0
- package/utilities/common/mergeDeep.js +76 -0
- package/utilities/common/mergeDeep.js.map +1 -0
- package/utilities/common/mergeOptions.d.ts +5 -0
- package/utilities/common/mergeOptions.d.ts.map +1 -0
- package/utilities/common/mergeOptions.js +8 -0
- package/utilities/common/mergeOptions.js.map +1 -0
- package/utilities/common/objects.d.ts +2 -0
- package/utilities/common/objects.d.ts.map +1 -0
- package/utilities/common/objects.js +4 -0
- package/utilities/common/objects.js.map +1 -0
- package/utilities/common/responseIterator.d.ts +10 -0
- package/utilities/common/responseIterator.d.ts.map +1 -0
- package/utilities/common/responseIterator.js +21 -0
- package/utilities/common/responseIterator.js.map +1 -0
- package/utilities/common/stringifyForDisplay.d.ts +2 -0
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -0
- package/utilities/common/stringifyForDisplay.js +8 -0
- package/utilities/common/stringifyForDisplay.js.map +1 -0
- package/utilities/globals/DEV.d.ts +3 -0
- package/utilities/globals/DEV.d.ts.map +1 -0
- package/utilities/globals/DEV.js +9 -0
- package/utilities/globals/DEV.js.map +1 -0
- package/utilities/globals/fix-graphql.d.ts +2 -0
- package/utilities/globals/fix-graphql.d.ts.map +1 -0
- package/utilities/globals/fix-graphql.js +6 -0
- package/utilities/globals/fix-graphql.js.map +1 -0
- package/utilities/globals/global.d.ts +5 -0
- package/utilities/globals/global.d.ts.map +1 -0
- package/utilities/globals/global.js +6 -0
- package/utilities/globals/global.js.map +1 -0
- package/utilities/globals/globals.cjs +42 -0
- package/utilities/globals/globals.cjs.map +1 -0
- package/utilities/globals/globals.cjs.native.js +42 -0
- package/utilities/globals/index.d.ts +8 -0
- package/utilities/globals/index.d.ts.map +1 -0
- package/utilities/globals/index.js +10 -0
- package/utilities/globals/index.js.map +1 -0
- package/utilities/globals/maybe.d.ts +2 -0
- package/utilities/globals/maybe.d.ts.map +1 -0
- package/utilities/globals/maybe.js +7 -0
- package/utilities/globals/maybe.js.map +1 -0
- package/utilities/globals/package.json +8 -0
- package/utilities/graphql/directives.d.ts +18 -0
- package/utilities/graphql/directives.d.ts.map +1 -0
- package/utilities/graphql/directives.js +72 -0
- package/utilities/graphql/directives.js.map +1 -0
- package/utilities/graphql/fragments.d.ts +9 -0
- package/utilities/graphql/fragments.d.ts.map +1 -0
- package/utilities/graphql/fragments.js +64 -0
- package/utilities/graphql/fragments.js.map +1 -0
- package/utilities/graphql/getFromAST.d.ts +10 -0
- package/utilities/graphql/getFromAST.d.ts.map +1 -0
- package/utilities/graphql/getFromAST.js +76 -0
- package/utilities/graphql/getFromAST.js.map +1 -0
- package/utilities/graphql/storeUtils.d.ts +32 -0
- package/utilities/graphql/storeUtils.d.ts.map +1 -0
- package/utilities/graphql/storeUtils.js +208 -0
- package/utilities/graphql/storeUtils.js.map +1 -0
- package/utilities/graphql/transform.d.ts +27 -0
- package/utilities/graphql/transform.d.ts.map +1 -0
- package/utilities/graphql/transform.js +281 -0
- package/utilities/graphql/transform.js.map +1 -0
- package/utilities/index.d.ts +27 -0
- package/utilities/index.d.ts.map +1 -0
- package/utilities/index.js +27 -0
- package/utilities/index.js.map +1 -0
- package/utilities/observables/Concast.d.ts +27 -0
- package/utilities/observables/Concast.d.ts.map +1 -0
- package/utilities/observables/Concast.js +137 -0
- package/utilities/observables/Concast.js.map +1 -0
- package/utilities/observables/Observable.d.ts +5 -0
- package/utilities/observables/Observable.d.ts.map +1 -0
- package/utilities/observables/Observable.js +9 -0
- package/utilities/observables/Observable.js.map +1 -0
- package/utilities/observables/asyncMap.d.ts +3 -0
- package/utilities/observables/asyncMap.d.ts.map +1 -0
- package/utilities/observables/asyncMap.js +49 -0
- package/utilities/observables/asyncMap.js.map +1 -0
- package/utilities/observables/iteration.d.ts +3 -0
- package/utilities/observables/iteration.d.ts.map +1 -0
- package/utilities/observables/iteration.js +6 -0
- package/utilities/observables/iteration.js.map +1 -0
- package/utilities/observables/subclassing.d.ts +3 -0
- package/utilities/observables/subclassing.d.ts.map +1 -0
- package/utilities/observables/subclassing.js +13 -0
- package/utilities/observables/subclassing.js.map +1 -0
- package/utilities/package.json +8 -0
- package/utilities/policies/pagination.d.ts +28 -0
- package/utilities/policies/pagination.d.ts.map +1 -0
- package/utilities/policies/pagination.js +151 -0
- package/utilities/policies/pagination.js.map +1 -0
- package/utilities/types/IsStrictlyAny.d.ts +5 -0
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -0
- package/utilities/types/IsStrictlyAny.js +2 -0
- package/utilities/types/IsStrictlyAny.js.map +1 -0
- package/utilities/utilities.cjs +1371 -0
- package/utilities/utilities.cjs.map +1 -0
- package/utilities/utilities.cjs.native.js +1371 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +2 -0
- package/version.js.map +1 -0
|
@@ -0,0 +1,890 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator } from "tslib";
|
|
2
|
+
import { invariant, InvariantError, __DEV__ } from "../utilities/globals/index.js";
|
|
3
|
+
import { equal } from '@wry/equality';
|
|
4
|
+
import { execute } from "../link/core/index.js";
|
|
5
|
+
import { isExecutionPatchIncrementalResult, isExecutionPatchResult, } from "../utilities/index.js";
|
|
6
|
+
import { canonicalStringify } from "../cache/index.js";
|
|
7
|
+
import { getDefaultValues, getOperationDefinition, getOperationName, hasClientExports, graphQLResultHasError, getGraphQLErrorsFromResult, removeConnectionDirectiveFromDocument, canUseWeakMap, Observable, asyncMap, isNonEmptyArray, Concast, makeUniqueId, isDocumentNode, isNonNullObject, } from "../utilities/index.js";
|
|
8
|
+
import { mergeIncrementalData } from "../utilities/common/incrementalResult.js";
|
|
9
|
+
import { ApolloError, isApolloError } 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
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
15
|
+
var QueryManager = (function () {
|
|
16
|
+
function QueryManager(_a) {
|
|
17
|
+
var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, _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, assumeImmutableResults = _a.assumeImmutableResults;
|
|
18
|
+
this.clientAwareness = {};
|
|
19
|
+
this.queries = new Map();
|
|
20
|
+
this.fetchCancelFns = new Map();
|
|
21
|
+
this.transformCache = new (canUseWeakMap ? WeakMap : Map)();
|
|
22
|
+
this.queryIdCounter = 1;
|
|
23
|
+
this.requestIdCounter = 1;
|
|
24
|
+
this.mutationIdCounter = 1;
|
|
25
|
+
this.inFlightLinkObservables = new Map();
|
|
26
|
+
this.cache = cache;
|
|
27
|
+
this.link = link;
|
|
28
|
+
this.defaultOptions = defaultOptions || Object.create(null);
|
|
29
|
+
this.queryDeduplication = queryDeduplication;
|
|
30
|
+
this.clientAwareness = clientAwareness;
|
|
31
|
+
this.localState = localState || new LocalState({ cache: cache });
|
|
32
|
+
this.ssrMode = ssrMode;
|
|
33
|
+
this.assumeImmutableResults = !!assumeImmutableResults;
|
|
34
|
+
if ((this.onBroadcast = onBroadcast)) {
|
|
35
|
+
this.mutationStore = Object.create(null);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
QueryManager.prototype.stop = function () {
|
|
39
|
+
var _this = this;
|
|
40
|
+
this.queries.forEach(function (_info, queryId) {
|
|
41
|
+
_this.stopQueryNoBroadcast(queryId);
|
|
42
|
+
});
|
|
43
|
+
this.cancelPendingFetches(__DEV__ ? new InvariantError('QueryManager stopped while query was in flight') : new InvariantError(14));
|
|
44
|
+
};
|
|
45
|
+
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
46
|
+
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
47
|
+
this.fetchCancelFns.clear();
|
|
48
|
+
};
|
|
49
|
+
QueryManager.prototype.mutate = function (_a) {
|
|
50
|
+
var _b, _c;
|
|
51
|
+
var mutation = _a.mutation, variables = _a.variables, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries, _d = _a.refetchQueries, refetchQueries = _d === void 0 ? [] : _d, _e = _a.awaitRefetchQueries, awaitRefetchQueries = _e === void 0 ? false : _e, updateWithProxyFn = _a.update, onQueryUpdated = _a.onQueryUpdated, _f = _a.fetchPolicy, fetchPolicy = _f === void 0 ? ((_b = this.defaultOptions.mutate) === null || _b === void 0 ? void 0 : _b.fetchPolicy) || "network-only" : _f, _g = _a.errorPolicy, errorPolicy = _g === void 0 ? ((_c = this.defaultOptions.mutate) === null || _c === void 0 ? void 0 : _c.errorPolicy) || "none" : _g, keepRootFields = _a.keepRootFields, context = _a.context;
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var mutationId, _h, document, hasClientExports, mutationStoreValue, self;
|
|
54
|
+
return __generator(this, function (_j) {
|
|
55
|
+
switch (_j.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
__DEV__ ? invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : invariant(mutation, 15);
|
|
58
|
+
__DEV__ ? invariant(fetchPolicy === 'network-only' ||
|
|
59
|
+
fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.") : invariant(fetchPolicy === 'network-only' ||
|
|
60
|
+
fetchPolicy === 'no-cache', 16);
|
|
61
|
+
mutationId = this.generateMutationId();
|
|
62
|
+
_h = this.transform(mutation), document = _h.document, hasClientExports = _h.hasClientExports;
|
|
63
|
+
mutation = this.cache.transformForLink(document);
|
|
64
|
+
variables = this.getVariables(mutation, variables);
|
|
65
|
+
if (!hasClientExports) return [3, 2];
|
|
66
|
+
return [4, this.localState.addExportedVariables(mutation, variables, context)];
|
|
67
|
+
case 1:
|
|
68
|
+
variables = (_j.sent());
|
|
69
|
+
_j.label = 2;
|
|
70
|
+
case 2:
|
|
71
|
+
mutationStoreValue = this.mutationStore &&
|
|
72
|
+
(this.mutationStore[mutationId] = {
|
|
73
|
+
mutation: mutation,
|
|
74
|
+
variables: variables,
|
|
75
|
+
loading: true,
|
|
76
|
+
error: null,
|
|
77
|
+
});
|
|
78
|
+
if (optimisticResponse) {
|
|
79
|
+
this.markMutationOptimistic(optimisticResponse, {
|
|
80
|
+
mutationId: mutationId,
|
|
81
|
+
document: mutation,
|
|
82
|
+
variables: variables,
|
|
83
|
+
fetchPolicy: fetchPolicy,
|
|
84
|
+
errorPolicy: errorPolicy,
|
|
85
|
+
context: context,
|
|
86
|
+
updateQueries: updateQueries,
|
|
87
|
+
update: updateWithProxyFn,
|
|
88
|
+
keepRootFields: keepRootFields,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
this.broadcastQueries();
|
|
92
|
+
self = this;
|
|
93
|
+
return [2, new Promise(function (resolve, reject) {
|
|
94
|
+
return asyncMap(self.getObservableFromLink(mutation, __assign(__assign({}, context), { optimisticResponse: optimisticResponse }), variables, false), function (result) {
|
|
95
|
+
if (graphQLResultHasError(result) && errorPolicy === 'none') {
|
|
96
|
+
throw new ApolloError({
|
|
97
|
+
graphQLErrors: getGraphQLErrorsFromResult(result),
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (mutationStoreValue) {
|
|
101
|
+
mutationStoreValue.loading = false;
|
|
102
|
+
mutationStoreValue.error = null;
|
|
103
|
+
}
|
|
104
|
+
var storeResult = __assign({}, result);
|
|
105
|
+
if (typeof refetchQueries === "function") {
|
|
106
|
+
refetchQueries = refetchQueries(storeResult);
|
|
107
|
+
}
|
|
108
|
+
if (errorPolicy === 'ignore' &&
|
|
109
|
+
graphQLResultHasError(storeResult)) {
|
|
110
|
+
delete storeResult.errors;
|
|
111
|
+
}
|
|
112
|
+
return self.markMutationResult({
|
|
113
|
+
mutationId: mutationId,
|
|
114
|
+
result: storeResult,
|
|
115
|
+
document: mutation,
|
|
116
|
+
variables: variables,
|
|
117
|
+
fetchPolicy: fetchPolicy,
|
|
118
|
+
errorPolicy: errorPolicy,
|
|
119
|
+
context: context,
|
|
120
|
+
update: updateWithProxyFn,
|
|
121
|
+
updateQueries: updateQueries,
|
|
122
|
+
awaitRefetchQueries: awaitRefetchQueries,
|
|
123
|
+
refetchQueries: refetchQueries,
|
|
124
|
+
removeOptimistic: optimisticResponse ? mutationId : void 0,
|
|
125
|
+
onQueryUpdated: onQueryUpdated,
|
|
126
|
+
keepRootFields: keepRootFields,
|
|
127
|
+
});
|
|
128
|
+
}).subscribe({
|
|
129
|
+
next: function (storeResult) {
|
|
130
|
+
self.broadcastQueries();
|
|
131
|
+
if (!('hasNext' in storeResult) || storeResult.hasNext === false) {
|
|
132
|
+
resolve(storeResult);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
error: function (err) {
|
|
136
|
+
if (mutationStoreValue) {
|
|
137
|
+
mutationStoreValue.loading = false;
|
|
138
|
+
mutationStoreValue.error = err;
|
|
139
|
+
}
|
|
140
|
+
if (optimisticResponse) {
|
|
141
|
+
self.cache.removeOptimistic(mutationId);
|
|
142
|
+
}
|
|
143
|
+
self.broadcastQueries();
|
|
144
|
+
reject(err instanceof ApolloError ? err : new ApolloError({
|
|
145
|
+
networkError: err,
|
|
146
|
+
}));
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
})];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
QueryManager.prototype.markMutationResult = function (mutation, cache) {
|
|
155
|
+
var _this = this;
|
|
156
|
+
if (cache === void 0) { cache = this.cache; }
|
|
157
|
+
var result = mutation.result;
|
|
158
|
+
var cacheWrites = [];
|
|
159
|
+
var skipCache = mutation.fetchPolicy === "no-cache";
|
|
160
|
+
if (!skipCache && shouldWriteResult(result, mutation.errorPolicy)) {
|
|
161
|
+
if (!isExecutionPatchIncrementalResult(result)) {
|
|
162
|
+
cacheWrites.push({
|
|
163
|
+
result: result.data,
|
|
164
|
+
dataId: 'ROOT_MUTATION',
|
|
165
|
+
query: mutation.document,
|
|
166
|
+
variables: mutation.variables,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (isExecutionPatchIncrementalResult(result) && isNonEmptyArray(result.incremental)) {
|
|
170
|
+
var diff = cache.diff({
|
|
171
|
+
id: "ROOT_MUTATION",
|
|
172
|
+
query: this.transform(mutation.document).asQuery,
|
|
173
|
+
variables: mutation.variables,
|
|
174
|
+
optimistic: false,
|
|
175
|
+
returnPartialData: true,
|
|
176
|
+
});
|
|
177
|
+
var mergedData = void 0;
|
|
178
|
+
if (diff.result) {
|
|
179
|
+
mergedData = mergeIncrementalData(diff.result, result);
|
|
180
|
+
}
|
|
181
|
+
if (typeof mergedData !== 'undefined') {
|
|
182
|
+
result.data = mergedData;
|
|
183
|
+
cacheWrites.push({
|
|
184
|
+
result: mergedData,
|
|
185
|
+
dataId: 'ROOT_MUTATION',
|
|
186
|
+
query: mutation.document,
|
|
187
|
+
variables: mutation.variables,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
var updateQueries_1 = mutation.updateQueries;
|
|
192
|
+
if (updateQueries_1) {
|
|
193
|
+
this.queries.forEach(function (_a, queryId) {
|
|
194
|
+
var observableQuery = _a.observableQuery;
|
|
195
|
+
var queryName = observableQuery && observableQuery.queryName;
|
|
196
|
+
if (!queryName || !hasOwnProperty.call(updateQueries_1, queryName)) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
var updater = updateQueries_1[queryName];
|
|
200
|
+
var _b = _this.queries.get(queryId), document = _b.document, variables = _b.variables;
|
|
201
|
+
var _c = cache.diff({
|
|
202
|
+
query: document,
|
|
203
|
+
variables: variables,
|
|
204
|
+
returnPartialData: true,
|
|
205
|
+
optimistic: false,
|
|
206
|
+
}), currentQueryResult = _c.result, complete = _c.complete;
|
|
207
|
+
if (complete && currentQueryResult) {
|
|
208
|
+
var nextQueryResult = updater(currentQueryResult, {
|
|
209
|
+
mutationResult: result,
|
|
210
|
+
queryName: document && getOperationName(document) || void 0,
|
|
211
|
+
queryVariables: variables,
|
|
212
|
+
});
|
|
213
|
+
if (nextQueryResult) {
|
|
214
|
+
cacheWrites.push({
|
|
215
|
+
result: nextQueryResult,
|
|
216
|
+
dataId: 'ROOT_QUERY',
|
|
217
|
+
query: document,
|
|
218
|
+
variables: variables,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (cacheWrites.length > 0 ||
|
|
226
|
+
mutation.refetchQueries ||
|
|
227
|
+
mutation.update ||
|
|
228
|
+
mutation.onQueryUpdated ||
|
|
229
|
+
mutation.removeOptimistic) {
|
|
230
|
+
var results_1 = [];
|
|
231
|
+
this.refetchQueries({
|
|
232
|
+
updateCache: function (cache) {
|
|
233
|
+
if (!skipCache) {
|
|
234
|
+
cacheWrites.forEach(function (write) { return cache.write(write); });
|
|
235
|
+
}
|
|
236
|
+
var update = mutation.update;
|
|
237
|
+
var isFinalResult = !isExecutionPatchResult(result) ||
|
|
238
|
+
(isExecutionPatchIncrementalResult(result) && !result.hasNext);
|
|
239
|
+
if (update) {
|
|
240
|
+
if (!skipCache) {
|
|
241
|
+
var diff = cache.diff({
|
|
242
|
+
id: "ROOT_MUTATION",
|
|
243
|
+
query: _this.transform(mutation.document).asQuery,
|
|
244
|
+
variables: mutation.variables,
|
|
245
|
+
optimistic: false,
|
|
246
|
+
returnPartialData: true,
|
|
247
|
+
});
|
|
248
|
+
if (diff.complete) {
|
|
249
|
+
result = __assign(__assign({}, result), { data: diff.result });
|
|
250
|
+
if ('incremental' in result) {
|
|
251
|
+
delete result.incremental;
|
|
252
|
+
}
|
|
253
|
+
if ('hasNext' in result) {
|
|
254
|
+
delete result.hasNext;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (isFinalResult) {
|
|
259
|
+
update(cache, result, {
|
|
260
|
+
context: mutation.context,
|
|
261
|
+
variables: mutation.variables,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (!skipCache && !mutation.keepRootFields && isFinalResult) {
|
|
266
|
+
cache.modify({
|
|
267
|
+
id: 'ROOT_MUTATION',
|
|
268
|
+
fields: function (value, _a) {
|
|
269
|
+
var fieldName = _a.fieldName, DELETE = _a.DELETE;
|
|
270
|
+
return fieldName === "__typename" ? value : DELETE;
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
include: mutation.refetchQueries,
|
|
276
|
+
optimistic: false,
|
|
277
|
+
removeOptimistic: mutation.removeOptimistic,
|
|
278
|
+
onQueryUpdated: mutation.onQueryUpdated || null,
|
|
279
|
+
}).forEach(function (result) { return results_1.push(result); });
|
|
280
|
+
if (mutation.awaitRefetchQueries || mutation.onQueryUpdated) {
|
|
281
|
+
return Promise.all(results_1).then(function () { return result; });
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return Promise.resolve(result);
|
|
285
|
+
};
|
|
286
|
+
QueryManager.prototype.markMutationOptimistic = function (optimisticResponse, mutation) {
|
|
287
|
+
var _this = this;
|
|
288
|
+
var data = typeof optimisticResponse === "function"
|
|
289
|
+
? optimisticResponse(mutation.variables)
|
|
290
|
+
: optimisticResponse;
|
|
291
|
+
return this.cache.recordOptimisticTransaction(function (cache) {
|
|
292
|
+
try {
|
|
293
|
+
_this.markMutationResult(__assign(__assign({}, mutation), { result: { data: data } }), cache);
|
|
294
|
+
}
|
|
295
|
+
catch (error) {
|
|
296
|
+
__DEV__ && invariant.error(error);
|
|
297
|
+
}
|
|
298
|
+
}, mutation.mutationId);
|
|
299
|
+
};
|
|
300
|
+
QueryManager.prototype.fetchQuery = function (queryId, options, networkStatus) {
|
|
301
|
+
return this.fetchQueryObservable(queryId, options, networkStatus).promise;
|
|
302
|
+
};
|
|
303
|
+
QueryManager.prototype.getQueryStore = function () {
|
|
304
|
+
var store = Object.create(null);
|
|
305
|
+
this.queries.forEach(function (info, queryId) {
|
|
306
|
+
store[queryId] = {
|
|
307
|
+
variables: info.variables,
|
|
308
|
+
networkStatus: info.networkStatus,
|
|
309
|
+
networkError: info.networkError,
|
|
310
|
+
graphQLErrors: info.graphQLErrors,
|
|
311
|
+
};
|
|
312
|
+
});
|
|
313
|
+
return store;
|
|
314
|
+
};
|
|
315
|
+
QueryManager.prototype.resetErrors = function (queryId) {
|
|
316
|
+
var queryInfo = this.queries.get(queryId);
|
|
317
|
+
if (queryInfo) {
|
|
318
|
+
queryInfo.networkError = undefined;
|
|
319
|
+
queryInfo.graphQLErrors = [];
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
QueryManager.prototype.transform = function (document) {
|
|
323
|
+
var transformCache = this.transformCache;
|
|
324
|
+
var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
325
|
+
if (!transformCache.has(document)) {
|
|
326
|
+
var transformed = this.cache.transformDocument(document);
|
|
327
|
+
var noConnection = removeConnectionDirectiveFromDocument(transformed);
|
|
328
|
+
var clientQuery = this.localState.clientQuery(transformed);
|
|
329
|
+
var serverQuery = noConnection &&
|
|
330
|
+
this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
|
|
331
|
+
var cacheEntry_1 = {
|
|
332
|
+
document: transformed,
|
|
333
|
+
hasClientExports: hasClientExports(transformed),
|
|
334
|
+
hasForcedResolvers: this.localState.shouldForceResolvers(transformed),
|
|
335
|
+
clientQuery: clientQuery,
|
|
336
|
+
serverQuery: serverQuery,
|
|
337
|
+
defaultVars: getDefaultValues(getOperationDefinition(transformed)),
|
|
338
|
+
asQuery: __assign(__assign({}, transformed), { definitions: transformed.definitions.map(function (def) {
|
|
339
|
+
if (def.kind === "OperationDefinition" &&
|
|
340
|
+
def.operation !== "query") {
|
|
341
|
+
return __assign(__assign({}, def), { operation: "query" });
|
|
342
|
+
}
|
|
343
|
+
return def;
|
|
344
|
+
}) })
|
|
345
|
+
};
|
|
346
|
+
var add = function (doc) {
|
|
347
|
+
if (doc && !transformCache.has(doc)) {
|
|
348
|
+
transformCache.set(doc, cacheEntry_1);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
add(document);
|
|
352
|
+
add(transformed);
|
|
353
|
+
add(clientQuery);
|
|
354
|
+
add(serverQuery);
|
|
355
|
+
}
|
|
356
|
+
return transformCache.get(document);
|
|
357
|
+
};
|
|
358
|
+
QueryManager.prototype.getVariables = function (document, variables) {
|
|
359
|
+
return __assign(__assign({}, this.transform(document).defaultVars), variables);
|
|
360
|
+
};
|
|
361
|
+
QueryManager.prototype.watchQuery = function (options) {
|
|
362
|
+
options = __assign(__assign({}, options), { variables: this.getVariables(options.query, options.variables) });
|
|
363
|
+
if (typeof options.notifyOnNetworkStatusChange === 'undefined') {
|
|
364
|
+
options.notifyOnNetworkStatusChange = false;
|
|
365
|
+
}
|
|
366
|
+
var queryInfo = new QueryInfo(this);
|
|
367
|
+
var observable = new ObservableQuery({
|
|
368
|
+
queryManager: this,
|
|
369
|
+
queryInfo: queryInfo,
|
|
370
|
+
options: options,
|
|
371
|
+
});
|
|
372
|
+
this.queries.set(observable.queryId, queryInfo);
|
|
373
|
+
queryInfo.init({
|
|
374
|
+
document: observable.query,
|
|
375
|
+
observableQuery: observable,
|
|
376
|
+
variables: observable.variables,
|
|
377
|
+
});
|
|
378
|
+
return observable;
|
|
379
|
+
};
|
|
380
|
+
QueryManager.prototype.query = function (options, queryId) {
|
|
381
|
+
var _this = this;
|
|
382
|
+
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
383
|
+
__DEV__ ? invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
384
|
+
'in the query option.') : invariant(options.query, 17);
|
|
385
|
+
__DEV__ ? invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : invariant(options.query.kind === 'Document', 18);
|
|
386
|
+
__DEV__ ? invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : invariant(!options.returnPartialData, 19);
|
|
387
|
+
__DEV__ ? invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : invariant(!options.pollInterval, 20);
|
|
388
|
+
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
389
|
+
};
|
|
390
|
+
QueryManager.prototype.generateQueryId = function () {
|
|
391
|
+
return String(this.queryIdCounter++);
|
|
392
|
+
};
|
|
393
|
+
QueryManager.prototype.generateRequestId = function () {
|
|
394
|
+
return this.requestIdCounter++;
|
|
395
|
+
};
|
|
396
|
+
QueryManager.prototype.generateMutationId = function () {
|
|
397
|
+
return String(this.mutationIdCounter++);
|
|
398
|
+
};
|
|
399
|
+
QueryManager.prototype.stopQueryInStore = function (queryId) {
|
|
400
|
+
this.stopQueryInStoreNoBroadcast(queryId);
|
|
401
|
+
this.broadcastQueries();
|
|
402
|
+
};
|
|
403
|
+
QueryManager.prototype.stopQueryInStoreNoBroadcast = function (queryId) {
|
|
404
|
+
var queryInfo = this.queries.get(queryId);
|
|
405
|
+
if (queryInfo)
|
|
406
|
+
queryInfo.stop();
|
|
407
|
+
};
|
|
408
|
+
QueryManager.prototype.clearStore = function (options) {
|
|
409
|
+
if (options === void 0) { options = {
|
|
410
|
+
discardWatches: true,
|
|
411
|
+
}; }
|
|
412
|
+
this.cancelPendingFetches(__DEV__ ? new InvariantError('Store reset while query was in flight (not completed in link chain)') : new InvariantError(21));
|
|
413
|
+
this.queries.forEach(function (queryInfo) {
|
|
414
|
+
if (queryInfo.observableQuery) {
|
|
415
|
+
queryInfo.networkStatus = NetworkStatus.loading;
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
queryInfo.stop();
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
if (this.mutationStore) {
|
|
422
|
+
this.mutationStore = Object.create(null);
|
|
423
|
+
}
|
|
424
|
+
return this.cache.reset(options);
|
|
425
|
+
};
|
|
426
|
+
QueryManager.prototype.getObservableQueries = function (include) {
|
|
427
|
+
var _this = this;
|
|
428
|
+
if (include === void 0) { include = "active"; }
|
|
429
|
+
var queries = new Map();
|
|
430
|
+
var queryNamesAndDocs = new Map();
|
|
431
|
+
var legacyQueryOptions = new Set();
|
|
432
|
+
if (Array.isArray(include)) {
|
|
433
|
+
include.forEach(function (desc) {
|
|
434
|
+
if (typeof desc === "string") {
|
|
435
|
+
queryNamesAndDocs.set(desc, false);
|
|
436
|
+
}
|
|
437
|
+
else if (isDocumentNode(desc)) {
|
|
438
|
+
queryNamesAndDocs.set(_this.transform(desc).document, false);
|
|
439
|
+
}
|
|
440
|
+
else if (isNonNullObject(desc) && desc.query) {
|
|
441
|
+
legacyQueryOptions.add(desc);
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
this.queries.forEach(function (_a, queryId) {
|
|
446
|
+
var oq = _a.observableQuery, document = _a.document;
|
|
447
|
+
if (oq) {
|
|
448
|
+
if (include === "all") {
|
|
449
|
+
queries.set(queryId, oq);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
var queryName = oq.queryName, fetchPolicy = oq.options.fetchPolicy;
|
|
453
|
+
if (fetchPolicy === "standby" ||
|
|
454
|
+
(include === "active" && !oq.hasObservers())) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
if (include === "active" ||
|
|
458
|
+
(queryName && queryNamesAndDocs.has(queryName)) ||
|
|
459
|
+
(document && queryNamesAndDocs.has(document))) {
|
|
460
|
+
queries.set(queryId, oq);
|
|
461
|
+
if (queryName)
|
|
462
|
+
queryNamesAndDocs.set(queryName, true);
|
|
463
|
+
if (document)
|
|
464
|
+
queryNamesAndDocs.set(document, true);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
if (legacyQueryOptions.size) {
|
|
469
|
+
legacyQueryOptions.forEach(function (options) {
|
|
470
|
+
var queryId = makeUniqueId("legacyOneTimeQuery");
|
|
471
|
+
var queryInfo = _this.getQuery(queryId).init({
|
|
472
|
+
document: options.query,
|
|
473
|
+
variables: options.variables,
|
|
474
|
+
});
|
|
475
|
+
var oq = new ObservableQuery({
|
|
476
|
+
queryManager: _this,
|
|
477
|
+
queryInfo: queryInfo,
|
|
478
|
+
options: __assign(__assign({}, options), { fetchPolicy: "network-only" }),
|
|
479
|
+
});
|
|
480
|
+
invariant(oq.queryId === queryId);
|
|
481
|
+
queryInfo.setObservableQuery(oq);
|
|
482
|
+
queries.set(queryId, oq);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
if (__DEV__ && queryNamesAndDocs.size) {
|
|
486
|
+
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
487
|
+
if (!included) {
|
|
488
|
+
__DEV__ && invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
return queries;
|
|
493
|
+
};
|
|
494
|
+
QueryManager.prototype.reFetchObservableQueries = function (includeStandby) {
|
|
495
|
+
var _this = this;
|
|
496
|
+
if (includeStandby === void 0) { includeStandby = false; }
|
|
497
|
+
var observableQueryPromises = [];
|
|
498
|
+
this.getObservableQueries(includeStandby ? "all" : "active").forEach(function (observableQuery, queryId) {
|
|
499
|
+
var fetchPolicy = observableQuery.options.fetchPolicy;
|
|
500
|
+
observableQuery.resetLastResults();
|
|
501
|
+
if (includeStandby ||
|
|
502
|
+
(fetchPolicy !== "standby" &&
|
|
503
|
+
fetchPolicy !== "cache-only")) {
|
|
504
|
+
observableQueryPromises.push(observableQuery.refetch());
|
|
505
|
+
}
|
|
506
|
+
_this.getQuery(queryId).setDiff(null);
|
|
507
|
+
});
|
|
508
|
+
this.broadcastQueries();
|
|
509
|
+
return Promise.all(observableQueryPromises);
|
|
510
|
+
};
|
|
511
|
+
QueryManager.prototype.setObservableQuery = function (observableQuery) {
|
|
512
|
+
this.getQuery(observableQuery.queryId).setObservableQuery(observableQuery);
|
|
513
|
+
};
|
|
514
|
+
QueryManager.prototype.startGraphQLSubscription = function (_a) {
|
|
515
|
+
var _this = this;
|
|
516
|
+
var query = _a.query, fetchPolicy = _a.fetchPolicy, errorPolicy = _a.errorPolicy, variables = _a.variables, _b = _a.context, context = _b === void 0 ? {} : _b;
|
|
517
|
+
query = this.transform(query).document;
|
|
518
|
+
variables = this.getVariables(query, variables);
|
|
519
|
+
var makeObservable = function (variables) {
|
|
520
|
+
return _this.getObservableFromLink(query, context, variables).map(function (result) {
|
|
521
|
+
if (fetchPolicy !== 'no-cache') {
|
|
522
|
+
if (shouldWriteResult(result, errorPolicy)) {
|
|
523
|
+
_this.cache.write({
|
|
524
|
+
query: query,
|
|
525
|
+
result: result.data,
|
|
526
|
+
dataId: 'ROOT_SUBSCRIPTION',
|
|
527
|
+
variables: variables,
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
_this.broadcastQueries();
|
|
531
|
+
}
|
|
532
|
+
if (graphQLResultHasError(result)) {
|
|
533
|
+
throw new ApolloError({
|
|
534
|
+
graphQLErrors: result.errors,
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
return result;
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
if (this.transform(query).hasClientExports) {
|
|
541
|
+
var observablePromise_1 = this.localState.addExportedVariables(query, variables, context).then(makeObservable);
|
|
542
|
+
return new Observable(function (observer) {
|
|
543
|
+
var sub = null;
|
|
544
|
+
observablePromise_1.then(function (observable) { return sub = observable.subscribe(observer); }, observer.error);
|
|
545
|
+
return function () { return sub && sub.unsubscribe(); };
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
return makeObservable(variables);
|
|
549
|
+
};
|
|
550
|
+
QueryManager.prototype.stopQuery = function (queryId) {
|
|
551
|
+
this.stopQueryNoBroadcast(queryId);
|
|
552
|
+
this.broadcastQueries();
|
|
553
|
+
};
|
|
554
|
+
QueryManager.prototype.stopQueryNoBroadcast = function (queryId) {
|
|
555
|
+
this.stopQueryInStoreNoBroadcast(queryId);
|
|
556
|
+
this.removeQuery(queryId);
|
|
557
|
+
};
|
|
558
|
+
QueryManager.prototype.removeQuery = function (queryId) {
|
|
559
|
+
this.fetchCancelFns.delete(queryId);
|
|
560
|
+
if (this.queries.has(queryId)) {
|
|
561
|
+
this.getQuery(queryId).stop();
|
|
562
|
+
this.queries.delete(queryId);
|
|
563
|
+
}
|
|
564
|
+
};
|
|
565
|
+
QueryManager.prototype.broadcastQueries = function () {
|
|
566
|
+
if (this.onBroadcast)
|
|
567
|
+
this.onBroadcast();
|
|
568
|
+
this.queries.forEach(function (info) { return info.notify(); });
|
|
569
|
+
};
|
|
570
|
+
QueryManager.prototype.getLocalState = function () {
|
|
571
|
+
return this.localState;
|
|
572
|
+
};
|
|
573
|
+
QueryManager.prototype.getObservableFromLink = function (query, context, variables, deduplication) {
|
|
574
|
+
var _this = this;
|
|
575
|
+
var _a;
|
|
576
|
+
if (deduplication === void 0) { deduplication = (_a = context === null || context === void 0 ? void 0 : context.queryDeduplication) !== null && _a !== void 0 ? _a : this.queryDeduplication; }
|
|
577
|
+
var observable;
|
|
578
|
+
var serverQuery = this.transform(query).serverQuery;
|
|
579
|
+
if (serverQuery) {
|
|
580
|
+
var _b = this, inFlightLinkObservables_1 = _b.inFlightLinkObservables, link = _b.link;
|
|
581
|
+
var operation = {
|
|
582
|
+
query: serverQuery,
|
|
583
|
+
variables: variables,
|
|
584
|
+
operationName: getOperationName(serverQuery) || void 0,
|
|
585
|
+
context: this.prepareContext(__assign(__assign({}, context), { forceFetch: !deduplication })),
|
|
586
|
+
};
|
|
587
|
+
context = operation.context;
|
|
588
|
+
if (deduplication) {
|
|
589
|
+
var byVariables_1 = inFlightLinkObservables_1.get(serverQuery) || new Map();
|
|
590
|
+
inFlightLinkObservables_1.set(serverQuery, byVariables_1);
|
|
591
|
+
var varJson_1 = canonicalStringify(variables);
|
|
592
|
+
observable = byVariables_1.get(varJson_1);
|
|
593
|
+
if (!observable) {
|
|
594
|
+
var concast = new Concast([
|
|
595
|
+
execute(link, operation)
|
|
596
|
+
]);
|
|
597
|
+
byVariables_1.set(varJson_1, observable = concast);
|
|
598
|
+
concast.beforeNext(function () {
|
|
599
|
+
if (byVariables_1.delete(varJson_1) &&
|
|
600
|
+
byVariables_1.size < 1) {
|
|
601
|
+
inFlightLinkObservables_1.delete(serverQuery);
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
observable = new Concast([
|
|
608
|
+
execute(link, operation)
|
|
609
|
+
]);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
observable = new Concast([
|
|
614
|
+
Observable.of({ data: {} })
|
|
615
|
+
]);
|
|
616
|
+
context = this.prepareContext(context);
|
|
617
|
+
}
|
|
618
|
+
var clientQuery = this.transform(query).clientQuery;
|
|
619
|
+
if (clientQuery) {
|
|
620
|
+
observable = asyncMap(observable, function (result) {
|
|
621
|
+
return _this.localState.runResolvers({
|
|
622
|
+
document: clientQuery,
|
|
623
|
+
remoteResult: result,
|
|
624
|
+
context: context,
|
|
625
|
+
variables: variables,
|
|
626
|
+
});
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
return observable;
|
|
630
|
+
};
|
|
631
|
+
QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
|
|
632
|
+
var requestId = queryInfo.lastRequestId = this.generateRequestId();
|
|
633
|
+
var linkDocument = this.cache.transformForLink(this.transform(queryInfo.document).document);
|
|
634
|
+
return asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
635
|
+
var graphQLErrors = getGraphQLErrorsFromResult(result);
|
|
636
|
+
var hasErrors = graphQLErrors.length > 0;
|
|
637
|
+
if (requestId >= queryInfo.lastRequestId) {
|
|
638
|
+
if (hasErrors && options.errorPolicy === "none") {
|
|
639
|
+
throw queryInfo.markError(new ApolloError({
|
|
640
|
+
graphQLErrors: graphQLErrors,
|
|
641
|
+
}));
|
|
642
|
+
}
|
|
643
|
+
queryInfo.markResult(result, linkDocument, options, cacheWriteBehavior);
|
|
644
|
+
queryInfo.markReady();
|
|
645
|
+
}
|
|
646
|
+
var aqr = {
|
|
647
|
+
data: result.data,
|
|
648
|
+
loading: false,
|
|
649
|
+
networkStatus: NetworkStatus.ready,
|
|
650
|
+
};
|
|
651
|
+
if (hasErrors && options.errorPolicy !== "ignore") {
|
|
652
|
+
aqr.errors = graphQLErrors;
|
|
653
|
+
aqr.networkStatus = NetworkStatus.error;
|
|
654
|
+
}
|
|
655
|
+
return aqr;
|
|
656
|
+
}, function (networkError) {
|
|
657
|
+
var error = isApolloError(networkError)
|
|
658
|
+
? networkError
|
|
659
|
+
: new ApolloError({ networkError: networkError });
|
|
660
|
+
if (requestId >= queryInfo.lastRequestId) {
|
|
661
|
+
queryInfo.markError(error);
|
|
662
|
+
}
|
|
663
|
+
throw error;
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
QueryManager.prototype.fetchQueryObservable = function (queryId, options, networkStatus) {
|
|
667
|
+
var _this = this;
|
|
668
|
+
if (networkStatus === void 0) { networkStatus = NetworkStatus.loading; }
|
|
669
|
+
var query = this.transform(options.query).document;
|
|
670
|
+
var variables = this.getVariables(query, options.variables);
|
|
671
|
+
var queryInfo = this.getQuery(queryId);
|
|
672
|
+
var defaults = this.defaultOptions.watchQuery;
|
|
673
|
+
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;
|
|
674
|
+
var normalized = Object.assign({}, options, {
|
|
675
|
+
query: query,
|
|
676
|
+
variables: variables,
|
|
677
|
+
fetchPolicy: fetchPolicy,
|
|
678
|
+
errorPolicy: errorPolicy,
|
|
679
|
+
returnPartialData: returnPartialData,
|
|
680
|
+
notifyOnNetworkStatusChange: notifyOnNetworkStatusChange,
|
|
681
|
+
context: context,
|
|
682
|
+
});
|
|
683
|
+
var fromVariables = function (variables) {
|
|
684
|
+
normalized.variables = variables;
|
|
685
|
+
var concastSources = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
686
|
+
if (normalized.fetchPolicy !== "standby" &&
|
|
687
|
+
concastSources.length > 0 &&
|
|
688
|
+
queryInfo.observableQuery) {
|
|
689
|
+
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
690
|
+
}
|
|
691
|
+
return concastSources;
|
|
692
|
+
};
|
|
693
|
+
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
694
|
+
this.fetchCancelFns.set(queryId, function (reason) {
|
|
695
|
+
cleanupCancelFn();
|
|
696
|
+
setTimeout(function () { return concast.cancel(reason); });
|
|
697
|
+
});
|
|
698
|
+
var concast = new Concast(this.transform(normalized.query).hasClientExports
|
|
699
|
+
? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
|
|
700
|
+
: fromVariables(normalized.variables));
|
|
701
|
+
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
702
|
+
return concast;
|
|
703
|
+
};
|
|
704
|
+
QueryManager.prototype.refetchQueries = function (_a) {
|
|
705
|
+
var _this = this;
|
|
706
|
+
var updateCache = _a.updateCache, include = _a.include, _b = _a.optimistic, optimistic = _b === void 0 ? false : _b, _c = _a.removeOptimistic, removeOptimistic = _c === void 0 ? optimistic ? makeUniqueId("refetchQueries") : void 0 : _c, onQueryUpdated = _a.onQueryUpdated;
|
|
707
|
+
var includedQueriesById = new Map();
|
|
708
|
+
if (include) {
|
|
709
|
+
this.getObservableQueries(include).forEach(function (oq, queryId) {
|
|
710
|
+
includedQueriesById.set(queryId, {
|
|
711
|
+
oq: oq,
|
|
712
|
+
lastDiff: _this.getQuery(queryId).getDiff(),
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
var results = new Map;
|
|
717
|
+
if (updateCache) {
|
|
718
|
+
this.cache.batch({
|
|
719
|
+
update: updateCache,
|
|
720
|
+
optimistic: optimistic && removeOptimistic || false,
|
|
721
|
+
removeOptimistic: removeOptimistic,
|
|
722
|
+
onWatchUpdated: function (watch, diff, lastDiff) {
|
|
723
|
+
var oq = watch.watcher instanceof QueryInfo &&
|
|
724
|
+
watch.watcher.observableQuery;
|
|
725
|
+
if (oq) {
|
|
726
|
+
if (onQueryUpdated) {
|
|
727
|
+
includedQueriesById.delete(oq.queryId);
|
|
728
|
+
var result = onQueryUpdated(oq, diff, lastDiff);
|
|
729
|
+
if (result === true) {
|
|
730
|
+
result = oq.refetch();
|
|
731
|
+
}
|
|
732
|
+
if (result !== false) {
|
|
733
|
+
results.set(oq, result);
|
|
734
|
+
}
|
|
735
|
+
return result;
|
|
736
|
+
}
|
|
737
|
+
if (onQueryUpdated !== null) {
|
|
738
|
+
includedQueriesById.set(oq.queryId, { oq: oq, lastDiff: lastDiff, diff: diff });
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
},
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
if (includedQueriesById.size) {
|
|
745
|
+
includedQueriesById.forEach(function (_a, queryId) {
|
|
746
|
+
var oq = _a.oq, lastDiff = _a.lastDiff, diff = _a.diff;
|
|
747
|
+
var result;
|
|
748
|
+
if (onQueryUpdated) {
|
|
749
|
+
if (!diff) {
|
|
750
|
+
var info = oq["queryInfo"];
|
|
751
|
+
info.reset();
|
|
752
|
+
diff = info.getDiff();
|
|
753
|
+
}
|
|
754
|
+
result = onQueryUpdated(oq, diff, lastDiff);
|
|
755
|
+
}
|
|
756
|
+
if (!onQueryUpdated || result === true) {
|
|
757
|
+
result = oq.refetch();
|
|
758
|
+
}
|
|
759
|
+
if (result !== false) {
|
|
760
|
+
results.set(oq, result);
|
|
761
|
+
}
|
|
762
|
+
if (queryId.indexOf("legacyOneTimeQuery") >= 0) {
|
|
763
|
+
_this.stopQueryNoBroadcast(queryId);
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
if (removeOptimistic) {
|
|
768
|
+
this.cache.removeOptimistic(removeOptimistic);
|
|
769
|
+
}
|
|
770
|
+
return results;
|
|
771
|
+
};
|
|
772
|
+
QueryManager.prototype.fetchQueryByPolicy = function (queryInfo, _a, networkStatus) {
|
|
773
|
+
var _this = this;
|
|
774
|
+
var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange;
|
|
775
|
+
var oldNetworkStatus = queryInfo.networkStatus;
|
|
776
|
+
queryInfo.init({
|
|
777
|
+
document: this.transform(query).document,
|
|
778
|
+
variables: variables,
|
|
779
|
+
networkStatus: networkStatus,
|
|
780
|
+
});
|
|
781
|
+
var readCache = function () { return queryInfo.getDiff(variables); };
|
|
782
|
+
var resultsFromCache = function (diff, networkStatus) {
|
|
783
|
+
if (networkStatus === void 0) { networkStatus = queryInfo.networkStatus || NetworkStatus.loading; }
|
|
784
|
+
var data = diff.result;
|
|
785
|
+
if (__DEV__ &&
|
|
786
|
+
!returnPartialData &&
|
|
787
|
+
!equal(data, {})) {
|
|
788
|
+
logMissingFieldErrors(diff.missing);
|
|
789
|
+
}
|
|
790
|
+
var fromData = function (data) { return Observable.of(__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
|
|
791
|
+
if (data && _this.transform(query).hasForcedResolvers) {
|
|
792
|
+
return _this.localState.runResolvers({
|
|
793
|
+
document: query,
|
|
794
|
+
remoteResult: { data: data },
|
|
795
|
+
context: context,
|
|
796
|
+
variables: variables,
|
|
797
|
+
onlyRunForcedResolvers: true,
|
|
798
|
+
}).then(function (resolved) { return fromData(resolved.data || void 0); });
|
|
799
|
+
}
|
|
800
|
+
if (errorPolicy === 'none' &&
|
|
801
|
+
networkStatus === NetworkStatus.refetch &&
|
|
802
|
+
Array.isArray(diff.missing)) {
|
|
803
|
+
return fromData(void 0);
|
|
804
|
+
}
|
|
805
|
+
return fromData(data);
|
|
806
|
+
};
|
|
807
|
+
var cacheWriteBehavior = fetchPolicy === "no-cache" ? 0 :
|
|
808
|
+
(networkStatus === NetworkStatus.refetch &&
|
|
809
|
+
refetchWritePolicy !== "merge") ? 1
|
|
810
|
+
: 2;
|
|
811
|
+
var resultsFromLink = function () { return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
|
|
812
|
+
variables: variables,
|
|
813
|
+
context: context,
|
|
814
|
+
fetchPolicy: fetchPolicy,
|
|
815
|
+
errorPolicy: errorPolicy,
|
|
816
|
+
}); };
|
|
817
|
+
var shouldNotify = notifyOnNetworkStatusChange &&
|
|
818
|
+
typeof oldNetworkStatus === "number" &&
|
|
819
|
+
oldNetworkStatus !== networkStatus &&
|
|
820
|
+
isNetworkRequestInFlight(networkStatus);
|
|
821
|
+
switch (fetchPolicy) {
|
|
822
|
+
default:
|
|
823
|
+
case "cache-first": {
|
|
824
|
+
var diff = readCache();
|
|
825
|
+
if (diff.complete) {
|
|
826
|
+
return [
|
|
827
|
+
resultsFromCache(diff, queryInfo.markReady()),
|
|
828
|
+
];
|
|
829
|
+
}
|
|
830
|
+
if (returnPartialData || shouldNotify) {
|
|
831
|
+
return [
|
|
832
|
+
resultsFromCache(diff),
|
|
833
|
+
resultsFromLink(),
|
|
834
|
+
];
|
|
835
|
+
}
|
|
836
|
+
return [
|
|
837
|
+
resultsFromLink(),
|
|
838
|
+
];
|
|
839
|
+
}
|
|
840
|
+
case "cache-and-network": {
|
|
841
|
+
var diff = readCache();
|
|
842
|
+
if (diff.complete || returnPartialData || shouldNotify) {
|
|
843
|
+
return [
|
|
844
|
+
resultsFromCache(diff),
|
|
845
|
+
resultsFromLink(),
|
|
846
|
+
];
|
|
847
|
+
}
|
|
848
|
+
return [
|
|
849
|
+
resultsFromLink(),
|
|
850
|
+
];
|
|
851
|
+
}
|
|
852
|
+
case "cache-only":
|
|
853
|
+
return [
|
|
854
|
+
resultsFromCache(readCache(), queryInfo.markReady()),
|
|
855
|
+
];
|
|
856
|
+
case "network-only":
|
|
857
|
+
if (shouldNotify) {
|
|
858
|
+
return [
|
|
859
|
+
resultsFromCache(readCache()),
|
|
860
|
+
resultsFromLink(),
|
|
861
|
+
];
|
|
862
|
+
}
|
|
863
|
+
return [resultsFromLink()];
|
|
864
|
+
case "no-cache":
|
|
865
|
+
if (shouldNotify) {
|
|
866
|
+
return [
|
|
867
|
+
resultsFromCache(queryInfo.getDiff()),
|
|
868
|
+
resultsFromLink(),
|
|
869
|
+
];
|
|
870
|
+
}
|
|
871
|
+
return [resultsFromLink()];
|
|
872
|
+
case "standby":
|
|
873
|
+
return [];
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
QueryManager.prototype.getQuery = function (queryId) {
|
|
877
|
+
if (queryId && !this.queries.has(queryId)) {
|
|
878
|
+
this.queries.set(queryId, new QueryInfo(this, queryId));
|
|
879
|
+
}
|
|
880
|
+
return this.queries.get(queryId);
|
|
881
|
+
};
|
|
882
|
+
QueryManager.prototype.prepareContext = function (context) {
|
|
883
|
+
if (context === void 0) { context = {}; }
|
|
884
|
+
var newContext = this.localState.prepareContext(context);
|
|
885
|
+
return __assign(__assign({}, newContext), { clientAwareness: this.clientAwareness });
|
|
886
|
+
};
|
|
887
|
+
return QueryManager;
|
|
888
|
+
}());
|
|
889
|
+
export { QueryManager };
|
|
890
|
+
//# sourceMappingURL=QueryManager.js.map
|