@apollo/client 3.8.7 → 3.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/README.md +8 -0
- package/.changeset/config.json +14 -0
- package/CHANGELOG.md +3369 -0
- package/apollo-client.cjs +356 -354
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +133 -152
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +133 -152
- package/cache/core/cache.d.ts +10 -0
- package/cache/core/cache.js +17 -5
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +1 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +92 -0
- package/cache/core/types/common.js +4 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -1
- package/cache/inmemory/entityStore.js +190 -29
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fixPolyfills.js +9 -0
- package/cache/inmemory/fixPolyfills.js.map +1 -1
- package/cache/inmemory/fixPolyfills.native.js +12 -0
- package/cache/inmemory/fixPolyfills.native.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +23 -12
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.js +20 -11
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.js +161 -8
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +72 -4
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/object-canon.js +91 -3
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.js +193 -43
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.js +20 -2
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +4 -0
- package/cache/inmemory/readFromStore.js +54 -9
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +28 -0
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +152 -25
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/setup.js +2 -0
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +264 -3
- package/core/ApolloClient.js +235 -7
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +4 -6
- package/core/LocalState.js +56 -18
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +25 -0
- package/core/ObservableQuery.js +239 -30
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +3 -3
- package/core/QueryInfo.js +116 -13
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +4 -0
- package/core/QueryManager.js +229 -33
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +112 -103
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +112 -103
- package/core/equalByQuery.js +20 -1
- package/core/equalByQuery.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +19 -0
- package/core/index.js.map +1 -1
- package/core/networkStatus.d.ts +39 -0
- package/core/networkStatus.js +39 -0
- package/core/networkStatus.js.map +1 -1
- package/core/types.d.ts +9 -0
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +225 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +5 -111
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +5 -111
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/errors/errors.cjs +1 -1
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +1 -1
- package/errors/index.js +14 -1
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +1 -0
- package/link/batch/batch.cjs +2 -2
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +2 -2
- package/link/batch/batchLink.d.ts +21 -0
- package/link/batch/batchLink.js +2 -1
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.js +24 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +3 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +3 -2
- package/link/batch-http/batchHttpLink.d.ts +4 -0
- package/link/batch-http/batchHttpLink.js +53 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/context.cjs.map +1 -1
- package/link/context/index.js +1 -0
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.js +12 -5
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +5 -5
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +5 -5
- package/link/error/error.cjs +1 -1
- package/link/error/error.cjs.map +1 -1
- package/link/error/error.cjs.native.js +1 -1
- package/link/error/index.d.ts +3 -0
- package/link/error/index.js +4 -1
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +0 -2
- package/link/http/HttpLink.js +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.d.ts +1 -1
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.js +23 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/createSignalIfSupported.d.ts +5 -0
- package/link/http/createSignalIfSupported.js +5 -0
- package/link/http/createSignalIfSupported.js.map +1 -1
- package/link/http/http.cjs +14 -15
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +14 -15
- package/link/http/index.js +2 -1
- package/link/http/index.js.map +1 -1
- package/link/http/iterators/async.d.ts +4 -0
- package/link/http/iterators/async.js +4 -0
- package/link/http/iterators/async.js.map +1 -1
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.js +4 -0
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/iterators/promise.d.ts +4 -0
- package/link/http/iterators/promise.js +4 -0
- package/link/http/iterators/promise.js.map +1 -1
- package/link/http/iterators/reader.d.ts +4 -0
- package/link/http/iterators/reader.js +4 -0
- package/link/http/iterators/reader.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +50 -13
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts +4 -0
- package/link/http/responseIterator.js +6 -0
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +1 -1
- package/link/http/rewriteURIForGET.js +10 -0
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +46 -1
- package/link/http/selectHttpOptionsAndBody.js +23 -0
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.js +34 -4
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +4 -4
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +4 -4
- package/link/remove-typename/remove-typename.cjs +12 -9
- package/link/remove-typename/remove-typename.cjs.map +1 -1
- package/link/remove-typename/remove-typename.cjs.native.js +12 -9
- package/link/remove-typename/removeTypenameFromVariables.js +12 -9
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/delayFunction.d.ts +29 -0
- package/link/retry/delayFunction.js +6 -0
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retry.cjs +5 -5
- package/link/retry/retry.cjs.map +1 -1
- package/link/retry/retry.cjs.native.js +5 -5
- package/link/retry/retryFunction.d.ts +20 -0
- package/link/retry/retryLink.d.ts +6 -0
- package/link/retry/retryLink.js +31 -6
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +13 -0
- package/link/schema/index.js +3 -3
- package/link/schema/index.js.map +1 -1
- package/link/schema/schema.cjs +3 -3
- package/link/schema/schema.cjs.map +1 -1
- package/link/schema/schema.cjs.native.js +3 -3
- package/link/subscriptions/index.js +35 -2
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +3 -2
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +3 -2
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/filterOperationVariables.js +4 -0
- package/link/utils/filterOperationVariables.js.map +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/transformOperation.js +3 -2
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +12 -0
- package/link/ws/index.js +1 -1
- package/link/ws/index.js.map +1 -1
- package/link/ws/ws.cjs +1 -1
- package/link/ws/ws.cjs.map +1 -1
- package/link/ws/ws.cjs.native.js +1 -1
- package/package.json +56 -45
- package/react/cache/QueryReference.d.ts +6 -1
- package/react/cache/QueryReference.js +26 -1
- package/react/cache/QueryReference.js.map +1 -1
- package/react/cache/SuspenseCache.d.ts +10 -0
- package/react/cache/SuspenseCache.js +1 -1
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/cache/getSuspenseCache.js.map +1 -1
- package/react/context/ApolloContext.d.ts +5 -0
- package/react/context/ApolloContext.js +10 -3
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/context.cjs +1 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +1 -3
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.js +3 -1
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs +9 -17
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +9 -17
- package/react/hoc/mutation-hoc.js +9 -4
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.js +10 -4
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.js +10 -4
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.js +3 -4
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +72 -57
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +72 -57
- package/react/hooks/internal/__use.js +5 -0
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/internal/index.d.ts +1 -0
- package/react/hooks/internal/index.js +2 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -3
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/internal/useLazyRef.d.ts +3 -0
- package/react/hooks/internal/useLazyRef.js +10 -0
- package/react/hooks/internal/useLazyRef.js.map +1 -0
- package/react/hooks/useBackgroundQuery.js +6 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +21 -17
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +13 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.js +8 -3
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +11 -0
- package/react/hooks/useQuery.js +137 -5
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReactiveVar.js +5 -0
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +19 -0
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +5 -0
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +11 -5
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +53 -1
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/parser/index.js +4 -5
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +2 -4
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +2 -4
- package/react/ssr/RenderPromises.js +21 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/getDataFromTree.js +18 -3
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/ssr.cjs +6 -4
- package/react/ssr/ssr.cjs.map +1 -1
- package/react/ssr/ssr.cjs.native.js +6 -4
- package/react/types/types.d.ts +66 -0
- package/testing/core/core.cjs +18 -13
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +18 -13
- package/testing/core/itAsync.d.ts +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockFetch.d.ts +2 -2
- package/testing/core/mocking/mockFetch.js +8 -4
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.js +25 -9
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.js +2 -0
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.js +1 -1
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +17 -3
- package/testing/core/observableToPromise.js +5 -0
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/subscribeAndCount.js +3 -0
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/core/wait.js +2 -2
- package/testing/core/wait.js.map +1 -1
- package/testing/core/withConsoleSpy.d.ts +3 -0
- package/testing/core/withConsoleSpy.js +7 -1
- package/testing/core/withConsoleSpy.js.map +1 -1
- package/testing/core/wrap.js +2 -0
- package/testing/core/wrap.js.map +1 -1
- package/testing/internal/ObservableStream.js +14 -14
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/disposables/spyOnConsole.d.ts +1 -0
- package/testing/internal/disposables/spyOnConsole.js +2 -0
- package/testing/internal/disposables/spyOnConsole.js.map +1 -1
- package/testing/internal/disposables/withCleanup.d.ts +1 -0
- package/testing/internal/disposables/withCleanup.js +3 -0
- package/testing/internal/disposables/withCleanup.js.map +1 -1
- package/testing/internal/profile/Render.d.ts +28 -0
- package/testing/internal/profile/Render.js +12 -1
- package/testing/internal/profile/Render.js.map +1 -1
- package/testing/internal/profile/profile.d.ts +44 -7
- package/testing/internal/profile/profile.js +63 -51
- package/testing/internal/profile/profile.js.map +1 -1
- package/testing/internal/profile/traces.d.ts +4 -0
- package/testing/internal/profile/traces.js +9 -5
- package/testing/internal/profile/traces.js.map +1 -1
- package/testing/matchers/ProfiledComponent.js +27 -22
- package/testing/matchers/ProfiledComponent.js.map +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +4 -0
- package/testing/react/MockedProvider.js +6 -2
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +4 -2
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +4 -2
- package/utilities/common/arrays.js +1 -0
- package/utilities/common/arrays.js.map +1 -1
- package/utilities/common/canUse.js +16 -1
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/cloneDeep.d.ts +3 -0
- package/utilities/common/cloneDeep.js +5 -0
- package/utilities/common/cloneDeep.js.map +1 -1
- package/utilities/common/compact.d.ts +4 -0
- package/utilities/common/compact.js +4 -0
- package/utilities/common/compact.js.map +1 -1
- package/utilities/common/errorHandling.js +1 -3
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.js +3 -0
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/makeUniqueId.js +2 -0
- package/utilities/common/makeUniqueId.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +3 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.js +12 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/omitDeep.js.map +1 -1
- package/utilities/globals/global.js +7 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +4 -5
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +4 -5
- package/utilities/globals/index.d.ts +4 -0
- package/utilities/globals/index.js +7 -0
- package/utilities/globals/index.js.map +1 -1
- package/utilities/globals/invariantWrappers.d.ts +40 -0
- package/utilities/globals/invariantWrappers.js +11 -3
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/globals/maybe.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +19 -6
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/directives.js +3 -0
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +25 -0
- package/utilities/graphql/fragments.js +36 -0
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +5 -0
- package/utilities/graphql/getFromAST.js +9 -0
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +14 -0
- package/utilities/graphql/storeUtils.js +7 -2
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.js +106 -7
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/observables/Concast.d.ts +1 -1
- package/utilities/observables/Concast.js +84 -1
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/Observable.js +6 -0
- package/utilities/observables/Observable.js.map +1 -1
- package/utilities/observables/asyncMap.js +12 -3
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/observables/iteration.js +3 -0
- package/utilities/observables/iteration.js.map +1 -1
- package/utilities/observables/subclassing.js +14 -0
- package/utilities/observables/subclassing.js.map +1 -1
- package/utilities/policies/pagination.js +47 -3
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/promises/decoration.js +1 -0
- package/utilities/promises/decoration.js.map +1 -1
- package/utilities/types/DeepOmit.js.map +1 -1
- package/utilities/types/DeepPartial.d.ts +1 -1
- package/utilities/types/DeepPartial.js +4 -0
- package/utilities/types/DeepPartial.js.map +1 -1
- package/utilities/types/IsStrictlyAny.js.map +1 -1
- package/utilities/types/TODO.d.ts +3 -0
- package/utilities/types/TODO.js +2 -0
- package/utilities/types/TODO.js.map +1 -0
- package/utilities/utilities.cjs +31 -27
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +31 -27
- package/version.js +1 -1
- package/cache/core/cache.d.ts.map +0 -1
- package/cache/core/types/Cache.d.ts.map +0 -1
- package/cache/core/types/DataProxy.d.ts.map +0 -1
- package/cache/core/types/common.d.ts.map +0 -1
- package/cache/index.d.ts.map +0 -1
- package/cache/inmemory/entityStore.d.ts.map +0 -1
- package/cache/inmemory/fixPolyfills.d.ts.map +0 -1
- package/cache/inmemory/fixPolyfills.native.d.ts.map +0 -1
- package/cache/inmemory/fragmentRegistry.d.ts.map +0 -1
- package/cache/inmemory/helpers.d.ts.map +0 -1
- package/cache/inmemory/inMemoryCache.d.ts.map +0 -1
- package/cache/inmemory/key-extractor.d.ts.map +0 -1
- package/cache/inmemory/object-canon.d.ts.map +0 -1
- package/cache/inmemory/policies.d.ts.map +0 -1
- package/cache/inmemory/reactiveVars.d.ts.map +0 -1
- package/cache/inmemory/readFromStore.d.ts.map +0 -1
- package/cache/inmemory/types.d.ts.map +0 -1
- package/cache/inmemory/writeToStore.d.ts.map +0 -1
- package/config/jest/setup.d.ts.map +0 -1
- package/core/ApolloClient.d.ts.map +0 -1
- package/core/LocalState.d.ts.map +0 -1
- package/core/ObservableQuery.d.ts.map +0 -1
- package/core/QueryInfo.d.ts.map +0 -1
- package/core/QueryManager.d.ts.map +0 -1
- package/core/equalByQuery.d.ts.map +0 -1
- package/core/index.d.ts.map +0 -1
- package/core/networkStatus.d.ts.map +0 -1
- package/core/types.d.ts.map +0 -1
- package/core/watchQueryOptions.d.ts.map +0 -1
- package/dev/index.d.ts.map +0 -1
- package/dev/loadDevMessages.d.ts.map +0 -1
- package/dev/loadErrorMessageHandler.d.ts.map +0 -1
- package/dev/loadErrorMessages.d.ts.map +0 -1
- package/errors/index.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/invariantErrorCodes.d.ts.map +0 -1
- package/link/batch/batchLink.d.ts.map +0 -1
- package/link/batch/batching.d.ts.map +0 -1
- package/link/batch/index.d.ts.map +0 -1
- package/link/batch-http/batchHttpLink.d.ts.map +0 -1
- package/link/batch-http/index.d.ts.map +0 -1
- package/link/context/index.d.ts.map +0 -1
- package/link/core/ApolloLink.d.ts.map +0 -1
- package/link/core/concat.d.ts.map +0 -1
- package/link/core/empty.d.ts.map +0 -1
- package/link/core/execute.d.ts.map +0 -1
- package/link/core/from.d.ts.map +0 -1
- package/link/core/index.d.ts.map +0 -1
- package/link/core/split.d.ts.map +0 -1
- package/link/core/types.d.ts.map +0 -1
- package/link/error/index.d.ts.map +0 -1
- package/link/http/HttpLink.d.ts.map +0 -1
- package/link/http/checkFetcher.d.ts.map +0 -1
- package/link/http/createHttpLink.d.ts.map +0 -1
- package/link/http/createSignalIfSupported.d.ts.map +0 -1
- package/link/http/index.d.ts.map +0 -1
- package/link/http/iterators/async.d.ts.map +0 -1
- package/link/http/iterators/nodeStream.d.ts.map +0 -1
- package/link/http/iterators/promise.d.ts.map +0 -1
- package/link/http/iterators/reader.d.ts.map +0 -1
- package/link/http/parseAndCheckHttpResponse.d.ts.map +0 -1
- package/link/http/responseIterator.d.ts.map +0 -1
- package/link/http/rewriteURIForGET.d.ts.map +0 -1
- package/link/http/selectHttpOptionsAndBody.d.ts.map +0 -1
- package/link/http/selectURI.d.ts.map +0 -1
- package/link/http/serializeFetchParameter.d.ts.map +0 -1
- package/link/persisted-queries/index.d.ts.map +0 -1
- package/link/remove-typename/index.d.ts.map +0 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts.map +0 -1
- package/link/retry/delayFunction.d.ts.map +0 -1
- package/link/retry/index.d.ts.map +0 -1
- package/link/retry/retryFunction.d.ts.map +0 -1
- package/link/retry/retryLink.d.ts.map +0 -1
- package/link/schema/index.d.ts.map +0 -1
- package/link/subscriptions/index.d.ts.map +0 -1
- package/link/utils/createOperation.d.ts.map +0 -1
- package/link/utils/filterOperationVariables.d.ts.map +0 -1
- package/link/utils/fromError.d.ts.map +0 -1
- package/link/utils/fromPromise.d.ts.map +0 -1
- package/link/utils/index.d.ts.map +0 -1
- package/link/utils/throwServerError.d.ts.map +0 -1
- package/link/utils/toPromise.d.ts.map +0 -1
- package/link/utils/transformOperation.d.ts.map +0 -1
- package/link/utils/validateOperation.d.ts.map +0 -1
- package/link/ws/index.d.ts.map +0 -1
- package/react/cache/QueryReference.d.ts.map +0 -1
- package/react/cache/SuspenseCache.d.ts.map +0 -1
- package/react/cache/getSuspenseCache.d.ts.map +0 -1
- package/react/cache/index.d.ts.map +0 -1
- package/react/cache/types.d.ts.map +0 -1
- package/react/components/Mutation.d.ts.map +0 -1
- package/react/components/Query.d.ts.map +0 -1
- package/react/components/Subscription.d.ts.map +0 -1
- package/react/components/index.d.ts.map +0 -1
- package/react/components/types.d.ts.map +0 -1
- package/react/context/ApolloConsumer.d.ts.map +0 -1
- package/react/context/ApolloContext.d.ts.map +0 -1
- package/react/context/ApolloProvider.d.ts.map +0 -1
- package/react/context/index.d.ts.map +0 -1
- package/react/hoc/graphql.d.ts.map +0 -1
- package/react/hoc/hoc-utils.d.ts.map +0 -1
- package/react/hoc/index.d.ts.map +0 -1
- package/react/hoc/mutation-hoc.d.ts.map +0 -1
- package/react/hoc/query-hoc.d.ts.map +0 -1
- package/react/hoc/subscription-hoc.d.ts.map +0 -1
- package/react/hoc/types.d.ts.map +0 -1
- package/react/hoc/withApollo.d.ts.map +0 -1
- package/react/hooks/constants.d.ts.map +0 -1
- package/react/hooks/index.d.ts.map +0 -1
- package/react/hooks/internal/__use.d.ts.map +0 -1
- package/react/hooks/internal/index.d.ts.map +0 -1
- package/react/hooks/internal/useDeepMemo.d.ts.map +0 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +0 -1
- package/react/hooks/useApolloClient.d.ts.map +0 -1
- package/react/hooks/useBackgroundQuery.d.ts.map +0 -1
- package/react/hooks/useFragment.d.ts.map +0 -1
- package/react/hooks/useLazyQuery.d.ts.map +0 -1
- package/react/hooks/useMutation.d.ts.map +0 -1
- package/react/hooks/useQuery.d.ts.map +0 -1
- package/react/hooks/useReactiveVar.d.ts.map +0 -1
- package/react/hooks/useReadQuery.d.ts.map +0 -1
- package/react/hooks/useSubscription.d.ts.map +0 -1
- package/react/hooks/useSuspenseQuery.d.ts.map +0 -1
- package/react/hooks/useSyncExternalStore.d.ts.map +0 -1
- package/react/index.d.ts.map +0 -1
- package/react/parser/index.d.ts.map +0 -1
- package/react/ssr/RenderPromises.d.ts.map +0 -1
- package/react/ssr/getDataFromTree.d.ts.map +0 -1
- package/react/ssr/index.d.ts.map +0 -1
- package/react/ssr/renderToStringWithData.d.ts.map +0 -1
- package/react/types/types.d.ts.map +0 -1
- package/testing/core/index.d.ts.map +0 -1
- package/testing/core/itAsync.d.ts.map +0 -1
- package/testing/core/mocking/mockClient.d.ts.map +0 -1
- package/testing/core/mocking/mockFetch.d.ts.map +0 -1
- package/testing/core/mocking/mockLink.d.ts.map +0 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +0 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +0 -1
- package/testing/core/mocking/mockWatchQuery.d.ts.map +0 -1
- package/testing/core/observableToPromise.d.ts.map +0 -1
- package/testing/core/subscribeAndCount.d.ts.map +0 -1
- package/testing/core/wait.d.ts.map +0 -1
- package/testing/core/withConsoleSpy.d.ts.map +0 -1
- package/testing/core/wrap.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/internal/ObservableStream.d.ts.map +0 -1
- package/testing/internal/disposables/index.d.ts.map +0 -1
- package/testing/internal/disposables/spyOnConsole.d.ts.map +0 -1
- package/testing/internal/disposables/withCleanup.d.ts.map +0 -1
- package/testing/internal/index.d.ts.map +0 -1
- package/testing/internal/profile/Render.d.ts.map +0 -1
- package/testing/internal/profile/index.d.ts.map +0 -1
- package/testing/internal/profile/profile.d.ts.map +0 -1
- package/testing/internal/profile/traces.d.ts.map +0 -1
- package/testing/matchers/ProfiledComponent.d.ts.map +0 -1
- package/testing/matchers/index.d.ts.map +0 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +0 -1
- package/testing/matchers/toMatchDocument.d.ts.map +0 -1
- package/testing/react/MockedProvider.d.ts.map +0 -1
- package/utilities/common/arrays.d.ts.map +0 -1
- package/utilities/common/canUse.d.ts.map +0 -1
- package/utilities/common/cloneDeep.d.ts.map +0 -1
- package/utilities/common/compact.d.ts.map +0 -1
- package/utilities/common/errorHandling.d.ts.map +0 -1
- package/utilities/common/filterInPlace.d.ts +0 -2
- package/utilities/common/filterInPlace.d.ts.map +0 -1
- package/utilities/common/filterInPlace.js +0 -11
- package/utilities/common/filterInPlace.js.map +0 -1
- package/utilities/common/incrementalResult.d.ts.map +0 -1
- package/utilities/common/makeUniqueId.d.ts.map +0 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +0 -1
- package/utilities/common/mergeDeep.d.ts.map +0 -1
- package/utilities/common/mergeOptions.d.ts.map +0 -1
- package/utilities/common/objects.d.ts.map +0 -1
- package/utilities/common/omitDeep.d.ts.map +0 -1
- package/utilities/common/stringifyForDisplay.d.ts.map +0 -1
- package/utilities/common/stripTypename.d.ts.map +0 -1
- package/utilities/globals/global.d.ts.map +0 -1
- package/utilities/globals/index.d.ts.map +0 -1
- package/utilities/globals/invariantWrappers.d.ts.map +0 -1
- package/utilities/globals/maybe.d.ts.map +0 -1
- package/utilities/graphql/DocumentTransform.d.ts.map +0 -1
- package/utilities/graphql/directives.d.ts.map +0 -1
- package/utilities/graphql/fragments.d.ts.map +0 -1
- package/utilities/graphql/getFromAST.d.ts.map +0 -1
- package/utilities/graphql/operations.d.ts.map +0 -1
- package/utilities/graphql/print.d.ts.map +0 -1
- package/utilities/graphql/storeUtils.d.ts.map +0 -1
- package/utilities/graphql/transform.d.ts.map +0 -1
- package/utilities/index.d.ts.map +0 -1
- package/utilities/observables/Concast.d.ts.map +0 -1
- package/utilities/observables/Observable.d.ts.map +0 -1
- package/utilities/observables/asyncMap.d.ts.map +0 -1
- package/utilities/observables/iteration.d.ts.map +0 -1
- package/utilities/observables/subclassing.d.ts.map +0 -1
- package/utilities/policies/pagination.d.ts.map +0 -1
- package/utilities/promises/decoration.d.ts.map +0 -1
- package/utilities/types/DeepOmit.d.ts.map +0 -1
- package/utilities/types/DeepPartial.d.ts.map +0 -1
- package/utilities/types/IsStrictlyAny.d.ts.map +0 -1
- package/utilities/types/Primitive.d.ts.map +0 -1
- package/version.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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;
|
|
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;IAC5E,sEAAsE;IACtE,6DAA6D;IAC7D,qEAAqE;IACrE,qDAAqD;IACrD,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,CAAC;YACX,uEAAuE;YACvE,oEAAoE;YACpE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC;QAChC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Operation } from \"../core/index.js\";\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"]}
|
package/link/retry/retry.cjs
CHANGED
|
@@ -27,7 +27,7 @@ function buildRetryFunction(retryOptions) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var RetryableOperation =
|
|
30
|
+
var RetryableOperation = (function () {
|
|
31
31
|
function RetryableOperation(operation, nextLink, delayFor, retryIf) {
|
|
32
32
|
var _this = this;
|
|
33
33
|
this.operation = operation;
|
|
@@ -64,12 +64,12 @@ var RetryableOperation = (function () {
|
|
|
64
64
|
switch (_b.label) {
|
|
65
65
|
case 0:
|
|
66
66
|
this.retryCount += 1;
|
|
67
|
-
return [4, this.retryIf(this.retryCount, this.operation, error)];
|
|
67
|
+
return [4 , this.retryIf(this.retryCount, this.operation, error)];
|
|
68
68
|
case 1:
|
|
69
69
|
shouldRetry = _b.sent();
|
|
70
70
|
if (shouldRetry) {
|
|
71
71
|
this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));
|
|
72
|
-
return [2];
|
|
72
|
+
return [2 ];
|
|
73
73
|
}
|
|
74
74
|
this.error = error;
|
|
75
75
|
for (_i = 0, _a = this.observers; _i < _a.length; _i++) {
|
|
@@ -78,7 +78,7 @@ var RetryableOperation = (function () {
|
|
|
78
78
|
continue;
|
|
79
79
|
observer.error(error);
|
|
80
80
|
}
|
|
81
|
-
return [2];
|
|
81
|
+
return [2 ];
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
}); };
|
|
@@ -142,7 +142,7 @@ var RetryableOperation = (function () {
|
|
|
142
142
|
};
|
|
143
143
|
return RetryableOperation;
|
|
144
144
|
}());
|
|
145
|
-
var RetryLink =
|
|
145
|
+
var RetryLink = (function (_super) {
|
|
146
146
|
tslib.__extends(RetryLink, _super);
|
|
147
147
|
function RetryLink(options) {
|
|
148
148
|
var _this = _super.call(this) || this;
|
package/link/retry/retry.cjs.map
CHANGED
|
@@ -1 +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/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport { buildDelayFunction } from \"./delayFunction.js\";\nimport { buildRetryFunction } from \"./retryFunction.js\";\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,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,CAAC;AACX,KAAK,CAAC;AACN,IAAI,OAAO,SAAS,CAAC;AACrB,CAAC,CAACC,eAAU,CAAC;;;;"}
|
|
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 // 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 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 // 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 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/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport { buildDelayFunction } from \"./delayFunction.js\";\nimport { buildRetryFunction } from \"./retryFunction.js\";\n/**\n * Tracking and management of operations that may be (or currently are) retried.\n */\nvar RetryableOperation = /** @class */ (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 /*yield*/, 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 /*return*/];\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 /*return*/];\n }\n });\n }); };\n }\n /**\n * Register a new observer for this operation.\n *\n * If the operation has previously emitted other events, they will be\n * immediately triggered for the observer.\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 // If we've already begun, catch this observer up.\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 /**\n * Remove a previously registered observer from this operation.\n *\n * If no observers remain, the operation will stop retrying, and unsubscribe\n * from its downstream link.\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 // Note that we are careful not to change the order of length of the array,\n // as we are often mid-iteration when calling this method.\n this.observers[index] = null;\n // If this is the last observer, we're done.\n if (this.observers.every(function (o) { return o === null; })) {\n this.cancel();\n }\n };\n /**\n * Start the initial request.\n */\n RetryableOperation.prototype.start = function () {\n if (this.currentSubscription)\n return; // Already started.\n this.try();\n };\n /**\n * Stop retrying for the operation, and cancel any in-progress requests.\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 = /** @class */ (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,C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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;;;;"}
|
|
@@ -27,7 +27,7 @@ function buildRetryFunction(retryOptions) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var RetryableOperation =
|
|
30
|
+
var RetryableOperation = (function () {
|
|
31
31
|
function RetryableOperation(operation, nextLink, delayFor, retryIf) {
|
|
32
32
|
var _this = this;
|
|
33
33
|
this.operation = operation;
|
|
@@ -64,12 +64,12 @@ var RetryableOperation = (function () {
|
|
|
64
64
|
switch (_b.label) {
|
|
65
65
|
case 0:
|
|
66
66
|
this.retryCount += 1;
|
|
67
|
-
return [4, this.retryIf(this.retryCount, this.operation, error)];
|
|
67
|
+
return [4 , this.retryIf(this.retryCount, this.operation, error)];
|
|
68
68
|
case 1:
|
|
69
69
|
shouldRetry = _b.sent();
|
|
70
70
|
if (shouldRetry) {
|
|
71
71
|
this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));
|
|
72
|
-
return [2];
|
|
72
|
+
return [2 ];
|
|
73
73
|
}
|
|
74
74
|
this.error = error;
|
|
75
75
|
for (_i = 0, _a = this.observers; _i < _a.length; _i++) {
|
|
@@ -78,7 +78,7 @@ var RetryableOperation = (function () {
|
|
|
78
78
|
continue;
|
|
79
79
|
observer.error(error);
|
|
80
80
|
}
|
|
81
|
-
return [2];
|
|
81
|
+
return [2 ];
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
}); };
|
|
@@ -142,7 +142,7 @@ var RetryableOperation = (function () {
|
|
|
142
142
|
};
|
|
143
143
|
return RetryableOperation;
|
|
144
144
|
}());
|
|
145
|
-
var RetryLink =
|
|
145
|
+
var RetryLink = (function (_super) {
|
|
146
146
|
tslib.__extends(RetryLink, _super);
|
|
147
147
|
function RetryLink(options) {
|
|
148
148
|
var _this = _super.call(this) || this;
|
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import type { Operation } from "../core/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Advanced mode: a function that determines both whether a particular
|
|
4
|
+
* response should be retried.
|
|
5
|
+
*/
|
|
2
6
|
export interface RetryFunction {
|
|
3
7
|
(count: number, operation: Operation, error: any): boolean | Promise<boolean>;
|
|
4
8
|
}
|
|
5
9
|
export interface RetryFunctionOptions {
|
|
10
|
+
/**
|
|
11
|
+
* The max number of times to try a single operation before giving up.
|
|
12
|
+
*
|
|
13
|
+
* Note that this INCLUDES the initial request as part of the count.
|
|
14
|
+
* E.g. maxTries of 1 indicates no retrying should occur.
|
|
15
|
+
*
|
|
16
|
+
* Defaults to 5. Pass Infinity for infinite retries.
|
|
17
|
+
*/
|
|
6
18
|
max?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Predicate function that determines whether a particular error should
|
|
21
|
+
* trigger a retry.
|
|
22
|
+
*
|
|
23
|
+
* For example, you may want to not retry 4xx class HTTP errors.
|
|
24
|
+
*
|
|
25
|
+
* By default, all errors are retried.
|
|
26
|
+
*/
|
|
7
27
|
retryIf?: (error: any, operation: Operation) => boolean | Promise<boolean>;
|
|
8
28
|
}
|
|
9
29
|
export declare function buildRetryFunction(retryOptions?: RetryFunctionOptions): RetryFunction;
|
|
@@ -5,7 +5,13 @@ import type { DelayFunction, DelayFunctionOptions } from "./delayFunction.js";
|
|
|
5
5
|
import type { RetryFunction, RetryFunctionOptions } from "./retryFunction.js";
|
|
6
6
|
export declare namespace RetryLink {
|
|
7
7
|
interface Options {
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for the delay strategy to use, or a custom delay strategy.
|
|
10
|
+
*/
|
|
8
11
|
delay?: DelayFunctionOptions | DelayFunction;
|
|
12
|
+
/**
|
|
13
|
+
* Configuration for the retry strategy to use, or a custom retry strategy.
|
|
14
|
+
*/
|
|
9
15
|
attempts?: RetryFunctionOptions | RetryFunction;
|
|
10
16
|
}
|
|
11
17
|
}
|
package/link/retry/retryLink.js
CHANGED
|
@@ -3,7 +3,10 @@ import { ApolloLink } from "../core/index.js";
|
|
|
3
3
|
import { Observable } from "../../utilities/index.js";
|
|
4
4
|
import { buildDelayFunction } from "./delayFunction.js";
|
|
5
5
|
import { buildRetryFunction } from "./retryFunction.js";
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Tracking and management of operations that may be (or currently are) retried.
|
|
8
|
+
*/
|
|
9
|
+
var RetryableOperation = /** @class */ (function () {
|
|
7
10
|
function RetryableOperation(operation, nextLink, delayFor, retryIf) {
|
|
8
11
|
var _this = this;
|
|
9
12
|
this.operation = operation;
|
|
@@ -40,12 +43,12 @@ var RetryableOperation = (function () {
|
|
|
40
43
|
switch (_b.label) {
|
|
41
44
|
case 0:
|
|
42
45
|
this.retryCount += 1;
|
|
43
|
-
return [4
|
|
46
|
+
return [4 /*yield*/, this.retryIf(this.retryCount, this.operation, error)];
|
|
44
47
|
case 1:
|
|
45
48
|
shouldRetry = _b.sent();
|
|
46
49
|
if (shouldRetry) {
|
|
47
50
|
this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));
|
|
48
|
-
return [2];
|
|
51
|
+
return [2 /*return*/];
|
|
49
52
|
}
|
|
50
53
|
this.error = error;
|
|
51
54
|
for (_i = 0, _a = this.observers; _i < _a.length; _i++) {
|
|
@@ -54,16 +57,23 @@ var RetryableOperation = (function () {
|
|
|
54
57
|
continue;
|
|
55
58
|
observer.error(error);
|
|
56
59
|
}
|
|
57
|
-
return [2];
|
|
60
|
+
return [2 /*return*/];
|
|
58
61
|
}
|
|
59
62
|
});
|
|
60
63
|
}); };
|
|
61
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Register a new observer for this operation.
|
|
67
|
+
*
|
|
68
|
+
* If the operation has previously emitted other events, they will be
|
|
69
|
+
* immediately triggered for the observer.
|
|
70
|
+
*/
|
|
62
71
|
RetryableOperation.prototype.subscribe = function (observer) {
|
|
63
72
|
if (this.canceled) {
|
|
64
73
|
throw new Error("Subscribing to a retryable link that was canceled is not supported");
|
|
65
74
|
}
|
|
66
75
|
this.observers.push(observer);
|
|
76
|
+
// If we've already begun, catch this observer up.
|
|
67
77
|
for (var _i = 0, _a = this.values; _i < _a.length; _i++) {
|
|
68
78
|
var value = _a[_i];
|
|
69
79
|
observer.next(value);
|
|
@@ -75,21 +85,36 @@ var RetryableOperation = (function () {
|
|
|
75
85
|
observer.error(this.error);
|
|
76
86
|
}
|
|
77
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Remove a previously registered observer from this operation.
|
|
90
|
+
*
|
|
91
|
+
* If no observers remain, the operation will stop retrying, and unsubscribe
|
|
92
|
+
* from its downstream link.
|
|
93
|
+
*/
|
|
78
94
|
RetryableOperation.prototype.unsubscribe = function (observer) {
|
|
79
95
|
var index = this.observers.indexOf(observer);
|
|
80
96
|
if (index < 0) {
|
|
81
97
|
throw new Error("RetryLink BUG! Attempting to unsubscribe unknown observer!");
|
|
82
98
|
}
|
|
99
|
+
// Note that we are careful not to change the order of length of the array,
|
|
100
|
+
// as we are often mid-iteration when calling this method.
|
|
83
101
|
this.observers[index] = null;
|
|
102
|
+
// If this is the last observer, we're done.
|
|
84
103
|
if (this.observers.every(function (o) { return o === null; })) {
|
|
85
104
|
this.cancel();
|
|
86
105
|
}
|
|
87
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* Start the initial request.
|
|
109
|
+
*/
|
|
88
110
|
RetryableOperation.prototype.start = function () {
|
|
89
111
|
if (this.currentSubscription)
|
|
90
|
-
return;
|
|
112
|
+
return; // Already started.
|
|
91
113
|
this.try();
|
|
92
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* Stop retrying for the operation, and cancel any in-progress requests.
|
|
117
|
+
*/
|
|
93
118
|
RetryableOperation.prototype.cancel = function () {
|
|
94
119
|
if (this.currentSubscription) {
|
|
95
120
|
this.currentSubscription.unsubscribe();
|
|
@@ -118,7 +143,7 @@ var RetryableOperation = (function () {
|
|
|
118
143
|
};
|
|
119
144
|
return RetryableOperation;
|
|
120
145
|
}());
|
|
121
|
-
var RetryLink = (function (_super) {
|
|
146
|
+
var RetryLink = /** @class */ (function (_super) {
|
|
122
147
|
__extends(RetryLink, _super);
|
|
123
148
|
function RetryLink(options) {
|
|
124
149
|
var _this = _super.call(this) || this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retryLink.js","sourceRoot":"","sources":["../../../src/link/retry/retryLink.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAmBxD;IAUE,4BACU,SAAoB,EACpB,QAAkB,EAClB,QAAuB,EACvB,OAAsB;QAJhC,iBAKI;QAJM,cAAS,GAAT,SAAS,CAAW;QACpB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAe;QACvB,YAAO,GAAP,OAAO,CAAe;QAbxB,eAAU,GAAW,CAAC,CAAC;QACvB,WAAM,GAAU,EAAE,CAAC;QAEnB,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAG,KAAK,CAAC;QAC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C;IAEM,2BAAO,GAAd,UACE,SAAoB,EACpB,QAAkB;QAElB,IAAM,SAAS,GAAG,IAAI,kBAAkB,CACtC,SAAS,EACT,QAAQ,EACR,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,CACb,CAAC;QACF,SAAS,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,IAAI,UAAU,CAAC,UAAC,QAAQ;YAC7B,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC9B,OAAO;gBACL,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACH,gBAAC;AAAD,CAAC,AAhCD,CAA+B,UAAU,GAgCxC","sourcesContent":["import type { Operation, FetchResult, NextLink } from \"../core/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport type {\n Observer,\n ObservableSubscription,\n} from \"../../utilities/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport type { DelayFunction, DelayFunctionOptions } from \"./delayFunction.js\";\nimport { buildDelayFunction } from \"./delayFunction.js\";\nimport type { RetryFunction, RetryFunctionOptions } from \"./retryFunction.js\";\nimport { buildRetryFunction } from \"./retryFunction.js\";\n\nexport namespace RetryLink {\n export interface Options {\n /**\n * Configuration for the delay strategy to use, or a custom delay strategy.\n */\n delay?: DelayFunctionOptions | DelayFunction;\n\n /**\n * Configuration for the retry strategy to use, or a custom retry strategy.\n */\n attempts?: RetryFunctionOptions | RetryFunction;\n }\n}\n\n/**\n * Tracking and management of operations that may be (or currently are) retried.\n */\nclass RetryableOperation<TValue = any> {\n private retryCount: number = 0;\n private values: any[] = [];\n private error: any;\n private complete = false;\n private canceled = false;\n private observers: (Observer<TValue> | null)[] = [];\n private currentSubscription: ObservableSubscription | null = null;\n private timerId: number | undefined;\n\n constructor(\n private operation: Operation,\n private nextLink: NextLink,\n private delayFor: DelayFunction,\n private retryIf: RetryFunction\n ) {}\n\n /**\n * Register a new observer for this operation.\n *\n * If the operation has previously emitted other events, they will be\n * immediately triggered for the observer.\n */\n public subscribe(observer: Observer<TValue>) {\n if (this.canceled) {\n throw new Error(\n `Subscribing to a retryable link that was canceled is not supported`\n );\n }\n this.observers.push(observer);\n\n // If we've already begun, catch this observer up.\n for (const value of this.values) {\n observer.next!(value);\n }\n\n if (this.complete) {\n observer.complete!();\n } else if (this.error) {\n observer.error!(this.error);\n }\n }\n\n /**\n * Remove a previously registered observer from this operation.\n *\n * If no observers remain, the operation will stop retrying, and unsubscribe\n * from its downstream link.\n */\n public unsubscribe(observer: Observer<TValue>) {\n const index = this.observers.indexOf(observer);\n if (index < 0) {\n throw new Error(\n `RetryLink BUG! Attempting to unsubscribe unknown observer!`\n );\n }\n // Note that we are careful not to change the order of length of the array,\n // as we are often mid-iteration when calling this method.\n this.observers[index] = null;\n\n // If this is the last observer, we're done.\n if (this.observers.every((o) => o === null)) {\n this.cancel();\n }\n }\n\n /**\n * Start the initial request.\n */\n public start() {\n if (this.currentSubscription) return; // Already started.\n\n this.try();\n }\n\n /**\n * Stop retrying for the operation, and cancel any in-progress requests.\n */\n public cancel() {\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\n private try() {\n this.currentSubscription = this.nextLink(this.operation).subscribe({\n next: this.onNext,\n error: this.onError,\n complete: this.onComplete,\n });\n }\n\n private onNext = (value: any) => {\n this.values.push(value);\n for (const observer of this.observers) {\n if (!observer) continue;\n observer.next!(value);\n }\n };\n\n private onComplete = () => {\n this.complete = true;\n for (const observer of this.observers) {\n if (!observer) continue;\n observer.complete!();\n }\n };\n\n private onError = async (error: any) => {\n this.retryCount += 1;\n\n // Should we retry?\n const shouldRetry = await this.retryIf(\n this.retryCount,\n this.operation,\n error\n );\n if (shouldRetry) {\n this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));\n return;\n }\n\n this.error = error;\n for (const observer of this.observers) {\n if (!observer) continue;\n observer.error!(error);\n }\n };\n\n private scheduleRetry(delay: number) {\n if (this.timerId) {\n throw new Error(`RetryLink BUG! Encountered overlapping retries`);\n }\n\n this.timerId = setTimeout(() => {\n this.timerId = undefined;\n this.try();\n }, delay) as any as number;\n }\n}\n\nexport class RetryLink extends ApolloLink {\n private delayFor: DelayFunction;\n private retryIf: RetryFunction;\n\n constructor(options?: RetryLink.Options) {\n super();\n const { attempts, delay } = options || ({} as RetryLink.Options);\n this.delayFor =\n typeof delay === \"function\" ? delay : buildDelayFunction(delay);\n this.retryIf =\n typeof attempts === \"function\" ? attempts : buildRetryFunction(attempts);\n }\n\n public request(\n operation: Operation,\n nextLink: NextLink\n ): Observable<FetchResult> {\n const retryable = new RetryableOperation(\n operation,\n nextLink,\n this.delayFor,\n this.retryIf\n );\n retryable.start();\n\n return new Observable((observer) => {\n retryable.subscribe(observer);\n return () => {\n retryable.unsubscribe(observer);\n };\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"retryLink.js","sourceRoot":"","sources":["../../../src/link/retry/retryLink.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAgBxD;;GAEG;AACH;IAUE,4BACU,SAAoB,EACpB,QAAkB,EAClB,QAAuB,EACvB,OAAsB;QAJhC,iBAKI;QAJM,cAAS,GAAT,SAAS,CAAW;QACpB,aAAQ,GAAR,QAAQ,CAAU;QAClB,aAAQ,GAAR,QAAQ,CAAe;QACvB,YAAO,GAAP,OAAO,CAAe;QAbxB,eAAU,GAAW,CAAC,CAAC;QACvB,WAAM,GAAU,EAAE,CAAC;QAEnB,aAAQ,GAAG,KAAK,CAAC;QACjB,aAAQ,GAAG,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A,EAAE,KAAK,WAAyC,CAAC;QACjE,KAAI,CAAC,QAAQ;YACX,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAClE,KAAI,CAAC,OAAO;YACV,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;;IAC7E,CAAC;IAEM,2BAAO,GAAd,UACE,SAAoB,EACpB,QAAkB;QAElB,IAAM,SAAS,GAAG,IAAI,kBAAkB,CACtC,SAAS,EACT,QAAQ,EACR,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,OAAO,CACb,CAAC;QACF,SAAS,CAAC,KAAK,EAAE,CAAC;QAElB,OAAO,IAAI,UAAU,CAAC,UAAC,QAAQ;YAC7B,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC9B,OAAO;gBACL,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YAClC,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACH,gBAAC;AAAD,CAAC,AAhCD,CAA+B,UAAU,GAgCxC","sourcesContent":["import type { Operation, FetchResult, NextLink } from \"../core/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport type {\n Observer,\n ObservableSubscription,\n} from \"../../utilities/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nimport type { DelayFunction, DelayFunctionOptions } from \"./delayFunction.js\";\nimport { buildDelayFunction } from \"./delayFunction.js\";\nimport type { RetryFunction, RetryFunctionOptions } from \"./retryFunction.js\";\nimport { buildRetryFunction } from \"./retryFunction.js\";\n\nexport namespace RetryLink {\n export interface Options {\n /**\n * Configuration for the delay strategy to use, or a custom delay strategy.\n */\n delay?: DelayFunctionOptions | DelayFunction;\n\n /**\n * Configuration for the retry strategy to use, or a custom retry strategy.\n */\n attempts?: RetryFunctionOptions | RetryFunction;\n }\n}\n\n/**\n * Tracking and management of operations that may be (or currently are) retried.\n */\nclass RetryableOperation<TValue = any> {\n private retryCount: number = 0;\n private values: any[] = [];\n private error: any;\n private complete = false;\n private canceled = false;\n private observers: (Observer<TValue> | null)[] = [];\n private currentSubscription: ObservableSubscription | null = null;\n private timerId: number | undefined;\n\n constructor(\n private operation: Operation,\n private nextLink: NextLink,\n private delayFor: DelayFunction,\n private retryIf: RetryFunction\n ) {}\n\n /**\n * Register a new observer for this operation.\n *\n * If the operation has previously emitted other events, they will be\n * immediately triggered for the observer.\n */\n public subscribe(observer: Observer<TValue>) {\n if (this.canceled) {\n throw new Error(\n `Subscribing to a retryable link that was canceled is not supported`\n );\n }\n this.observers.push(observer);\n\n // If we've already begun, catch this observer up.\n for (const value of this.values) {\n observer.next!(value);\n }\n\n if (this.complete) {\n observer.complete!();\n } else if (this.error) {\n observer.error!(this.error);\n }\n }\n\n /**\n * Remove a previously registered observer from this operation.\n *\n * If no observers remain, the operation will stop retrying, and unsubscribe\n * from its downstream link.\n */\n public unsubscribe(observer: Observer<TValue>) {\n const index = this.observers.indexOf(observer);\n if (index < 0) {\n throw new Error(\n `RetryLink BUG! Attempting to unsubscribe unknown observer!`\n );\n }\n // Note that we are careful not to change the order of length of the array,\n // as we are often mid-iteration when calling this method.\n this.observers[index] = null;\n\n // If this is the last observer, we're done.\n if (this.observers.every((o) => o === null)) {\n this.cancel();\n }\n }\n\n /**\n * Start the initial request.\n */\n public start() {\n if (this.currentSubscription) return; // Already started.\n\n this.try();\n }\n\n /**\n * Stop retrying for the operation, and cancel any in-progress requests.\n */\n public cancel() {\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\n private try() {\n this.currentSubscription = this.nextLink(this.operation).subscribe({\n next: this.onNext,\n error: this.onError,\n complete: this.onComplete,\n });\n }\n\n private onNext = (value: any) => {\n this.values.push(value);\n for (const observer of this.observers) {\n if (!observer) continue;\n observer.next!(value);\n }\n };\n\n private onComplete = () => {\n this.complete = true;\n for (const observer of this.observers) {\n if (!observer) continue;\n observer.complete!();\n }\n };\n\n private onError = async (error: any) => {\n this.retryCount += 1;\n\n // Should we retry?\n const shouldRetry = await this.retryIf(\n this.retryCount,\n this.operation,\n error\n );\n if (shouldRetry) {\n this.scheduleRetry(this.delayFor(this.retryCount, this.operation, error));\n return;\n }\n\n this.error = error;\n for (const observer of this.observers) {\n if (!observer) continue;\n observer.error!(error);\n }\n };\n\n private scheduleRetry(delay: number) {\n if (this.timerId) {\n throw new Error(`RetryLink BUG! Encountered overlapping retries`);\n }\n\n this.timerId = setTimeout(() => {\n this.timerId = undefined;\n this.try();\n }, delay) as any as number;\n }\n}\n\nexport class RetryLink extends ApolloLink {\n private delayFor: DelayFunction;\n private retryIf: RetryFunction;\n\n constructor(options?: RetryLink.Options) {\n super();\n const { attempts, delay } = options || ({} as RetryLink.Options);\n this.delayFor =\n typeof delay === \"function\" ? delay : buildDelayFunction(delay);\n this.retryIf =\n typeof attempts === \"function\" ? attempts : buildRetryFunction(attempts);\n }\n\n public request(\n operation: Operation,\n nextLink: NextLink\n ): Observable<FetchResult> {\n const retryable = new RetryableOperation(\n operation,\n nextLink,\n this.delayFor,\n this.retryIf\n );\n retryable.start();\n\n return new Observable((observer) => {\n retryable.subscribe(observer);\n return () => {\n retryable.unsubscribe(observer);\n };\n });\n }\n}\n"]}
|
package/link/schema/index.d.ts
CHANGED
|
@@ -6,9 +6,22 @@ export declare namespace SchemaLink {
|
|
|
6
6
|
type ResolverContext = Record<string, any>;
|
|
7
7
|
type ResolverContextFunction = (operation: Operation) => ResolverContext | PromiseLike<ResolverContext>;
|
|
8
8
|
interface Options {
|
|
9
|
+
/**
|
|
10
|
+
* The schema to generate responses from.
|
|
11
|
+
*/
|
|
9
12
|
schema: GraphQLSchema;
|
|
13
|
+
/**
|
|
14
|
+
* The root value to use when generating responses.
|
|
15
|
+
*/
|
|
10
16
|
rootValue?: any;
|
|
17
|
+
/**
|
|
18
|
+
* A context to provide to resolvers declared within the schema.
|
|
19
|
+
*/
|
|
11
20
|
context?: ResolverContext | ResolverContextFunction;
|
|
21
|
+
/**
|
|
22
|
+
* Validate incoming queries against the given schema, returning
|
|
23
|
+
* validation errors as a GraphQL server would.
|
|
24
|
+
*/
|
|
12
25
|
validate?: boolean;
|
|
13
26
|
}
|
|
14
27
|
}
|
package/link/schema/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { __extends } from "tslib";
|
|
|
2
2
|
import { validate, execute } from "graphql";
|
|
3
3
|
import { ApolloLink } from "../core/index.js";
|
|
4
4
|
import { Observable } from "../../utilities/index.js";
|
|
5
|
-
var SchemaLink = (function (_super) {
|
|
5
|
+
var SchemaLink = /** @class */ (function (_super) {
|
|
6
6
|
__extends(SchemaLink, _super);
|
|
7
7
|
function SchemaLink(options) {
|
|
8
8
|
var _this = _super.call(this) || this;
|
|
@@ -16,8 +16,8 @@ var SchemaLink = (function (_super) {
|
|
|
16
16
|
var _this = this;
|
|
17
17
|
return new Observable(function (observer) {
|
|
18
18
|
new Promise(function (resolve) {
|
|
19
|
-
return resolve(typeof _this.context === "function"
|
|
20
|
-
|
|
19
|
+
return resolve(typeof _this.context === "function" ?
|
|
20
|
+
_this.context(operation)
|
|
21
21
|
: _this.context);
|
|
22
22
|
})
|
|
23
23
|
.then(function (context) {
|
package/link/schema/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/schema/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAG5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAgCtD;IAAgC,8BAAU;IAMxC,oBAAY,OAA2B;
|
|
1
|
+
{"version":3,"file":"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,CAAC,KAAK;oBACzB,SAAS,EAAE,KAAI,CAAC,SAAS;oBACzB,YAAY,EAAE,OAAO;oBACrB,cAAc,EAAE,SAAS,CAAC,SAAS;oBACnC,aAAa,EAAE,SAAS,CAAC,aAAa;iBACvC,CAAC,CAAC;YACL,CAAC,CAAC;iBACD,IAAI,CAAC,UAAC,IAAI;gBACT,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACpB,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACtB,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,UAAC,KAAK;gBACX,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;IACH,iBAAC;AAAD,CAAC,AArDD,CAAgC,UAAU,GAqDzC","sourcesContent":["import type { GraphQLSchema } from \"graphql\";\nimport { validate, execute } from \"graphql\";\n\nimport type { Operation, FetchResult } from \"../core/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\n\nexport namespace SchemaLink {\n export type ResolverContext = Record<string, any>;\n export type ResolverContextFunction = (\n operation: Operation\n ) => ResolverContext | PromiseLike<ResolverContext>;\n\n export interface Options {\n /**\n * The schema to generate responses from.\n */\n schema: GraphQLSchema;\n\n /**\n * The root value to use when generating responses.\n */\n rootValue?: any;\n\n /**\n * A context to provide to resolvers declared within the schema.\n */\n context?: ResolverContext | ResolverContextFunction;\n\n /**\n * Validate incoming queries against the given schema, returning\n * validation errors as a GraphQL server would.\n */\n validate?: boolean;\n }\n}\n\nexport class SchemaLink extends ApolloLink {\n public schema: SchemaLink.Options[\"schema\"];\n public rootValue: SchemaLink.Options[\"rootValue\"];\n public context: SchemaLink.Options[\"context\"];\n public validate: boolean;\n\n constructor(options: SchemaLink.Options) {\n super();\n this.schema = options.schema;\n this.rootValue = options.rootValue;\n this.context = options.context;\n this.validate = !!options.validate;\n }\n\n public request(operation: Operation): Observable<FetchResult> {\n return new Observable<FetchResult>((observer) => {\n new Promise<SchemaLink.ResolverContext>((resolve) =>\n resolve(\n typeof this.context === \"function\" ?\n this.context(operation)\n : this.context\n )\n )\n .then((context) => {\n if (this.validate) {\n const validationErrors = validate(this.schema, operation.query);\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n }\n\n return execute({\n schema: this.schema,\n document: operation.query,\n rootValue: this.rootValue,\n contextValue: context,\n variableValues: operation.variables,\n operationName: operation.operationName,\n });\n })\n .then((data) => {\n if (!observer.closed) {\n observer.next(data);\n observer.complete();\n }\n })\n .catch((error) => {\n if (!observer.closed) {\n observer.error(error);\n }\n });\n });\n }\n}\n"]}
|
package/link/schema/schema.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var graphql = require('graphql');
|
|
|
7
7
|
var core = require('../core');
|
|
8
8
|
var utilities = require('../../utilities');
|
|
9
9
|
|
|
10
|
-
var SchemaLink =
|
|
10
|
+
var SchemaLink = (function (_super) {
|
|
11
11
|
tslib.__extends(SchemaLink, _super);
|
|
12
12
|
function SchemaLink(options) {
|
|
13
13
|
var _this = _super.call(this) || this;
|
|
@@ -21,8 +21,8 @@ var SchemaLink = (function (_super) {
|
|
|
21
21
|
var _this = this;
|
|
22
22
|
return new utilities.Observable(function (observer) {
|
|
23
23
|
new Promise(function (resolve) {
|
|
24
|
-
return resolve(typeof _this.context === "function"
|
|
25
|
-
|
|
24
|
+
return resolve(typeof _this.context === "function" ?
|
|
25
|
+
_this.context(operation)
|
|
26
26
|
: _this.context);
|
|
27
27
|
})
|
|
28
28
|
.then(function (context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.cjs","sources":["index.js"],"sourcesContent":["import { __extends } from \"tslib\";\nimport { validate, execute } from \"graphql\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nvar SchemaLink = (function (_super) {\n __extends(SchemaLink, _super);\n function SchemaLink(options) {\n var _this = _super.call(this) || this;\n _this.schema = options.schema;\n _this.rootValue = options.rootValue;\n _this.context = options.context;\n _this.validate = !!options.validate;\n return _this;\n }\n SchemaLink.prototype.request = function (operation) {\n var _this = this;\n return new Observable(function (observer) {\n new Promise(function (resolve) {\n return resolve(typeof _this.context === \"function\"
|
|
1
|
+
{"version":3,"file":"schema.cjs","sources":["index.js"],"sourcesContent":["import { __extends } from \"tslib\";\nimport { validate, execute } from \"graphql\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { Observable } from \"../../utilities/index.js\";\nvar SchemaLink = /** @class */ (function (_super) {\n __extends(SchemaLink, _super);\n function SchemaLink(options) {\n var _this = _super.call(this) || this;\n _this.schema = options.schema;\n _this.rootValue = options.rootValue;\n _this.context = options.context;\n _this.validate = !!options.validate;\n return _this;\n }\n SchemaLink.prototype.request = function (operation) {\n var _this = this;\n return new Observable(function (observer) {\n new Promise(function (resolve) {\n return resolve(typeof _this.context === \"function\" ?\n _this.context(operation)\n : _this.context);\n })\n .then(function (context) {\n if (_this.validate) {\n var validationErrors = validate(_this.schema, operation.query);\n if (validationErrors.length > 0) {\n return { errors: validationErrors };\n }\n }\n return execute({\n schema: _this.schema,\n document: operation.query,\n rootValue: _this.rootValue,\n contextValue: context,\n variableValues: operation.variables,\n operationName: operation.operationName,\n });\n })\n .then(function (data) {\n if (!observer.closed) {\n observer.next(data);\n observer.complete();\n }\n })\n .catch(function (error) {\n if (!observer.closed) {\n observer.error(error);\n }\n });\n });\n };\n return SchemaLink;\n}(ApolloLink));\nexport { SchemaLink };\n//# sourceMappingURL=index.js.map"],"names":["__extends","Observable","validate","execute","ApolloLink"],"mappings":";;;;;;;;;AAIG,IAAC,UAAU,KAAkB,UAAU,MAAM,EAAE;AAClD,IAAIA,eAAS,CAAC,UAAU,EAAE,MAAM,CAAC,C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AM,EAAE,KAAK,CAAC,MAAM;AACxC,oBAAoB,QAAQ,EAAE,SAAS,CAAC,KAAK;AAC7C,oBAAoB,SAAS,EAAE,KAAK,CAAC,SAAS;AAC9C,oBAAoB,YAAY,EAAE,OAAO;AACzC,oBAAoB,cAAc,EAAE,SAAS,CAAC,SAAS;AACvD,oBAAoB,aAAa,EAAE,SAAS,CAAC,aAAa;AAC1D,iBAAiB,CAAC,CAAC;AACnB,aAAa,CAAC;AACd,iBAAiB,IAAI,CAAC,UAAU,IAAI,EAAE;AACtC,gBAAgB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;AACtC,oBAAoB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,oBAAoB,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACxC,iBAAiB;AACjB,aAAa,CAAC;AACd,iBAAiB,KAAK,CAAC,UAAU,KAAK,EAAE;AACxC,gBAAgB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;AACtC,oBAAoB,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC1C,iBAAiB;AACjB,aAAa,CAAC,CAAC;AACf,SAAS,CAAC,CAAC;AACX,KAAK,CAAC;AACN,IAAI,OAAO,UAAU,CAAC;AACtB,CAAC,CAACC,eAAU,CAAC;;;;"}
|
|
@@ -7,7 +7,7 @@ var graphql = require('graphql');
|
|
|
7
7
|
var core = require('../core');
|
|
8
8
|
var utilities = require('../../utilities');
|
|
9
9
|
|
|
10
|
-
var SchemaLink =
|
|
10
|
+
var SchemaLink = (function (_super) {
|
|
11
11
|
tslib.__extends(SchemaLink, _super);
|
|
12
12
|
function SchemaLink(options) {
|
|
13
13
|
var _this = _super.call(this) || this;
|
|
@@ -21,8 +21,8 @@ var SchemaLink = (function (_super) {
|
|
|
21
21
|
var _this = this;
|
|
22
22
|
return new utilities.Observable(function (observer) {
|
|
23
23
|
new Promise(function (resolve) {
|
|
24
|
-
return resolve(typeof _this.context === "function"
|
|
25
|
-
|
|
24
|
+
return resolve(typeof _this.context === "function" ?
|
|
25
|
+
_this.context(operation)
|
|
26
26
|
: _this.context);
|
|
27
27
|
})
|
|
28
28
|
.then(function (context) {
|
|
@@ -1,16 +1,47 @@
|
|
|
1
|
+
// This file is adapted from the graphql-ws npm package:
|
|
2
|
+
// https://github.com/enisdenjo/graphql-ws
|
|
3
|
+
//
|
|
4
|
+
// Most of the file comes from that package's README; some other parts (such as
|
|
5
|
+
// isLikeCloseEvent) come from its source.
|
|
6
|
+
//
|
|
7
|
+
// Here's the license of the original code:
|
|
8
|
+
//
|
|
9
|
+
// The MIT License (MIT)
|
|
10
|
+
//
|
|
11
|
+
// Copyright (c) 2020-2021 Denis Badurina
|
|
12
|
+
//
|
|
13
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
// in the Software without restriction, including without limitation the rights
|
|
16
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
// furnished to do so, subject to the following conditions:
|
|
19
|
+
//
|
|
20
|
+
// The above copyright notice and this permission notice shall be included in
|
|
21
|
+
// all copies or substantial portions of the Software.
|
|
22
|
+
//
|
|
23
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
29
|
+
// THE SOFTWARE.
|
|
1
30
|
import { __assign, __extends } from "tslib";
|
|
2
31
|
import { print } from "../../utilities/index.js";
|
|
3
32
|
import { ApolloLink } from "../core/index.js";
|
|
4
33
|
import { isNonNullObject, Observable } from "../../utilities/index.js";
|
|
5
34
|
import { ApolloError } from "../../errors/index.js";
|
|
35
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event
|
|
6
36
|
function isLikeCloseEvent(val) {
|
|
7
37
|
return isNonNullObject(val) && "code" in val && "reason" in val;
|
|
8
38
|
}
|
|
39
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/error_event
|
|
9
40
|
function isLikeErrorEvent(err) {
|
|
10
41
|
var _a;
|
|
11
42
|
return isNonNullObject(err) && ((_a = err.target) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.CLOSED;
|
|
12
43
|
}
|
|
13
|
-
var GraphQLWsLink = (function (_super) {
|
|
44
|
+
var GraphQLWsLink = /** @class */ (function (_super) {
|
|
14
45
|
__extends(GraphQLWsLink, _super);
|
|
15
46
|
function GraphQLWsLink(client) {
|
|
16
47
|
var _this = _super.call(this) || this;
|
|
@@ -29,7 +60,9 @@ var GraphQLWsLink = (function (_super) {
|
|
|
29
60
|
}
|
|
30
61
|
var likeClose = isLikeCloseEvent(err);
|
|
31
62
|
if (likeClose || isLikeErrorEvent(err)) {
|
|
32
|
-
return observer.error(
|
|
63
|
+
return observer.error(
|
|
64
|
+
// reason will be available on clean closes
|
|
65
|
+
new Error("Socket closed".concat(likeClose ? " with event ".concat(err.code) : "").concat(likeClose ? " ".concat(err.reason) : "")));
|
|
33
66
|
}
|
|
34
67
|
return observer.error(new ApolloError({
|
|
35
68
|
graphQLErrors: Array.isArray(err) ? err : [err],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/link/subscriptions/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"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OAAO,KAAI,CAAC,MAAM,CAAC,SAAS,uBACrB,SAAS,KAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAC7C;gBACE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAClC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAC1C,KAAK,EAAE,UAAC,GAAG;oBACT,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;wBACzB,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC7B,CAAC;oBACD,IAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;oBACxC,IAAI,SAAS,IAAI,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC;wBACvC,OAAO,QAAQ,CAAC,KAAK;wBACnB,2CAA2C;wBAC3C,IAAI,KAAK,CACP,uBAAgB,SAAS,CAAC,CAAC,CAAC,sBAAe,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAE,SACxD,SAAS,CAAC,CAAC,CAAC,WAAI,GAAG,CAAC,MAAM,CAAE,CAAC,CAAC,CAAC,EAAE,CACjC,CACH,CACF,CAAC;oBACJ,CAAC;oBAED,OAAO,QAAQ,CAAC,KAAK,CACnB,IAAI,WAAW,CAAC;wBACd,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;qBAChD,CAAC,CACH,CAAC;gBACJ,CAAC;aACF,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACH,oBAAC;AAAD,CAAC,AAtCD,CAAmC,UAAU,GAsC5C","sourcesContent":["// This file is adapted from the graphql-ws npm package:\n// https://github.com/enisdenjo/graphql-ws\n//\n// Most of the file comes from that package's README; some other parts (such as\n// isLikeCloseEvent) come from its source.\n//\n// Here's the license of the original code:\n//\n// The MIT License (MIT)\n//\n// Copyright (c) 2020-2021 Denis Badurina\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport { print } from \"../../utilities/index.js\";\nimport type { Client } from \"graphql-ws\";\n\nimport type { Operation, FetchResult } from \"../core/index.js\";\nimport { ApolloLink } from \"../core/index.js\";\nimport { isNonNullObject, Observable } from \"../../utilities/index.js\";\nimport { ApolloError } from \"../../errors/index.js\";\n\n// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close_event\nfunction isLikeCloseEvent(val: unknown): val is CloseEvent {\n return isNonNullObject(val) && \"code\" in val && \"reason\" in val;\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/error_event\nfunction isLikeErrorEvent(err: unknown): err is Event {\n return isNonNullObject(err) && err.target?.readyState === WebSocket.CLOSED;\n}\n\nexport class GraphQLWsLink extends ApolloLink {\n constructor(public readonly client: Client) {\n super();\n }\n\n public request(operation: Operation): Observable<FetchResult> {\n return new Observable((observer) => {\n return this.client.subscribe<FetchResult>(\n { ...operation, query: print(operation.query) },\n {\n next: observer.next.bind(observer),\n complete: observer.complete.bind(observer),\n error: (err) => {\n if (err instanceof Error) {\n return observer.error(err);\n }\n const likeClose = isLikeCloseEvent(err);\n if (likeClose || isLikeErrorEvent(err)) {\n return observer.error(\n // reason will be available on clean closes\n new Error(\n `Socket closed${likeClose ? ` with event ${err.code}` : \"\"}${\n likeClose ? ` ${err.reason}` : \"\"\n }`\n )\n );\n }\n\n return observer.error(\n new ApolloError({\n graphQLErrors: Array.isArray(err) ? err : [err],\n })\n );\n },\n }\n );\n });\n }\n}\n"]}
|
|
@@ -14,7 +14,7 @@ function isLikeErrorEvent(err) {
|
|
|
14
14
|
var _a;
|
|
15
15
|
return utilities.isNonNullObject(err) && ((_a = err.target) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.CLOSED;
|
|
16
16
|
}
|
|
17
|
-
var GraphQLWsLink =
|
|
17
|
+
var GraphQLWsLink = (function (_super) {
|
|
18
18
|
tslib.__extends(GraphQLWsLink, _super);
|
|
19
19
|
function GraphQLWsLink(client) {
|
|
20
20
|
var _this = _super.call(this) || this;
|
|
@@ -33,7 +33,8 @@ var GraphQLWsLink = (function (_super) {
|
|
|
33
33
|
}
|
|
34
34
|
var likeClose = isLikeCloseEvent(err);
|
|
35
35
|
if (likeClose || isLikeErrorEvent(err)) {
|
|
36
|
-
return observer.error(
|
|
36
|
+
return observer.error(
|
|
37
|
+
new Error("Socket closed".concat(likeClose ? " with event ".concat(err.code) : "").concat(likeClose ? " ".concat(err.reason) : "")));
|
|
37
38
|
}
|
|
38
39
|
return observer.error(new errors.ApolloError({
|
|
39
40
|
graphQLErrors: Array.isArray(err) ? err : [err],
|