@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,174 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var globals = require('../../utilities/globals');
|
|
7
|
+
var graphql = require('graphql');
|
|
8
|
+
var core = require('../core');
|
|
9
|
+
var utilities = require('../../utilities');
|
|
10
|
+
|
|
11
|
+
var VERSION = 1;
|
|
12
|
+
exports.PersistedQueryLink = void 0;
|
|
13
|
+
(function (PersistedQueryLink) {
|
|
14
|
+
})(exports.PersistedQueryLink || (exports.PersistedQueryLink = {}));
|
|
15
|
+
function collectErrorsByMessage(graphQLErrors) {
|
|
16
|
+
var collected = Object.create(null);
|
|
17
|
+
if (utilities.isNonEmptyArray(graphQLErrors)) {
|
|
18
|
+
graphQLErrors.forEach(function (error) { return collected[error.message] = error; });
|
|
19
|
+
}
|
|
20
|
+
return collected;
|
|
21
|
+
}
|
|
22
|
+
var defaultOptions = {
|
|
23
|
+
disable: function (_a) {
|
|
24
|
+
var graphQLErrors = _a.graphQLErrors, operation = _a.operation;
|
|
25
|
+
var errorMessages = collectErrorsByMessage(graphQLErrors);
|
|
26
|
+
if (errorMessages.PersistedQueryNotSupported) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (errorMessages.PersistedQueryNotFound) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
var response = operation.getContext().response;
|
|
33
|
+
if (response &&
|
|
34
|
+
response.status &&
|
|
35
|
+
(response.status === 400 || response.status === 500)) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
},
|
|
40
|
+
useGETForHashedQueries: false,
|
|
41
|
+
};
|
|
42
|
+
function operationDefinesMutation(operation) {
|
|
43
|
+
return operation.query.definitions.some(function (d) { return d.kind === 'OperationDefinition' && d.operation === 'mutation'; });
|
|
44
|
+
}
|
|
45
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
46
|
+
var hashesByQuery = new WeakMap();
|
|
47
|
+
var nextHashesChildKey = 0;
|
|
48
|
+
var createPersistedQueryLink = function (options) {
|
|
49
|
+
globals.__DEV__ ? globals.invariant(options && (typeof options.sha256 === 'function' ||
|
|
50
|
+
typeof options.generateHash === 'function'), 'Missing/invalid "sha256" or "generateHash" function. Please ' +
|
|
51
|
+
'configure one using the "createPersistedQueryLink(options)" options ' +
|
|
52
|
+
'parameter.') : globals.invariant(options && (typeof options.sha256 === 'function' ||
|
|
53
|
+
typeof options.generateHash === 'function'), 25);
|
|
54
|
+
var _a = utilities.compact(defaultOptions, options), sha256 = _a.sha256, _b = _a.generateHash, generateHash = _b === void 0 ? function (query) {
|
|
55
|
+
return Promise.resolve(sha256(graphql.print(query)));
|
|
56
|
+
} : _b, disable = _a.disable, useGETForHashedQueries = _a.useGETForHashedQueries;
|
|
57
|
+
var supportsPersistedQueries = true;
|
|
58
|
+
var hashesChildKey = 'forLink' + nextHashesChildKey++;
|
|
59
|
+
var getHashPromise = function (query) {
|
|
60
|
+
return new Promise(function (resolve) { return resolve(generateHash(query)); });
|
|
61
|
+
};
|
|
62
|
+
function getQueryHash(query) {
|
|
63
|
+
if (!query || typeof query !== 'object') {
|
|
64
|
+
return getHashPromise(query);
|
|
65
|
+
}
|
|
66
|
+
var hashes = hashesByQuery.get(query);
|
|
67
|
+
if (!hashes)
|
|
68
|
+
hashesByQuery.set(query, hashes = Object.create(null));
|
|
69
|
+
return hasOwnProperty.call(hashes, hashesChildKey)
|
|
70
|
+
? hashes[hashesChildKey]
|
|
71
|
+
: hashes[hashesChildKey] = getHashPromise(query);
|
|
72
|
+
}
|
|
73
|
+
return new core.ApolloLink(function (operation, forward) {
|
|
74
|
+
globals.__DEV__ ? globals.invariant(forward, 'PersistedQueryLink cannot be the last link in the chain.') : globals.invariant(forward, 26);
|
|
75
|
+
var query = operation.query;
|
|
76
|
+
return new utilities.Observable(function (observer) {
|
|
77
|
+
var subscription;
|
|
78
|
+
var retried = false;
|
|
79
|
+
var originalFetchOptions;
|
|
80
|
+
var setFetchOptions = false;
|
|
81
|
+
var retry = function (_a, cb) {
|
|
82
|
+
var response = _a.response, networkError = _a.networkError;
|
|
83
|
+
if (!retried && ((response && response.errors) || networkError)) {
|
|
84
|
+
retried = true;
|
|
85
|
+
var graphQLErrors = [];
|
|
86
|
+
var responseErrors = response && response.errors;
|
|
87
|
+
if (utilities.isNonEmptyArray(responseErrors)) {
|
|
88
|
+
graphQLErrors.push.apply(graphQLErrors, responseErrors);
|
|
89
|
+
}
|
|
90
|
+
var networkErrors = networkError &&
|
|
91
|
+
networkError.result &&
|
|
92
|
+
networkError.result.errors;
|
|
93
|
+
if (utilities.isNonEmptyArray(networkErrors)) {
|
|
94
|
+
graphQLErrors.push.apply(graphQLErrors, networkErrors);
|
|
95
|
+
}
|
|
96
|
+
var disablePayload = {
|
|
97
|
+
response: response,
|
|
98
|
+
networkError: networkError,
|
|
99
|
+
operation: operation,
|
|
100
|
+
graphQLErrors: utilities.isNonEmptyArray(graphQLErrors) ? graphQLErrors : void 0,
|
|
101
|
+
};
|
|
102
|
+
supportsPersistedQueries = !disable(disablePayload);
|
|
103
|
+
if (collectErrorsByMessage(graphQLErrors).PersistedQueryNotFound ||
|
|
104
|
+
!supportsPersistedQueries) {
|
|
105
|
+
if (subscription)
|
|
106
|
+
subscription.unsubscribe();
|
|
107
|
+
operation.setContext({
|
|
108
|
+
http: {
|
|
109
|
+
includeQuery: true,
|
|
110
|
+
includeExtensions: supportsPersistedQueries,
|
|
111
|
+
},
|
|
112
|
+
fetchOptions: {
|
|
113
|
+
method: 'POST',
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
if (setFetchOptions) {
|
|
117
|
+
operation.setContext({ fetchOptions: originalFetchOptions });
|
|
118
|
+
}
|
|
119
|
+
subscription = forward(operation).subscribe(handler);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
cb();
|
|
124
|
+
};
|
|
125
|
+
var handler = {
|
|
126
|
+
next: function (response) {
|
|
127
|
+
retry({ response: response }, function () { return observer.next(response); });
|
|
128
|
+
},
|
|
129
|
+
error: function (networkError) {
|
|
130
|
+
retry({ networkError: networkError }, function () { return observer.error(networkError); });
|
|
131
|
+
},
|
|
132
|
+
complete: observer.complete.bind(observer),
|
|
133
|
+
};
|
|
134
|
+
operation.setContext({
|
|
135
|
+
http: {
|
|
136
|
+
includeQuery: !supportsPersistedQueries,
|
|
137
|
+
includeExtensions: supportsPersistedQueries,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
if (useGETForHashedQueries &&
|
|
141
|
+
supportsPersistedQueries &&
|
|
142
|
+
!operationDefinesMutation(operation)) {
|
|
143
|
+
operation.setContext(function (_a) {
|
|
144
|
+
var _b = _a.fetchOptions, fetchOptions = _b === void 0 ? {} : _b;
|
|
145
|
+
originalFetchOptions = fetchOptions;
|
|
146
|
+
return {
|
|
147
|
+
fetchOptions: tslib.__assign(tslib.__assign({}, fetchOptions), { method: 'GET' }),
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
setFetchOptions = true;
|
|
151
|
+
}
|
|
152
|
+
if (supportsPersistedQueries) {
|
|
153
|
+
getQueryHash(query).then(function (sha256Hash) {
|
|
154
|
+
operation.extensions.persistedQuery = {
|
|
155
|
+
version: VERSION,
|
|
156
|
+
sha256Hash: sha256Hash,
|
|
157
|
+
};
|
|
158
|
+
subscription = forward(operation).subscribe(handler);
|
|
159
|
+
}).catch(observer.error.bind(observer));
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
subscription = forward(operation).subscribe(handler);
|
|
163
|
+
}
|
|
164
|
+
return function () {
|
|
165
|
+
if (subscription)
|
|
166
|
+
subscription.unsubscribe();
|
|
167
|
+
};
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
exports.VERSION = VERSION;
|
|
173
|
+
exports.createPersistedQueryLink = createPersistedQueryLink;
|
|
174
|
+
//# sourceMappingURL=persisted-queries.cjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Operation } from '../core';
|
|
2
|
+
export interface DelayFunction {
|
|
3
|
+
(count: number, operation: Operation, error: any): number;
|
|
4
|
+
}
|
|
5
|
+
export interface DelayFunctionOptions {
|
|
6
|
+
initial?: number;
|
|
7
|
+
max?: number;
|
|
8
|
+
jitter?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function buildDelayFunction(delayOptions?: DelayFunctionOptions): DelayFunction;
|
|
11
|
+
//# sourceMappingURL=delayFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delayFunction.d.ts","sourceRoot":"","sources":["../../../src/link/retry/delayFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMpC,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,CAAC;CAC3D;AAED,MAAM,WAAW,oBAAoB;IAYnC,OAAO,CAAC,EAAE,MAAM,CAAC;IAQjB,GAAG,CAAC,EAAE,MAAM,CAAC;IAUb,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,kBAAkB,CAChC,YAAY,CAAC,EAAE,oBAAoB,GAClC,aAAa,CAkBf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function buildDelayFunction(delayOptions) {
|
|
2
|
+
var _a = delayOptions || {}, _b = _a.initial, initial = _b === void 0 ? 300 : _b, _c = _a.jitter, jitter = _c === void 0 ? true : _c, _d = _a.max, max = _d === void 0 ? Infinity : _d;
|
|
3
|
+
var baseDelay = jitter ? initial : initial / 2;
|
|
4
|
+
return function delayFunction(count) {
|
|
5
|
+
var delay = Math.min(max, baseDelay * Math.pow(2, count));
|
|
6
|
+
if (jitter) {
|
|
7
|
+
delay = Math.random() * delay;
|
|
8
|
+
}
|
|
9
|
+
return delay;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=delayFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delayFunction.js","sourceRoot":"","sources":["../../../src/link/retry/delayFunction.ts"],"names":[],"mappings":"AA2CA,MAAM,UAAU,kBAAkB,CAChC,YAAmC;IAE7B,IAAA,KAAmD,YAAY,IAAI,EAAE,EAAnE,eAAa,EAAb,OAAO,mBAAG,GAAG,KAAA,EAAE,cAAa,EAAb,MAAM,mBAAG,IAAI,KAAA,EAAE,WAAc,EAAd,GAAG,mBAAG,QAAQ,KAAuB,CAAC;IAK5E,IAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC;IAEjD,OAAO,SAAS,aAAa,CAAC,KAAa;QACzC,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,GAAG,SAAA,CAAC,EAAI,KAAK,CAAA,CAAC,CAAC;QAClD,IAAI,MAAM,EAAE;YAGV,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;SAC/B;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Operation } from '../core';\n\n/**\n * Advanced mode: a function that implements the strategy for calculating delays\n * for particular responses.\n */\nexport interface DelayFunction {\n (count: number, operation: Operation, error: any): number;\n}\n\nexport interface DelayFunctionOptions {\n /**\n * The number of milliseconds to wait before attempting the first retry.\n *\n * Delays will increase exponentially for each attempt. E.g. if this is\n * set to 100, subsequent retries will be delayed by 200, 400, 800, etc,\n * until they reach maxDelay.\n *\n * Note that if jittering is enabled, this is the _average_ delay.\n *\n * Defaults to 300.\n */\n initial?: number;\n\n /**\n * The maximum number of milliseconds that the link should wait for any\n * retry.\n *\n * Defaults to Infinity.\n */\n max?: number;\n\n /**\n * Whether delays between attempts should be randomized.\n *\n * This helps avoid thundering herd type situations by better distributing\n * load during major outages.\n *\n * Defaults to true.\n */\n jitter?: boolean;\n}\n\nexport function buildDelayFunction(\n delayOptions?: DelayFunctionOptions,\n): DelayFunction {\n const { initial = 300, jitter = true, max = Infinity } = delayOptions || {};\n // If we're jittering, baseDelay is half of the maximum delay for that\n // attempt (and is, on average, the delay we will encounter).\n // If we're not jittering, adjust baseDelay so that the first attempt\n // lines up with initialDelay, for everyone's sanity.\n const baseDelay = jitter ? initial : initial / 2;\n\n return function delayFunction(count: number) {\n let delay = Math.min(max, baseDelay * 2 ** count);\n if (jitter) {\n // We opt for a full jitter approach for a mostly uniform distribution,\n // but bound it within initialDelay and delay for everyone's sanity.\n delay = Math.random() * delay;\n }\n\n return delay;\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/link/retry/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/retry/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC","sourcesContent":["export * from './retryLink';\n"]}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var core = require('../core');
|
|
7
|
+
var utilities = require('../../utilities');
|
|
8
|
+
|
|
9
|
+
function buildDelayFunction(delayOptions) {
|
|
10
|
+
var _a = delayOptions || {}, _b = _a.initial, initial = _b === void 0 ? 300 : _b, _c = _a.jitter, jitter = _c === void 0 ? true : _c, _d = _a.max, max = _d === void 0 ? Infinity : _d;
|
|
11
|
+
var baseDelay = jitter ? initial : initial / 2;
|
|
12
|
+
return function delayFunction(count) {
|
|
13
|
+
var delay = Math.min(max, baseDelay * Math.pow(2, count));
|
|
14
|
+
if (jitter) {
|
|
15
|
+
delay = Math.random() * delay;
|
|
16
|
+
}
|
|
17
|
+
return delay;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function buildRetryFunction(retryOptions) {
|
|
22
|
+
var _a = retryOptions || {}, retryIf = _a.retryIf, _b = _a.max, max = _b === void 0 ? 5 : _b;
|
|
23
|
+
return function retryFunction(count, operation, error) {
|
|
24
|
+
if (count >= max)
|
|
25
|
+
return false;
|
|
26
|
+
return retryIf ? retryIf(error, operation) : !!error;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var RetryableOperation = (function () {
|
|
31
|
+
function RetryableOperation(operation, nextLink, delayFor, retryIf) {
|
|
32
|
+
var _this = this;
|
|
33
|
+
this.operation = operation;
|
|
34
|
+
this.nextLink = nextLink;
|
|
35
|
+
this.delayFor = delayFor;
|
|
36
|
+
this.retryIf = retryIf;
|
|
37
|
+
this.retryCount = 0;
|
|
38
|
+
this.values = [];
|
|
39
|
+
this.complete = false;
|
|
40
|
+
this.canceled = false;
|
|
41
|
+
this.observers = [];
|
|
42
|
+
this.currentSubscription = null;
|
|
43
|
+
this.onNext = function (value) {
|
|
44
|
+
_this.values.push(value);
|
|
45
|
+
for (var _i = 0, _a = _this.observers; _i < _a.length; _i++) {
|
|
46
|
+
var observer = _a[_i];
|
|
47
|
+
if (!observer)
|
|
48
|
+
continue;
|
|
49
|
+
observer.next(value);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this.onComplete = function () {
|
|
53
|
+
_this.complete = true;
|
|
54
|
+
for (var _i = 0, _a = _this.observers; _i < _a.length; _i++) {
|
|
55
|
+
var observer = _a[_i];
|
|
56
|
+
if (!observer)
|
|
57
|
+
continue;
|
|
58
|
+
observer.complete();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
this.onError = function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
62
|
+
var shouldRetry, _i, _a, observer;
|
|
63
|
+
return tslib.__generator(this, function (_b) {
|
|
64
|
+
switch (_b.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
this.retryCount += 1;
|
|
67
|
+
return [4, this.retryIf(this.retryCount, this.operation, error)];
|
|
68
|
+
case 1:
|
|
69
|
+
shouldRetry = _b.sent();
|
|
70
|
+
if (shouldRetry) {
|
|
71
|
+
this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));
|
|
72
|
+
return [2];
|
|
73
|
+
}
|
|
74
|
+
this.error = error;
|
|
75
|
+
for (_i = 0, _a = this.observers; _i < _a.length; _i++) {
|
|
76
|
+
observer = _a[_i];
|
|
77
|
+
if (!observer)
|
|
78
|
+
continue;
|
|
79
|
+
observer.error(error);
|
|
80
|
+
}
|
|
81
|
+
return [2];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}); };
|
|
85
|
+
}
|
|
86
|
+
RetryableOperation.prototype.subscribe = function (observer) {
|
|
87
|
+
if (this.canceled) {
|
|
88
|
+
throw new Error("Subscribing to a retryable link that was canceled is not supported");
|
|
89
|
+
}
|
|
90
|
+
this.observers.push(observer);
|
|
91
|
+
for (var _i = 0, _a = this.values; _i < _a.length; _i++) {
|
|
92
|
+
var value = _a[_i];
|
|
93
|
+
observer.next(value);
|
|
94
|
+
}
|
|
95
|
+
if (this.complete) {
|
|
96
|
+
observer.complete();
|
|
97
|
+
}
|
|
98
|
+
else if (this.error) {
|
|
99
|
+
observer.error(this.error);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
RetryableOperation.prototype.unsubscribe = function (observer) {
|
|
103
|
+
var index = this.observers.indexOf(observer);
|
|
104
|
+
if (index < 0) {
|
|
105
|
+
throw new Error("RetryLink BUG! Attempting to unsubscribe unknown observer!");
|
|
106
|
+
}
|
|
107
|
+
this.observers[index] = null;
|
|
108
|
+
if (this.observers.every(function (o) { return o === null; })) {
|
|
109
|
+
this.cancel();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
RetryableOperation.prototype.start = function () {
|
|
113
|
+
if (this.currentSubscription)
|
|
114
|
+
return;
|
|
115
|
+
this.try();
|
|
116
|
+
};
|
|
117
|
+
RetryableOperation.prototype.cancel = function () {
|
|
118
|
+
if (this.currentSubscription) {
|
|
119
|
+
this.currentSubscription.unsubscribe();
|
|
120
|
+
}
|
|
121
|
+
clearTimeout(this.timerId);
|
|
122
|
+
this.timerId = undefined;
|
|
123
|
+
this.currentSubscription = null;
|
|
124
|
+
this.canceled = true;
|
|
125
|
+
};
|
|
126
|
+
RetryableOperation.prototype.try = function () {
|
|
127
|
+
this.currentSubscription = this.nextLink(this.operation).subscribe({
|
|
128
|
+
next: this.onNext,
|
|
129
|
+
error: this.onError,
|
|
130
|
+
complete: this.onComplete,
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
RetryableOperation.prototype.scheduleRetry = function (delay) {
|
|
134
|
+
var _this = this;
|
|
135
|
+
if (this.timerId) {
|
|
136
|
+
throw new Error("RetryLink BUG! Encountered overlapping retries");
|
|
137
|
+
}
|
|
138
|
+
this.timerId = setTimeout(function () {
|
|
139
|
+
_this.timerId = undefined;
|
|
140
|
+
_this.try();
|
|
141
|
+
}, delay);
|
|
142
|
+
};
|
|
143
|
+
return RetryableOperation;
|
|
144
|
+
}());
|
|
145
|
+
var RetryLink = (function (_super) {
|
|
146
|
+
tslib.__extends(RetryLink, _super);
|
|
147
|
+
function RetryLink(options) {
|
|
148
|
+
var _this = _super.call(this) || this;
|
|
149
|
+
var _a = options || {}, attempts = _a.attempts, delay = _a.delay;
|
|
150
|
+
_this.delayFor =
|
|
151
|
+
typeof delay === 'function' ? delay : buildDelayFunction(delay);
|
|
152
|
+
_this.retryIf =
|
|
153
|
+
typeof attempts === 'function' ? attempts : buildRetryFunction(attempts);
|
|
154
|
+
return _this;
|
|
155
|
+
}
|
|
156
|
+
RetryLink.prototype.request = function (operation, nextLink) {
|
|
157
|
+
var retryable = new RetryableOperation(operation, nextLink, this.delayFor, this.retryIf);
|
|
158
|
+
retryable.start();
|
|
159
|
+
return new utilities.Observable(function (observer) {
|
|
160
|
+
retryable.subscribe(observer);
|
|
161
|
+
return function () {
|
|
162
|
+
retryable.unsubscribe(observer);
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
return RetryLink;
|
|
167
|
+
}(core.ApolloLink));
|
|
168
|
+
|
|
169
|
+
exports.RetryLink = RetryLink;
|
|
170
|
+
//# sourceMappingURL=retry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.cjs","sources":["delayFunction.js","retryFunction.js","retryLink.js"],"sourcesContent":["export function buildDelayFunction(delayOptions) {\n var _a = delayOptions || {}, _b = _a.initial, initial = _b === void 0 ? 300 : _b, _c = _a.jitter, jitter = _c === void 0 ? true : _c, _d = _a.max, max = _d === void 0 ? Infinity : _d;\n var baseDelay = jitter ? initial : initial / 2;\n return function delayFunction(count) {\n var delay = Math.min(max, baseDelay * Math.pow(2, count));\n if (jitter) {\n delay = Math.random() * delay;\n }\n return delay;\n };\n}\n//# sourceMappingURL=delayFunction.js.map","export function buildRetryFunction(retryOptions) {\n var _a = retryOptions || {}, retryIf = _a.retryIf, _b = _a.max, max = _b === void 0 ? 5 : _b;\n return function retryFunction(count, operation, error) {\n if (count >= max)\n return false;\n return retryIf ? retryIf(error, operation) : !!error;\n };\n}\n//# sourceMappingURL=retryFunction.js.map","import { __awaiter, __extends, __generator } from \"tslib\";\nimport { ApolloLink } from '../core';\nimport { Observable } from '../../utilities';\nimport { buildDelayFunction, } from './delayFunction';\nimport { buildRetryFunction, } from './retryFunction';\nvar RetryableOperation = (function () {\n function RetryableOperation(operation, nextLink, delayFor, retryIf) {\n var _this = this;\n this.operation = operation;\n this.nextLink = nextLink;\n this.delayFor = delayFor;\n this.retryIf = retryIf;\n this.retryCount = 0;\n this.values = [];\n this.complete = false;\n this.canceled = false;\n this.observers = [];\n this.currentSubscription = null;\n this.onNext = function (value) {\n _this.values.push(value);\n for (var _i = 0, _a = _this.observers; _i < _a.length; _i++) {\n var observer = _a[_i];\n if (!observer)\n continue;\n observer.next(value);\n }\n };\n this.onComplete = function () {\n _this.complete = true;\n for (var _i = 0, _a = _this.observers; _i < _a.length; _i++) {\n var observer = _a[_i];\n if (!observer)\n continue;\n observer.complete();\n }\n };\n this.onError = function (error) { return __awaiter(_this, void 0, void 0, function () {\n var shouldRetry, _i, _a, observer;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n this.retryCount += 1;\n return [4, this.retryIf(this.retryCount, this.operation, error)];\n case 1:\n shouldRetry = _b.sent();\n if (shouldRetry) {\n this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));\n return [2];\n }\n this.error = error;\n for (_i = 0, _a = this.observers; _i < _a.length; _i++) {\n observer = _a[_i];\n if (!observer)\n continue;\n observer.error(error);\n }\n return [2];\n }\n });\n }); };\n }\n RetryableOperation.prototype.subscribe = function (observer) {\n if (this.canceled) {\n throw new Error(\"Subscribing to a retryable link that was canceled is not supported\");\n }\n this.observers.push(observer);\n for (var _i = 0, _a = this.values; _i < _a.length; _i++) {\n var value = _a[_i];\n observer.next(value);\n }\n if (this.complete) {\n observer.complete();\n }\n else if (this.error) {\n observer.error(this.error);\n }\n };\n RetryableOperation.prototype.unsubscribe = function (observer) {\n var index = this.observers.indexOf(observer);\n if (index < 0) {\n throw new Error(\"RetryLink BUG! Attempting to unsubscribe unknown observer!\");\n }\n this.observers[index] = null;\n if (this.observers.every(function (o) { return o === null; })) {\n this.cancel();\n }\n };\n RetryableOperation.prototype.start = function () {\n if (this.currentSubscription)\n return;\n this.try();\n };\n RetryableOperation.prototype.cancel = function () {\n if (this.currentSubscription) {\n this.currentSubscription.unsubscribe();\n }\n clearTimeout(this.timerId);\n this.timerId = undefined;\n this.currentSubscription = null;\n this.canceled = true;\n };\n RetryableOperation.prototype.try = function () {\n this.currentSubscription = this.nextLink(this.operation).subscribe({\n next: this.onNext,\n error: this.onError,\n complete: this.onComplete,\n });\n };\n RetryableOperation.prototype.scheduleRetry = function (delay) {\n var _this = this;\n if (this.timerId) {\n throw new Error(\"RetryLink BUG! Encountered overlapping retries\");\n }\n this.timerId = setTimeout(function () {\n _this.timerId = undefined;\n _this.try();\n }, delay);\n };\n return RetryableOperation;\n}());\nvar RetryLink = (function (_super) {\n __extends(RetryLink, _super);\n function RetryLink(options) {\n var _this = _super.call(this) || this;\n var _a = options || {}, attempts = _a.attempts, delay = _a.delay;\n _this.delayFor =\n typeof delay === 'function' ? delay : buildDelayFunction(delay);\n _this.retryIf =\n typeof attempts === 'function' ? attempts : buildRetryFunction(attempts);\n return _this;\n }\n RetryLink.prototype.request = function (operation, nextLink) {\n var retryable = new RetryableOperation(operation, nextLink, this.delayFor, this.retryIf);\n retryable.start();\n return new Observable(function (observer) {\n retryable.subscribe(observer);\n return function () {\n retryable.unsubscribe(observer);\n };\n });\n };\n return RetryLink;\n}(ApolloLink));\nexport { RetryLink };\n//# sourceMappingURL=retryLink.js.map"],"names":["__awaiter","__generator","__extends","Observable","ApolloLink"],"mappings":";;;;;;;;AAAO,SAAS,kBAAkB,CAAC,YAAY,EAAE;AACjD,IAAI,IAAI,EAAE,GAAG,YAAY,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,OAAO,GAAG,EAAE,KAAK,KAAK,CAAC,GAAG,GAAG,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,KAAK,KAAK,CAAC,GAAG,IAAI,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,KAAK,KAAK,CAAC,GAAG,QAAQ,GAAG,EAAE,CAAC;AAC3L,IAAI,IAAI,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,CAAC,CAAC;AACnD,IAAI,OAAO,SAAS,aAAa,CAAC,KAAK,EAAE;AACzC,QAAQ,IAAI,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAClE,QAAQ,IAAI,MAAM,EAAE;AACpB,YAAY,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;AAC1C,SAAS;AACT,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK,CAAC;AACN;;ACVO,SAAS,kBAAkB,CAAC,YAAY,EAAE;AACjD,IAAI,IAAI,EAAE,GAAG,YAAY,IAAI,EAAE,EAAE,OAAO,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,KAAK,KAAK,CAAC,GAAG,CAAC,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C,QAAQ,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC;AACzE,QAAQ,KAAK,CAAC,QAAQ;AACtB,YAAY,OAAO,KAAK,KAAK,UAAU,GAAG,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;AAC5E,QAAQ,KAAK,CAAC,OAAO;AACrB,YAAY,OAAO,QAAQ,KAAK,UAAU,GAAG,QAAQ,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACrF,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,SAAS,EAAE,QAAQ,EAAE;AACjE,QAAQ,IAAI,SAAS,GAAG,IAAI,kBAAkB,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AACjG,QAAQ,SAAS,CAAC,KAAK,EAAE,CAAC;AAC1B,QAAQ,OAAO,IAAIC,oBAAU,CAAC,UAAU,QAAQ,EAAE;AAClD,YAAY,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC1C,YAAY,OAAO,YAAY;AAC/B,gBAAgB,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAChD,aAAa,CAAC;AACd,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAACC,eAAU,CAAC;;;;"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var core = require('../core');
|
|
7
|
+
var utilities = require('../../utilities');
|
|
8
|
+
|
|
9
|
+
function buildDelayFunction(delayOptions) {
|
|
10
|
+
var _a = delayOptions || {}, _b = _a.initial, initial = _b === void 0 ? 300 : _b, _c = _a.jitter, jitter = _c === void 0 ? true : _c, _d = _a.max, max = _d === void 0 ? Infinity : _d;
|
|
11
|
+
var baseDelay = jitter ? initial : initial / 2;
|
|
12
|
+
return function delayFunction(count) {
|
|
13
|
+
var delay = Math.min(max, baseDelay * Math.pow(2, count));
|
|
14
|
+
if (jitter) {
|
|
15
|
+
delay = Math.random() * delay;
|
|
16
|
+
}
|
|
17
|
+
return delay;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function buildRetryFunction(retryOptions) {
|
|
22
|
+
var _a = retryOptions || {}, retryIf = _a.retryIf, _b = _a.max, max = _b === void 0 ? 5 : _b;
|
|
23
|
+
return function retryFunction(count, operation, error) {
|
|
24
|
+
if (count >= max)
|
|
25
|
+
return false;
|
|
26
|
+
return retryIf ? retryIf(error, operation) : !!error;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var RetryableOperation = (function () {
|
|
31
|
+
function RetryableOperation(operation, nextLink, delayFor, retryIf) {
|
|
32
|
+
var _this = this;
|
|
33
|
+
this.operation = operation;
|
|
34
|
+
this.nextLink = nextLink;
|
|
35
|
+
this.delayFor = delayFor;
|
|
36
|
+
this.retryIf = retryIf;
|
|
37
|
+
this.retryCount = 0;
|
|
38
|
+
this.values = [];
|
|
39
|
+
this.complete = false;
|
|
40
|
+
this.canceled = false;
|
|
41
|
+
this.observers = [];
|
|
42
|
+
this.currentSubscription = null;
|
|
43
|
+
this.onNext = function (value) {
|
|
44
|
+
_this.values.push(value);
|
|
45
|
+
for (var _i = 0, _a = _this.observers; _i < _a.length; _i++) {
|
|
46
|
+
var observer = _a[_i];
|
|
47
|
+
if (!observer)
|
|
48
|
+
continue;
|
|
49
|
+
observer.next(value);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this.onComplete = function () {
|
|
53
|
+
_this.complete = true;
|
|
54
|
+
for (var _i = 0, _a = _this.observers; _i < _a.length; _i++) {
|
|
55
|
+
var observer = _a[_i];
|
|
56
|
+
if (!observer)
|
|
57
|
+
continue;
|
|
58
|
+
observer.complete();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
this.onError = function (error) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
62
|
+
var shouldRetry, _i, _a, observer;
|
|
63
|
+
return tslib.__generator(this, function (_b) {
|
|
64
|
+
switch (_b.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
this.retryCount += 1;
|
|
67
|
+
return [4, this.retryIf(this.retryCount, this.operation, error)];
|
|
68
|
+
case 1:
|
|
69
|
+
shouldRetry = _b.sent();
|
|
70
|
+
if (shouldRetry) {
|
|
71
|
+
this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));
|
|
72
|
+
return [2];
|
|
73
|
+
}
|
|
74
|
+
this.error = error;
|
|
75
|
+
for (_i = 0, _a = this.observers; _i < _a.length; _i++) {
|
|
76
|
+
observer = _a[_i];
|
|
77
|
+
if (!observer)
|
|
78
|
+
continue;
|
|
79
|
+
observer.error(error);
|
|
80
|
+
}
|
|
81
|
+
return [2];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}); };
|
|
85
|
+
}
|
|
86
|
+
RetryableOperation.prototype.subscribe = function (observer) {
|
|
87
|
+
if (this.canceled) {
|
|
88
|
+
throw new Error("Subscribing to a retryable link that was canceled is not supported");
|
|
89
|
+
}
|
|
90
|
+
this.observers.push(observer);
|
|
91
|
+
for (var _i = 0, _a = this.values; _i < _a.length; _i++) {
|
|
92
|
+
var value = _a[_i];
|
|
93
|
+
observer.next(value);
|
|
94
|
+
}
|
|
95
|
+
if (this.complete) {
|
|
96
|
+
observer.complete();
|
|
97
|
+
}
|
|
98
|
+
else if (this.error) {
|
|
99
|
+
observer.error(this.error);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
RetryableOperation.prototype.unsubscribe = function (observer) {
|
|
103
|
+
var index = this.observers.indexOf(observer);
|
|
104
|
+
if (index < 0) {
|
|
105
|
+
throw new Error("RetryLink BUG! Attempting to unsubscribe unknown observer!");
|
|
106
|
+
}
|
|
107
|
+
this.observers[index] = null;
|
|
108
|
+
if (this.observers.every(function (o) { return o === null; })) {
|
|
109
|
+
this.cancel();
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
RetryableOperation.prototype.start = function () {
|
|
113
|
+
if (this.currentSubscription)
|
|
114
|
+
return;
|
|
115
|
+
this.try();
|
|
116
|
+
};
|
|
117
|
+
RetryableOperation.prototype.cancel = function () {
|
|
118
|
+
if (this.currentSubscription) {
|
|
119
|
+
this.currentSubscription.unsubscribe();
|
|
120
|
+
}
|
|
121
|
+
clearTimeout(this.timerId);
|
|
122
|
+
this.timerId = undefined;
|
|
123
|
+
this.currentSubscription = null;
|
|
124
|
+
this.canceled = true;
|
|
125
|
+
};
|
|
126
|
+
RetryableOperation.prototype.try = function () {
|
|
127
|
+
this.currentSubscription = this.nextLink(this.operation).subscribe({
|
|
128
|
+
next: this.onNext,
|
|
129
|
+
error: this.onError,
|
|
130
|
+
complete: this.onComplete,
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
RetryableOperation.prototype.scheduleRetry = function (delay) {
|
|
134
|
+
var _this = this;
|
|
135
|
+
if (this.timerId) {
|
|
136
|
+
throw new Error("RetryLink BUG! Encountered overlapping retries");
|
|
137
|
+
}
|
|
138
|
+
this.timerId = setTimeout(function () {
|
|
139
|
+
_this.timerId = undefined;
|
|
140
|
+
_this.try();
|
|
141
|
+
}, delay);
|
|
142
|
+
};
|
|
143
|
+
return RetryableOperation;
|
|
144
|
+
}());
|
|
145
|
+
var RetryLink = (function (_super) {
|
|
146
|
+
tslib.__extends(RetryLink, _super);
|
|
147
|
+
function RetryLink(options) {
|
|
148
|
+
var _this = _super.call(this) || this;
|
|
149
|
+
var _a = options || {}, attempts = _a.attempts, delay = _a.delay;
|
|
150
|
+
_this.delayFor =
|
|
151
|
+
typeof delay === 'function' ? delay : buildDelayFunction(delay);
|
|
152
|
+
_this.retryIf =
|
|
153
|
+
typeof attempts === 'function' ? attempts : buildRetryFunction(attempts);
|
|
154
|
+
return _this;
|
|
155
|
+
}
|
|
156
|
+
RetryLink.prototype.request = function (operation, nextLink) {
|
|
157
|
+
var retryable = new RetryableOperation(operation, nextLink, this.delayFor, this.retryIf);
|
|
158
|
+
retryable.start();
|
|
159
|
+
return new utilities.Observable(function (observer) {
|
|
160
|
+
retryable.subscribe(observer);
|
|
161
|
+
return function () {
|
|
162
|
+
retryable.unsubscribe(observer);
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
return RetryLink;
|
|
167
|
+
}(core.ApolloLink));
|
|
168
|
+
|
|
169
|
+
exports.RetryLink = RetryLink;
|
|
170
|
+
//# sourceMappingURL=retry.cjs.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Operation } from '../core';
|
|
2
|
+
export interface RetryFunction {
|
|
3
|
+
(count: number, operation: Operation, error: any): boolean | Promise<boolean>;
|
|
4
|
+
}
|
|
5
|
+
export interface RetryFunctionOptions {
|
|
6
|
+
max?: number;
|
|
7
|
+
retryIf?: (error: any, operation: Operation) => boolean | Promise<boolean>;
|
|
8
|
+
}
|
|
9
|
+
export declare function buildRetryFunction(retryOptions?: RetryFunctionOptions): RetryFunction;
|
|
10
|
+
//# sourceMappingURL=retryFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryFunction.d.ts","sourceRoot":"","sources":["../../../src/link/retry/retryFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAMpC,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/E;AAED,MAAM,WAAW,oBAAoB;IASnC,GAAG,CAAC,EAAE,MAAM,CAAC;IAUb,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5E;AAED,wBAAgB,kBAAkB,CAChC,YAAY,CAAC,EAAE,oBAAoB,GAClC,aAAa,CAMf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function buildRetryFunction(retryOptions) {
|
|
2
|
+
var _a = retryOptions || {}, retryIf = _a.retryIf, _b = _a.max, max = _b === void 0 ? 5 : _b;
|
|
3
|
+
return function retryFunction(count, operation, error) {
|
|
4
|
+
if (count >= max)
|
|
5
|
+
return false;
|
|
6
|
+
return retryIf ? retryIf(error, operation) : !!error;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=retryFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryFunction.js","sourceRoot":"","sources":["../../../src/link/retry/retryFunction.ts"],"names":[],"mappings":"AAgCA,MAAM,UAAU,kBAAkB,CAChC,YAAmC;IAE7B,IAAA,KAAuB,YAAY,IAAK,EAA2B,EAAjE,OAAO,aAAA,EAAE,WAAO,EAAP,GAAG,mBAAG,CAAC,KAAiD,CAAC;IAC1E,OAAO,SAAS,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK;QACnD,IAAI,KAAK,IAAI,GAAG;YAAE,OAAO,KAAK,CAAC;QAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACvD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { Operation } from '../core';\n\n/**\n * Advanced mode: a function that determines both whether a particular\n * response should be retried.\n */\nexport interface RetryFunction {\n (count: number, operation: Operation, error: any): boolean | Promise<boolean>;\n}\n\nexport interface RetryFunctionOptions {\n /**\n * The max number of times to try a single operation before giving up.\n *\n * Note that this INCLUDES the initial request as part of the count.\n * E.g. maxTries of 1 indicates no retrying should occur.\n *\n * Defaults to 5. Pass Infinity for infinite retries.\n */\n max?: number;\n\n /**\n * Predicate function that determines whether a particular error should\n * trigger a retry.\n *\n * For example, you may want to not retry 4xx class HTTP errors.\n *\n * By default, all errors are retried.\n */\n retryIf?: (error: any, operation: Operation) => boolean | Promise<boolean>;\n}\n\nexport function buildRetryFunction(\n retryOptions?: RetryFunctionOptions,\n): RetryFunction {\n const { retryIf, max = 5 } = retryOptions || ({} as RetryFunctionOptions);\n return function retryFunction(count, operation, error) {\n if (count >= max) return false;\n return retryIf ? retryIf(error, operation) : !!error;\n };\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ApolloLink, Operation, FetchResult, NextLink } from '../core';
|
|
2
|
+
import { Observable } from '../../utilities';
|
|
3
|
+
import { DelayFunction, DelayFunctionOptions } from './delayFunction';
|
|
4
|
+
import { RetryFunction, RetryFunctionOptions } from './retryFunction';
|
|
5
|
+
export declare namespace RetryLink {
|
|
6
|
+
interface Options {
|
|
7
|
+
delay?: DelayFunctionOptions | DelayFunction;
|
|
8
|
+
attempts?: RetryFunctionOptions | RetryFunction;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare class RetryLink extends ApolloLink {
|
|
12
|
+
private delayFor;
|
|
13
|
+
private retryIf;
|
|
14
|
+
constructor(options?: RetryLink.Options);
|
|
15
|
+
request(operation: Operation, nextLink: NextLink): Observable<FetchResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=retryLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retryLink.d.ts","sourceRoot":"","sources":["../../../src/link/retry/retryLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,UAAU,EAAoC,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EACL,aAAa,EACb,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,oBAAoB,EAErB,MAAM,iBAAiB,CAAC;AAEzB,yBAAiB,SAAS,CAAC;IACzB,UAAiB,OAAO;QAItB,KAAK,CAAC,EAAE,oBAAoB,GAAG,aAAa,CAAC;QAK7C,QAAQ,CAAC,EAAE,oBAAoB,GAAG,aAAa,CAAC;KACjD;CACF;AAsJD,qBAAa,SAAU,SAAQ,UAAU;IACvC,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,OAAO,CAAgB;gBAEnB,OAAO,CAAC,EAAE,SAAS,CAAC,OAAO;IAShC,OAAO,CACZ,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,GACjB,UAAU,CAAC,WAAW,CAAC;CAgB3B"}
|