@apollo/client 3.9.0-alpha.3 → 3.9.0-alpha.5
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/beige-geese-wink.md +5 -0
- package/.changeset/breezy-spiders-tap.md +38 -0
- package/.changeset/clean-items-smash.md +5 -0
- package/.changeset/cold-llamas-turn.md +8 -0
- package/.changeset/config.json +14 -0
- package/.changeset/dirty-kids-crash.md +5 -0
- package/.changeset/forty-cups-shop.md +5 -0
- package/.changeset/friendly-clouds-laugh.md +7 -0
- package/.changeset/hot-ducks-burn.md +5 -0
- package/.changeset/polite-avocados-warn.md +5 -0
- package/.changeset/pre.json +29 -0
- package/.changeset/quick-hats-marry.md +5 -0
- package/.changeset/shaggy-ears-scream.md +5 -0
- package/.changeset/shaggy-sheep-pull.md +5 -0
- package/.changeset/sixty-boxes-rest.md +8 -0
- package/.changeset/sour-sheep-walk.md +7 -0
- package/.changeset/strong-terms-perform.md +46 -0
- package/.changeset/thick-mice-collect.md +5 -0
- package/.changeset/thirty-ties-arrive.md +26 -0
- package/.changeset/violet-lions-draw.md +5 -0
- package/.changeset/wild-dolphins-jog.md +5 -0
- package/.changeset/yellow-flies-repeat.md +5 -0
- package/CHANGELOG.md +3535 -0
- package/apollo-client.cjs +484 -401
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +136 -153
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +136 -153
- 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.d.ts +1 -1
- package/cache/core/types/common.js +4 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +10 -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.d.ts +1 -0
- package/cache/inmemory/fragmentRegistry.js +23 -14
- 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 +166 -9
- 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 +87 -3
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.js +190 -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 +58 -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 +118 -13
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +8 -1
- package/core/QueryManager.js +247 -46
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +127 -114
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +127 -114
- 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 +10 -119
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +10 -119
- 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 +6 -8
- package/link/batch/batch.cjs +2 -2
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +2 -2
- package/link/batch/batchLink.d.ts +21 -0
- package/link/batch/batchLink.js +2 -1
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.js +24 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +3 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +3 -2
- package/link/batch-http/batchHttpLink.d.ts +4 -0
- package/link/batch-http/batchHttpLink.js +53 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/context.cjs.map +1 -1
- package/link/context/index.js +1 -0
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.js +12 -5
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +5 -5
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +5 -5
- package/link/error/error.cjs +1 -1
- package/link/error/error.cjs.map +1 -1
- package/link/error/error.cjs.native.js +1 -1
- package/link/error/index.d.ts +3 -0
- package/link/error/index.js +4 -1
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +0 -2
- package/link/http/HttpLink.js +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.js +23 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/createSignalIfSupported.d.ts +5 -0
- package/link/http/createSignalIfSupported.js +5 -0
- package/link/http/createSignalIfSupported.js.map +1 -1
- package/link/http/http.cjs +14 -12
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +14 -12
- package/link/http/index.js +2 -1
- package/link/http/index.js.map +1 -1
- package/link/http/iterators/async.d.ts +4 -0
- package/link/http/iterators/async.js +4 -0
- package/link/http/iterators/async.js.map +1 -1
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.js +4 -0
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/iterators/promise.d.ts +4 -0
- package/link/http/iterators/promise.js +4 -0
- package/link/http/iterators/promise.js.map +1 -1
- package/link/http/iterators/reader.d.ts +4 -0
- package/link/http/iterators/reader.js +4 -0
- package/link/http/iterators/reader.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +51 -10
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts +4 -0
- package/link/http/responseIterator.js +6 -0
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +1 -1
- package/link/http/rewriteURIForGET.js +10 -0
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +45 -0
- package/link/http/selectHttpOptionsAndBody.js +23 -0
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.js +34 -4
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +4 -4
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +4 -4
- package/link/remove-typename/remove-typename.cjs +12 -9
- package/link/remove-typename/remove-typename.cjs.map +1 -1
- package/link/remove-typename/remove-typename.cjs.native.js +12 -9
- package/link/remove-typename/removeTypenameFromVariables.js +12 -9
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/delayFunction.d.ts +29 -0
- package/link/retry/delayFunction.js +6 -0
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retry.cjs +5 -5
- package/link/retry/retry.cjs.map +1 -1
- package/link/retry/retry.cjs.native.js +5 -5
- package/link/retry/retryFunction.d.ts +20 -0
- package/link/retry/retryLink.d.ts +6 -0
- package/link/retry/retryLink.js +31 -6
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +13 -0
- package/link/schema/index.js +3 -3
- package/link/schema/index.js.map +1 -1
- package/link/schema/schema.cjs +3 -3
- package/link/schema/schema.cjs.map +1 -1
- package/link/schema/schema.cjs.native.js +3 -3
- package/link/subscriptions/index.js +35 -2
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +3 -2
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +3 -2
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/filterOperationVariables.js +4 -0
- package/link/utils/filterOperationVariables.js.map +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/transformOperation.js +3 -2
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +12 -0
- package/link/ws/index.js +1 -1
- package/link/ws/index.js.map +1 -1
- package/link/ws/ws.cjs +1 -1
- package/link/ws/ws.cjs.map +1 -1
- package/link/ws/ws.cjs.native.js +1 -1
- package/package.json +51 -38
- package/react/cache/QueryReference.d.ts +18 -10
- package/react/cache/QueryReference.js +52 -8
- package/react/cache/QueryReference.js.map +1 -1
- package/react/cache/SuspenseCache.d.ts +10 -0
- package/react/cache/SuspenseCache.js +1 -2
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/cache/getSuspenseCache.js.map +1 -1
- package/react/cache/types.d.ts +3 -0
- package/react/cache/types.js.map +1 -1
- package/react/components/Mutation.d.ts +2 -2
- package/react/components/Mutation.js.map +1 -1
- package/react/components/Query.d.ts +2 -2
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.d.ts +2 -2
- package/react/components/Subscription.js.map +1 -1
- package/react/components/types.d.ts +4 -4
- package/react/components/types.js.map +1 -1
- package/react/context/ApolloConsumer.d.ts +3 -3
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +7 -2
- package/react/context/ApolloContext.js +11 -4
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +3 -3
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/context/context.cjs +2 -4
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +2 -4
- package/react/hoc/graphql.d.ts +2 -2
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts +2 -1
- package/react/hoc/hoc-utils.js +4 -2
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs +10 -18
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +10 -18
- package/react/hoc/mutation-hoc.d.ts +2 -2
- package/react/hoc/mutation-hoc.js +10 -5
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +2 -2
- package/react/hoc/query-hoc.js +11 -5
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +2 -2
- package/react/hoc/subscription-hoc.js +11 -5
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.d.ts +2 -2
- package/react/hoc/withApollo.js +4 -5
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +139 -67
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +139 -67
- package/react/hooks/index.d.ts +2 -0
- package/react/hooks/index.js +1 -0
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/internal/__use.js +6 -1
- 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 +1 -1
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +2 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +7 -4
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/internal/useRenderGuard.d.ts +2 -0
- package/react/hooks/internal/useRenderGuard.js +17 -0
- package/react/hooks/internal/useRenderGuard.js.map +1 -0
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.js +15 -12
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +5 -4
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +14 -5
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +30 -0
- package/react/hooks/useLoadableQuery.js +61 -0
- package/react/hooks/useLoadableQuery.js.map +1 -0
- package/react/hooks/useMutation.js +9 -4
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +11 -0
- package/react/hooks/useQuery.js +139 -7
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReactiveVar.js +6 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +19 -0
- package/react/hooks/useReadQuery.js +5 -11
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +6 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +23 -23
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +54 -2
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/parser/index.d.ts +3 -0
- package/react/parser/index.js +13 -6
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +11 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +11 -5
- package/react/ssr/RenderPromises.d.ts +3 -3
- package/react/ssr/RenderPromises.js +21 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/getDataFromTree.d.ts +4 -4
- package/react/ssr/getDataFromTree.js +19 -4
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/renderToStringWithData.d.ts +2 -2
- package/react/ssr/renderToStringWithData.js.map +1 -1
- package/react/ssr/ssr.cjs +7 -5
- package/react/ssr/ssr.cjs.map +1 -1
- package/react/ssr/ssr.cjs.native.js +7 -5
- package/react/types/types.d.ts +125 -3
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +14 -11
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +14 -11
- package/testing/core/itAsync.d.ts +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockFetch.d.ts +2 -2
- package/testing/core/mocking/mockFetch.js +8 -4
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +1 -1
- package/testing/core/mocking/mockLink.js +17 -7
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.js +2 -0
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.js +1 -1
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +17 -3
- package/testing/core/observableToPromise.js +5 -0
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/subscribeAndCount.js +3 -0
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/core/wait.js +2 -2
- package/testing/core/wait.js.map +1 -1
- package/testing/core/withConsoleSpy.d.ts +3 -0
- package/testing/core/withConsoleSpy.js +7 -1
- package/testing/core/withConsoleSpy.js.map +1 -1
- package/testing/core/wrap.js +2 -0
- package/testing/core/wrap.js.map +1 -1
- package/testing/internal/ObservableStream.js +14 -14
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/disposables/disableActWarnings.d.ts +10 -0
- package/testing/internal/disposables/disableActWarnings.js +15 -0
- package/testing/internal/disposables/disableActWarnings.js.map +1 -0
- package/testing/internal/disposables/index.d.ts +1 -0
- package/testing/internal/disposables/index.js +1 -0
- package/testing/internal/disposables/index.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 +32 -1
- package/testing/internal/profile/Render.js +14 -2
- package/testing/internal/profile/Render.js.map +1 -1
- package/testing/internal/profile/context.d.ts +10 -0
- package/testing/internal/profile/context.js +14 -0
- package/testing/internal/profile/context.js.map +1 -0
- package/testing/internal/profile/index.d.ts +2 -2
- package/testing/internal/profile/index.js +1 -1
- package/testing/internal/profile/index.js.map +1 -1
- package/testing/internal/profile/profile.d.ts +67 -13
- package/testing/internal/profile/profile.js +153 -79
- 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 +29 -26
- package/testing/matchers/ProfiledComponent.js.map +1 -1
- package/testing/matchers/index.js +2 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toBeGarbageCollected.d.ts +8 -0
- package/testing/matchers/toBeGarbageCollected.js +48 -0
- package/testing/matchers/toBeGarbageCollected.js.map +1 -0
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +5 -1
- 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/canonicalStringify.d.ts +17 -0
- package/utilities/common/canonicalStringify.js +41 -0
- package/utilities/common/canonicalStringify.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.d.ts +6 -5
- package/utilities/graphql/DocumentTransform.js +48 -27
- 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.d.ts +4 -2
- package/utilities/graphql/print.js +11 -7
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +14 -0
- package/utilities/graphql/storeUtils.js +8 -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/index.d.ts +2 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +1 -1
- package/utilities/observables/Concast.js +85 -2
- 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/subscriptions/relay/index.js.map +1 -1
- package/utilities/subscriptions/relay/relay.cjs +9 -8
- package/utilities/subscriptions/relay/relay.cjs.map +1 -1
- package/utilities/subscriptions/relay/relay.cjs.native.js +9 -8
- package/utilities/subscriptions/urql/index.js.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs +9 -8
- package/utilities/subscriptions/urql/urql.cjs.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs.native.js +9 -8
- 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/OnlyRequiredProperties.d.ts +7 -0
- package/utilities/types/OnlyRequiredProperties.js +2 -0
- package/utilities/types/OnlyRequiredProperties.js.map +1 -0
- 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 +68 -55
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +68 -55
- 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/canonicalStringify.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/subscriptions/relay/index.d.ts.map +0 -1
- package/utilities/subscriptions/shared.d.ts.map +0 -1
- package/utilities/subscriptions/urql/index.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
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var globals = require('../../utilities/globals');
|
|
6
|
-
var React = require('
|
|
6
|
+
var React = require('rehackt');
|
|
7
7
|
var context = require('../context');
|
|
8
8
|
var tslib = require('tslib');
|
|
9
9
|
var utilities = require('../../utilities');
|
|
@@ -41,7 +41,8 @@ var realHook$1 = React__namespace[uSESKey];
|
|
|
41
41
|
var useSyncExternalStore = realHook$1 ||
|
|
42
42
|
(function (subscribe, getSnapshot, getServerSnapshot) {
|
|
43
43
|
var value = getSnapshot();
|
|
44
|
-
if (
|
|
44
|
+
if (
|
|
45
|
+
globalThis.__DEV__ !== false &&
|
|
45
46
|
!didWarnUncachedGetSnapshot &&
|
|
46
47
|
value !== getSnapshot()) {
|
|
47
48
|
didWarnUncachedGetSnapshot = true;
|
|
@@ -99,7 +100,7 @@ function useInternalState(client, query) {
|
|
|
99
100
|
state.forceUpdateState = React__namespace.useReducer(function (tick) { return tick + 1; }, 0)[1];
|
|
100
101
|
return state;
|
|
101
102
|
}
|
|
102
|
-
var InternalState =
|
|
103
|
+
var InternalState = (function () {
|
|
103
104
|
function InternalState(client, query, previous) {
|
|
104
105
|
var _this = this;
|
|
105
106
|
this.client = client;
|
|
@@ -126,7 +127,7 @@ var InternalState = (function () {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
InternalState.prototype.forceUpdateState = function () {
|
|
129
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(
|
|
130
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(51);
|
|
130
131
|
};
|
|
131
132
|
InternalState.prototype.executeQuery = function (options) {
|
|
132
133
|
var _this = this;
|
|
@@ -249,7 +250,8 @@ var InternalState = (function () {
|
|
|
249
250
|
InternalState.prototype.createWatchQueryOptions = function (_a) {
|
|
250
251
|
var _b;
|
|
251
252
|
if (_a === void 0) { _a = {}; }
|
|
252
|
-
var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.defaultOptions;
|
|
253
|
+
var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.defaultOptions;
|
|
254
|
+
var otherOptions = tslib.__rest(_a, ["skip", "ssr", "onCompleted", "onError", "defaultOptions"]);
|
|
253
255
|
var watchQueryOptions = Object.assign(otherOptions, { query: this.query });
|
|
254
256
|
if (this.renderPromises &&
|
|
255
257
|
(watchQueryOptions.fetchPolicy === "network-only" ||
|
|
@@ -335,8 +337,8 @@ var InternalState = (function () {
|
|
|
335
337
|
}
|
|
336
338
|
};
|
|
337
339
|
InternalState.prototype.toApolloError = function (result) {
|
|
338
|
-
return utilities.isNonEmptyArray(result.errors)
|
|
339
|
-
|
|
340
|
+
return utilities.isNonEmptyArray(result.errors) ?
|
|
341
|
+
new errors.ApolloError({ graphQLErrors: result.errors })
|
|
340
342
|
: result.error;
|
|
341
343
|
};
|
|
342
344
|
InternalState.prototype.getCurrentResult = function () {
|
|
@@ -416,10 +418,10 @@ function useLazyQuery(query, options) {
|
|
|
416
418
|
}, []);
|
|
417
419
|
Object.assign(result, eagerMethods);
|
|
418
420
|
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
419
|
-
execOptionsRef.current =
|
|
420
|
-
? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
execOptionsRef.current =
|
|
422
|
+
executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
423
|
+
fetchPolicy: initialFetchPolicy,
|
|
424
|
+
};
|
|
423
425
|
var options = utilities.mergeOptions(optionsRef.current, tslib.__assign({ query: queryRef.current }, execOptionsRef.current));
|
|
424
426
|
var promise = internalState
|
|
425
427
|
.executeQuery(tslib.__assign(tslib.__assign({}, options), { skip: false }))
|
|
@@ -472,8 +474,8 @@ function useMutation(mutation, options) {
|
|
|
472
474
|
.then(function (response) {
|
|
473
475
|
var _a, _b;
|
|
474
476
|
var data = response.data, errors$1 = response.errors;
|
|
475
|
-
var error = errors$1 && errors$1.length > 0
|
|
476
|
-
|
|
477
|
+
var error = errors$1 && errors$1.length > 0 ?
|
|
478
|
+
new errors.ApolloError({ graphQLErrors: errors$1 })
|
|
477
479
|
: void 0;
|
|
478
480
|
var onError = executeOptions.onError || ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError);
|
|
479
481
|
if (error && onError) {
|
|
@@ -522,7 +524,9 @@ function useMutation(mutation, options) {
|
|
|
522
524
|
}, []);
|
|
523
525
|
var reset = React__namespace.useCallback(function () {
|
|
524
526
|
if (ref.current.isMounted) {
|
|
525
|
-
|
|
527
|
+
var result_3 = { called: false, loading: false, client: client };
|
|
528
|
+
Object.assign(ref.current, { mutationId: 0, result: result_3 });
|
|
529
|
+
setResult(result_3);
|
|
526
530
|
}
|
|
527
531
|
}, []);
|
|
528
532
|
React__namespace.useEffect(function () {
|
|
@@ -695,9 +699,9 @@ function useFragment(options) {
|
|
|
695
699
|
var latestDiff = cache.diff(diffOptions);
|
|
696
700
|
var getSnapshot = function () {
|
|
697
701
|
var latestDiffToResult = diffToResult(latestDiff);
|
|
698
|
-
return resultRef.current &&
|
|
699
|
-
equality.equal(resultRef.current.data, latestDiffToResult.data)
|
|
700
|
-
|
|
702
|
+
return (resultRef.current &&
|
|
703
|
+
equality.equal(resultRef.current.data, latestDiffToResult.data)) ?
|
|
704
|
+
resultRef.current
|
|
701
705
|
: (resultRef.current = latestDiffToResult);
|
|
702
706
|
};
|
|
703
707
|
return useSyncExternalStore(function (forceUpdate) {
|
|
@@ -733,6 +737,18 @@ function useDeepMemo(memoFn, deps) {
|
|
|
733
737
|
return ref.current.value;
|
|
734
738
|
}
|
|
735
739
|
|
|
740
|
+
function getRenderDispatcher() {
|
|
741
|
+
var _a, _b;
|
|
742
|
+
return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
|
|
743
|
+
}
|
|
744
|
+
var RenderDispatcher = null;
|
|
745
|
+
function useRenderGuard() {
|
|
746
|
+
RenderDispatcher = getRenderDispatcher();
|
|
747
|
+
return React__namespace.useCallback(function () {
|
|
748
|
+
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
|
|
749
|
+
}, []);
|
|
750
|
+
}
|
|
751
|
+
|
|
736
752
|
var useKey = "use";
|
|
737
753
|
var realHook = React__namespace[useKey];
|
|
738
754
|
var __use = realHook ||
|
|
@@ -749,12 +765,27 @@ var __use = realHook ||
|
|
|
749
765
|
};
|
|
750
766
|
|
|
751
767
|
var QUERY_REFERENCE_SYMBOL = Symbol();
|
|
768
|
+
var PROMISE_SYMBOL = Symbol();
|
|
752
769
|
function wrapQueryRef(internalQueryRef) {
|
|
753
770
|
var _a;
|
|
754
|
-
return _a = {},
|
|
771
|
+
return _a = {},
|
|
772
|
+
_a[QUERY_REFERENCE_SYMBOL] = internalQueryRef,
|
|
773
|
+
_a[PROMISE_SYMBOL] = internalQueryRef.promise,
|
|
774
|
+
_a;
|
|
755
775
|
}
|
|
756
776
|
function unwrapQueryRef(queryRef) {
|
|
757
|
-
|
|
777
|
+
var internalQueryRef = queryRef[QUERY_REFERENCE_SYMBOL];
|
|
778
|
+
return [
|
|
779
|
+
internalQueryRef,
|
|
780
|
+
function () {
|
|
781
|
+
return internalQueryRef.promise.status === "fulfilled" ?
|
|
782
|
+
internalQueryRef.promise
|
|
783
|
+
: queryRef[PROMISE_SYMBOL];
|
|
784
|
+
},
|
|
785
|
+
];
|
|
786
|
+
}
|
|
787
|
+
function updateWrappedQueryRef(queryRef, promise) {
|
|
788
|
+
queryRef[PROMISE_SYMBOL] = promise;
|
|
758
789
|
}
|
|
759
790
|
var OBSERVED_CHANGED_OPTIONS = [
|
|
760
791
|
"canonizeResults",
|
|
@@ -764,9 +795,10 @@ var OBSERVED_CHANGED_OPTIONS = [
|
|
|
764
795
|
"refetchWritePolicy",
|
|
765
796
|
"returnPartialData",
|
|
766
797
|
];
|
|
767
|
-
var InternalQueryReference =
|
|
798
|
+
var InternalQueryReference = (function () {
|
|
768
799
|
function InternalQueryReference(observable, options) {
|
|
769
800
|
var _this = this;
|
|
801
|
+
this.key = {};
|
|
770
802
|
this.listeners = new Set();
|
|
771
803
|
this.status = "loading";
|
|
772
804
|
this.references = 0;
|
|
@@ -775,7 +807,6 @@ var InternalQueryReference = (function () {
|
|
|
775
807
|
this.dispose = this.dispose.bind(this);
|
|
776
808
|
this.observable = observable;
|
|
777
809
|
this.result = observable.getCurrentResult(false);
|
|
778
|
-
this.key = options.key;
|
|
779
810
|
if (options.onDispose) {
|
|
780
811
|
this.onDispose = options.onDispose;
|
|
781
812
|
}
|
|
@@ -786,10 +817,10 @@ var InternalQueryReference = (function () {
|
|
|
786
817
|
this.status = "idle";
|
|
787
818
|
}
|
|
788
819
|
else {
|
|
789
|
-
this.promise = new Promise(function (resolve, reject) {
|
|
820
|
+
this.promise = utilities.wrapPromiseWithState(new Promise(function (resolve, reject) {
|
|
790
821
|
_this.resolve = resolve;
|
|
791
822
|
_this.reject = reject;
|
|
792
|
-
});
|
|
823
|
+
}));
|
|
793
824
|
}
|
|
794
825
|
this.subscription = observable
|
|
795
826
|
.filter(function (_a) {
|
|
@@ -921,10 +952,10 @@ var InternalQueryReference = (function () {
|
|
|
921
952
|
InternalQueryReference.prototype.initiateFetch = function (returnedPromise) {
|
|
922
953
|
var _this = this;
|
|
923
954
|
this.status = "loading";
|
|
924
|
-
this.promise = new Promise(function (resolve, reject) {
|
|
955
|
+
this.promise = utilities.wrapPromiseWithState(new Promise(function (resolve, reject) {
|
|
925
956
|
_this.resolve = resolve;
|
|
926
957
|
_this.reject = reject;
|
|
927
|
-
});
|
|
958
|
+
}));
|
|
928
959
|
this.promise.catch(function () { });
|
|
929
960
|
returnedPromise
|
|
930
961
|
.then(function (result) {
|
|
@@ -941,7 +972,7 @@ var InternalQueryReference = (function () {
|
|
|
941
972
|
return InternalQueryReference;
|
|
942
973
|
}());
|
|
943
974
|
|
|
944
|
-
var SuspenseCache =
|
|
975
|
+
var SuspenseCache = (function () {
|
|
945
976
|
function SuspenseCache(options) {
|
|
946
977
|
if (options === void 0) { options = Object.create(null); }
|
|
947
978
|
this.queryRefs = new trie.Trie(utilities.canUseWeakMap);
|
|
@@ -951,7 +982,6 @@ var SuspenseCache = (function () {
|
|
|
951
982
|
var ref = this.queryRefs.lookupArray(cacheKey);
|
|
952
983
|
if (!ref.current) {
|
|
953
984
|
ref.current = new InternalQueryReference(createObservable(), {
|
|
954
|
-
key: cacheKey,
|
|
955
985
|
autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
|
|
956
986
|
onDispose: function () {
|
|
957
987
|
delete ref.current;
|
|
@@ -978,7 +1008,11 @@ function useSuspenseQuery(query, options) {
|
|
|
978
1008
|
if (options === void 0) { options = Object.create(null); }
|
|
979
1009
|
var client = useApolloClient(options.client);
|
|
980
1010
|
var suspenseCache = getSuspenseCache(client);
|
|
981
|
-
var watchQueryOptions = useWatchQueryOptions({
|
|
1011
|
+
var watchQueryOptions = useWatchQueryOptions({
|
|
1012
|
+
client: client,
|
|
1013
|
+
query: query,
|
|
1014
|
+
options: options,
|
|
1015
|
+
});
|
|
982
1016
|
var fetchPolicy = watchQueryOptions.fetchPolicy, variables = watchQueryOptions.variables;
|
|
983
1017
|
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
984
1018
|
var cacheKey = tslib.__spreadArray([
|
|
@@ -988,22 +1022,19 @@ function useSuspenseQuery(query, options) {
|
|
|
988
1022
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
989
1023
|
return client.watchQuery(watchQueryOptions);
|
|
990
1024
|
});
|
|
991
|
-
var _b = React__namespace.useState(
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
promiseCache.set(queryRef.key, promise);
|
|
1025
|
+
var _b = React__namespace.useState([queryRef.key, queryRef.promise]), current = _b[0], setPromise = _b[1];
|
|
1026
|
+
if (current[0] !== queryRef.key) {
|
|
1027
|
+
current[0] = queryRef.key;
|
|
1028
|
+
current[1] = queryRef.promise;
|
|
996
1029
|
}
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1030
|
+
var promise = current[1];
|
|
1031
|
+
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
1032
|
+
current[1] = promise = queryRef.applyOptions(watchQueryOptions);
|
|
1000
1033
|
}
|
|
1001
1034
|
React__namespace.useEffect(function () {
|
|
1002
1035
|
var dispose = queryRef.retain();
|
|
1003
1036
|
var removeListener = queryRef.listen(function (promise) {
|
|
1004
|
-
|
|
1005
|
-
return new Map(promiseCache).set(queryRef.key, promise);
|
|
1006
|
-
});
|
|
1037
|
+
setPromise([queryRef.key, promise]);
|
|
1007
1038
|
});
|
|
1008
1039
|
return function () {
|
|
1009
1040
|
removeListener();
|
|
@@ -1020,18 +1051,14 @@ function useSuspenseQuery(query, options) {
|
|
|
1020
1051
|
};
|
|
1021
1052
|
}, [queryRef.result]);
|
|
1022
1053
|
var result = fetchPolicy === "standby" ? skipResult : __use(promise);
|
|
1023
|
-
var fetchMore = React__namespace.useCallback(function (options) {
|
|
1054
|
+
var fetchMore = React__namespace.useCallback((function (options) {
|
|
1024
1055
|
var promise = queryRef.fetchMore(options);
|
|
1025
|
-
|
|
1026
|
-
return new Map(previousPromiseCache).set(queryRef.key, queryRef.promise);
|
|
1027
|
-
});
|
|
1056
|
+
setPromise([queryRef.key, queryRef.promise]);
|
|
1028
1057
|
return promise;
|
|
1029
|
-
}, [queryRef]);
|
|
1058
|
+
}), [queryRef]);
|
|
1030
1059
|
var refetch = React__namespace.useCallback(function (variables) {
|
|
1031
1060
|
var promise = queryRef.refetch(variables);
|
|
1032
|
-
|
|
1033
|
-
return new Map(previousPromiseCache).set(queryRef.key, queryRef.promise);
|
|
1034
|
-
});
|
|
1061
|
+
setPromise([queryRef.key, queryRef.promise]);
|
|
1035
1062
|
return promise;
|
|
1036
1063
|
}, [queryRef]);
|
|
1037
1064
|
var subscribeToMore = React__namespace.useCallback(function (options) { return queryRef.observable.subscribeToMore(options); }, [queryRef]);
|
|
@@ -1069,8 +1096,8 @@ function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
|
1069
1096
|
}
|
|
1070
1097
|
}
|
|
1071
1098
|
function toApolloError(result) {
|
|
1072
|
-
return utilities.isNonEmptyArray(result.errors)
|
|
1073
|
-
|
|
1099
|
+
return utilities.isNonEmptyArray(result.errors) ?
|
|
1100
|
+
new core.ApolloError({ graphQLErrors: result.errors })
|
|
1074
1101
|
: result.error;
|
|
1075
1102
|
}
|
|
1076
1103
|
function useWatchQueryOptions(_a) {
|
|
@@ -1110,47 +1137,91 @@ function useBackgroundQuery(query, options) {
|
|
|
1110
1137
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
1111
1138
|
return client.watchQuery(watchQueryOptions);
|
|
1112
1139
|
});
|
|
1113
|
-
var _b = React__namespace.useState(
|
|
1140
|
+
var _b = React__namespace.useState(wrapQueryRef(queryRef)), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
|
|
1141
|
+
if (unwrapQueryRef(wrappedQueryRef)[0] !== queryRef) {
|
|
1142
|
+
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
1143
|
+
}
|
|
1114
1144
|
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
1115
1145
|
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
1116
|
-
|
|
1146
|
+
updateWrappedQueryRef(wrappedQueryRef, promise);
|
|
1117
1147
|
}
|
|
1118
1148
|
React__namespace.useEffect(function () { return queryRef.retain(); }, [queryRef]);
|
|
1119
1149
|
var fetchMore = React__namespace.useCallback(function (options) {
|
|
1120
1150
|
var promise = queryRef.fetchMore(options);
|
|
1121
|
-
|
|
1122
|
-
return new Map(promiseCache).set(queryRef.key, queryRef.promise);
|
|
1123
|
-
});
|
|
1151
|
+
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
1124
1152
|
return promise;
|
|
1125
1153
|
}, [queryRef]);
|
|
1126
1154
|
var refetch = React__namespace.useCallback(function (variables) {
|
|
1127
1155
|
var promise = queryRef.refetch(variables);
|
|
1128
|
-
|
|
1129
|
-
return new Map(promiseCache).set(queryRef.key, queryRef.promise);
|
|
1130
|
-
});
|
|
1156
|
+
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
1131
1157
|
return promise;
|
|
1132
1158
|
}, [queryRef]);
|
|
1133
|
-
queryRef.promiseCache = promiseCache;
|
|
1134
|
-
var wrappedQueryRef = React__namespace.useMemo(function () { return wrapQueryRef(queryRef); }, [queryRef]);
|
|
1135
1159
|
return [
|
|
1136
1160
|
didFetchResult.current ? wrappedQueryRef : void 0,
|
|
1137
1161
|
{ fetchMore: fetchMore, refetch: refetch },
|
|
1138
1162
|
];
|
|
1139
1163
|
}
|
|
1140
1164
|
|
|
1141
|
-
function
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
var
|
|
1145
|
-
|
|
1146
|
-
|
|
1165
|
+
function useLoadableQuery(query, options) {
|
|
1166
|
+
if (options === void 0) { options = Object.create(null); }
|
|
1167
|
+
var client = useApolloClient(options.client);
|
|
1168
|
+
var suspenseCache = getSuspenseCache(client);
|
|
1169
|
+
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
1170
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
1171
|
+
var _b = React__namespace.useState(null), queryRef = _b[0], setQueryRef = _b[1];
|
|
1172
|
+
var internalQueryRef = queryRef && unwrapQueryRef(queryRef)[0];
|
|
1173
|
+
if (queryRef && (internalQueryRef === null || internalQueryRef === void 0 ? void 0 : internalQueryRef.didChangeOptions(watchQueryOptions))) {
|
|
1174
|
+
var promise = internalQueryRef.applyOptions(watchQueryOptions);
|
|
1175
|
+
updateWrappedQueryRef(queryRef, promise);
|
|
1147
1176
|
}
|
|
1177
|
+
var calledDuringRender = useRenderGuard();
|
|
1178
|
+
React__namespace.useEffect(function () { return internalQueryRef === null || internalQueryRef === void 0 ? void 0 : internalQueryRef.retain(); }, [internalQueryRef]);
|
|
1179
|
+
var fetchMore = React__namespace.useCallback(function (options) {
|
|
1180
|
+
if (!internalQueryRef) {
|
|
1181
|
+
throw new Error("The query has not been loaded. Please load the query.");
|
|
1182
|
+
}
|
|
1183
|
+
var promise = internalQueryRef.fetchMore(options);
|
|
1184
|
+
setQueryRef(wrapQueryRef(internalQueryRef));
|
|
1185
|
+
return promise;
|
|
1186
|
+
}, [internalQueryRef]);
|
|
1187
|
+
var refetch = React__namespace.useCallback(function (options) {
|
|
1188
|
+
if (!internalQueryRef) {
|
|
1189
|
+
throw new Error("The query has not been loaded. Please load the query.");
|
|
1190
|
+
}
|
|
1191
|
+
var promise = internalQueryRef.refetch(options);
|
|
1192
|
+
setQueryRef(wrapQueryRef(internalQueryRef));
|
|
1193
|
+
return promise;
|
|
1194
|
+
}, [internalQueryRef]);
|
|
1195
|
+
var loadQuery = React__namespace.useCallback(function () {
|
|
1196
|
+
var args = [];
|
|
1197
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1198
|
+
args[_i] = arguments[_i];
|
|
1199
|
+
}
|
|
1200
|
+
globals.invariant(!calledDuringRender(), 50);
|
|
1201
|
+
var variables = args[0];
|
|
1202
|
+
var cacheKey = tslib.__spreadArray([
|
|
1203
|
+
query,
|
|
1204
|
+
cache.canonicalStringify(variables)
|
|
1205
|
+
], [].concat(queryKey), true);
|
|
1206
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
1207
|
+
return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
|
|
1208
|
+
});
|
|
1209
|
+
setQueryRef(wrapQueryRef(queryRef));
|
|
1210
|
+
}, [query, queryKey, suspenseCache, watchQueryOptions, calledDuringRender]);
|
|
1211
|
+
var reset = React__namespace.useCallback(function () {
|
|
1212
|
+
setQueryRef(null);
|
|
1213
|
+
}, [queryRef]);
|
|
1214
|
+
return [loadQuery, queryRef, { fetchMore: fetchMore, refetch: refetch, reset: reset }];
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
function useReadQuery(queryRef) {
|
|
1218
|
+
var _a = React__namespace.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]), internalQueryRef = _a[0], getPromise = _a[1];
|
|
1148
1219
|
var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
1149
1220
|
return internalQueryRef.listen(function (promise) {
|
|
1150
|
-
|
|
1221
|
+
updateWrappedQueryRef(queryRef, promise);
|
|
1151
1222
|
forceUpdate();
|
|
1152
1223
|
});
|
|
1153
|
-
}, [internalQueryRef]),
|
|
1224
|
+
}, [internalQueryRef]), getPromise, getPromise);
|
|
1154
1225
|
var result = __use(promise);
|
|
1155
1226
|
return React__namespace.useMemo(function () {
|
|
1156
1227
|
return {
|
|
@@ -1166,6 +1237,7 @@ exports.useApolloClient = useApolloClient;
|
|
|
1166
1237
|
exports.useBackgroundQuery = useBackgroundQuery;
|
|
1167
1238
|
exports.useFragment = useFragment;
|
|
1168
1239
|
exports.useLazyQuery = useLazyQuery;
|
|
1240
|
+
exports.useLoadableQuery = useLoadableQuery;
|
|
1169
1241
|
exports.useMutation = useMutation;
|
|
1170
1242
|
exports.useQuery = useQuery;
|
|
1171
1243
|
exports.useReactiveVar = useReactiveVar;
|
package/react/hooks/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export type { UseSuspenseQueryResult } from "./useSuspenseQuery.js";
|
|
|
10
10
|
export { useSuspenseQuery } from "./useSuspenseQuery.js";
|
|
11
11
|
export type { UseBackgroundQueryResult } from "./useBackgroundQuery.js";
|
|
12
12
|
export { useBackgroundQuery } from "./useBackgroundQuery.js";
|
|
13
|
+
export type { LoadQueryFunction, UseLoadableQueryResult, } from "./useLoadableQuery.js";
|
|
14
|
+
export { useLoadableQuery } from "./useLoadableQuery.js";
|
|
13
15
|
export type { UseReadQueryResult } from "./useReadQuery.js";
|
|
14
16
|
export { useReadQuery } from "./useReadQuery.js";
|
|
15
17
|
export { skipToken } from "./constants.js";
|
package/react/hooks/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./useReactiveVar.js";
|
|
|
8
8
|
export * from "./useFragment.js";
|
|
9
9
|
export { useSuspenseQuery } from "./useSuspenseQuery.js";
|
|
10
10
|
export { useBackgroundQuery } from "./useBackgroundQuery.js";
|
|
11
|
+
export { useLoadableQuery } from "./useLoadableQuery.js";
|
|
11
12
|
export { useReadQuery } from "./useReadQuery.js";
|
|
12
13
|
export { skipToken } from "./constants.js";
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
package/react/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAE1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAE1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["import \"../../utilities/globals/index.js\";\n\nexport * from \"./useApolloClient.js\";\nexport * from \"./useLazyQuery.js\";\nexport * from \"./useMutation.js\";\nexport { useQuery } from \"./useQuery.js\";\nexport * from \"./useSubscription.js\";\nexport * from \"./useReactiveVar.js\";\nexport * from \"./useFragment.js\";\nexport type { UseSuspenseQueryResult } from \"./useSuspenseQuery.js\";\nexport { useSuspenseQuery } from \"./useSuspenseQuery.js\";\nexport type { UseBackgroundQueryResult } from \"./useBackgroundQuery.js\";\nexport { useBackgroundQuery } from \"./useBackgroundQuery.js\";\nexport type {\n LoadQueryFunction,\n UseLoadableQueryResult,\n} from \"./useLoadableQuery.js\";\nexport { useLoadableQuery } from \"./useLoadableQuery.js\";\nexport type { UseReadQueryResult } from \"./useReadQuery.js\";\nexport { useReadQuery } from \"./useReadQuery.js\";\nexport { skipToken } from \"./constants.js\";\nexport type { SkipToken } from \"./constants.js\";\n"]}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { wrapPromiseWithState } from "../../../utilities/index.js";
|
|
2
|
-
import * as React from "
|
|
2
|
+
import * as React from "rehackt";
|
|
3
|
+
// Prevent webpack from complaining about our feature detection of the
|
|
4
|
+
// use property of the React namespace, which is expected not
|
|
5
|
+
// to exist when using current stable versions, and that's fine.
|
|
3
6
|
var useKey = "use";
|
|
4
7
|
var realHook = React[useKey];
|
|
8
|
+
// This is named with two underscores to allow this hook to evade typical rules of
|
|
9
|
+
// hooks (i.e. it can be used conditionally)
|
|
5
10
|
export var __use = realHook ||
|
|
6
11
|
function __use(promise) {
|
|
7
12
|
var statefulPromise = wrapPromiseWithState(promise);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"__use.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/__use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"__use.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/__use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAGjC,sEAAsE;AACtE,6DAA6D;AAC7D,gEAAgE;AAChE,IAAM,MAAM,GAAG,KAA2B,CAAC;AAC3C,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAoB,CAAC;AAElD,kFAAkF;AAClF,4CAA4C;AAC5C,MAAM,CAAC,IAAM,KAAK,GAChB,QAAQ;IACR,SAAS,KAAK,CAAS,OAAwB;QAC7C,IAAM,eAAe,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;QAEtD,QAAQ,eAAe,CAAC,MAAM,EAAE,CAAC;YAC/B,KAAK,SAAS;gBACZ,MAAM,eAAe,CAAC;YACxB,KAAK,UAAU;gBACb,MAAM,eAAe,CAAC,MAAM,CAAC;YAC/B,KAAK,WAAW;gBACd,OAAO,eAAe,CAAC,KAAK,CAAC;QACjC,CAAC;IACH,CAAC,CAAC","sourcesContent":["import { wrapPromiseWithState } from \"../../../utilities/index.js\";\nimport * as React from \"rehackt\";\n\ntype Use = <T>(promise: Promise<T>) => T;\n// Prevent webpack from complaining about our feature detection of the\n// use property of the React namespace, which is expected not\n// to exist when using current stable versions, and that's fine.\nconst useKey = \"use\" as keyof typeof React;\nconst realHook = React[useKey] as Use | undefined;\n\n// This is named with two underscores to allow this hook to evade typical rules of\n// hooks (i.e. it can be used conditionally)\nexport const __use =\n realHook ||\n function __use<TValue>(promise: Promise<TValue>) {\n const statefulPromise = wrapPromiseWithState(promise);\n\n switch (statefulPromise.status) {\n case \"pending\":\n throw statefulPromise;\n case \"rejected\":\n throw statefulPromise.reason;\n case \"fulfilled\":\n return statefulPromise.value;\n }\n };\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
// These hooks are used internally and are not exported publicly by the library
|
|
1
2
|
export { useDeepMemo } from "./useDeepMemo.js";
|
|
2
3
|
export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect.js";
|
|
4
|
+
export { useRenderGuard } from "./useRenderGuard.js";
|
|
3
5
|
export { __use } from "./__use.js";
|
|
4
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// These hooks are used internally and are not exported publicly by the library\nexport { useDeepMemo } from \"./useDeepMemo.js\";\nexport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect.js\";\nexport { useRenderGuard } from \"./useRenderGuard.js\";\nexport { __use } from \"./__use.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,MAAoB,EACpB,IAAoB;IAEpB,IAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAA2C,CAAC;IAEpE,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACnD,GAAG,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,MAAA,EAAE,CAAC;IAC1C,CAAC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC;AAC3B,CAAC","sourcesContent":["import type { DependencyList } from \"react\";\nimport * as React from \"rehackt\";\nimport { equal } from \"@wry/equality\";\n\nexport function useDeepMemo<TValue>(\n memoFn: () => TValue,\n deps: DependencyList\n) {\n const ref = React.useRef<{ deps: DependencyList; value: TValue }>();\n\n if (!ref.current || !equal(ref.current.deps, deps)) {\n ref.current = { value: memoFn(), deps };\n }\n\n return ref.current.value;\n}\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import * as React from "
|
|
1
|
+
import * as React from "rehackt";
|
|
2
2
|
import { canUseDOM } from "../../../utilities/index.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// use canUseDOM here instead of canUseLayoutEffect because we want to be able
|
|
4
|
+
// to use useLayoutEffect in our jest tests. useLayoutEffect seems to work fine
|
|
5
|
+
// in useSuspenseQuery tests, but to honor the original comment about the
|
|
6
|
+
// warnings for useSyncExternalStore implementation, canUseLayoutEffect is left
|
|
7
|
+
// alone.
|
|
8
|
+
export var useIsomorphicLayoutEffect = canUseDOM ? React.useLayoutEffect : React.useEffect;
|
|
6
9
|
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsomorphicLayoutEffect.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useIsomorphicLayoutEffect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,8EAA8E;AAC9E,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAC/E,SAAS;AACT,MAAM,CAAC,IAAM,yBAAyB,GACpC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC","sourcesContent":["import * as React from \"rehackt\";\nimport { canUseDOM } from \"../../../utilities/index.js\";\n\n// use canUseDOM here instead of canUseLayoutEffect because we want to be able\n// to use useLayoutEffect in our jest tests. useLayoutEffect seems to work fine\n// in useSuspenseQuery tests, but to honor the original comment about the\n// warnings for useSyncExternalStore implementation, canUseLayoutEffect is left\n// alone.\nexport const useIsomorphicLayoutEffect =\n canUseDOM ? React.useLayoutEffect : React.useEffect;\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from "rehackt";
|
|
2
|
+
function getRenderDispatcher() {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
return (_b = (_a = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
|
|
5
|
+
}
|
|
6
|
+
var RenderDispatcher = null;
|
|
7
|
+
/*
|
|
8
|
+
Relay does this too, so we hope this is safe.
|
|
9
|
+
https://github.com/facebook/relay/blob/8651fbca19adbfbb79af7a3bc40834d105fd7747/packages/react-relay/relay-hooks/loadQuery.js#L90-L98
|
|
10
|
+
*/
|
|
11
|
+
export function useRenderGuard() {
|
|
12
|
+
RenderDispatcher = getRenderDispatcher();
|
|
13
|
+
return React.useCallback(function () {
|
|
14
|
+
return (RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher());
|
|
15
|
+
}, []);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useRenderGuard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRenderGuard.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useRenderGuard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,SAAS,mBAAmB;;IAC1B,OAAO,MAAA,MAAC,KAAa,CAAC,kDAAkD,0CACpE,sBAAsB,0CAAE,OAAO,CAAC;AACtC,CAAC;AAED,IAAI,gBAAgB,GAAY,IAAI,CAAC;AAErC;;;EAGE;AACF,MAAM,UAAU,cAAc;IAC5B,gBAAgB,GAAG,mBAAmB,EAAE,CAAC;IAEzC,OAAO,KAAK,CAAC,WAAW,CAAC;QACvB,OAAO,CACL,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,mBAAmB,EAAE,CACxE,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import * as React from \"rehackt\";\n\nfunction getRenderDispatcher() {\n return (React as any).__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED\n ?.ReactCurrentDispatcher?.current;\n}\n\nlet RenderDispatcher: unknown = null;\n\n/*\nRelay does this too, so we hope this is safe.\nhttps://github.com/facebook/relay/blob/8651fbca19adbfbb79af7a3bc40834d105fd7747/packages/react-relay/relay-hooks/loadQuery.js#L90-L98\n*/\nexport function useRenderGuard() {\n RenderDispatcher = getRenderDispatcher();\n\n return React.useCallback(() => {\n return (\n RenderDispatcher !== null && RenderDispatcher === getRenderDispatcher()\n );\n }, []);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { invariant } from "../../utilities/globals/index.js";
|
|
2
|
-
import * as React from "
|
|
2
|
+
import * as React from "rehackt";
|
|
3
3
|
import { getApolloContext } from "../context/index.js";
|
|
4
4
|
export function useApolloClient(override) {
|
|
5
5
|
var context = React.useContext(getApolloContext());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApolloClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,
|
|
1
|
+
{"version":3,"file":"useApolloClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,UAAU,eAAe,CAC7B,QAA+B;IAE/B,IAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACrD,IAAM,MAAM,GAAG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAC1C,SAAS,CACP,CAAC,CAAC,MAAM,EACR,oEAAoE;QAClE,0EAA0E;QAC1E,0BAA0B,CAC7B,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from \"../../utilities/globals/index.js\";\nimport * as React from \"rehackt\";\nimport type { ApolloClient } from \"../../core/index.js\";\nimport { getApolloContext } from \"../context/index.js\";\n\nexport function useApolloClient(\n override?: ApolloClient<object>\n): ApolloClient<object> {\n const context = React.useContext(getApolloContext());\n const client = override || context.client;\n invariant(\n !!client,\n 'Could not find \"client\" in the context or passed in as an option. ' +\n \"Wrap the root component in an <ApolloProvider>, or pass an ApolloClient \" +\n \"instance in via options.\"\n );\n\n return client;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __spreadArray } from "tslib";
|
|
2
|
-
import * as React from "
|
|
2
|
+
import * as React from "rehackt";
|
|
3
3
|
import { useApolloClient } from "./useApolloClient.js";
|
|
4
|
-
import { wrapQueryRef } from "../cache/QueryReference.js";
|
|
4
|
+
import { unwrapQueryRef, updateWrappedQueryRef, wrapQueryRef, } from "../cache/QueryReference.js";
|
|
5
5
|
import { getSuspenseCache } from "../cache/index.js";
|
|
6
6
|
import { useWatchQueryOptions } from "./useSuspenseQuery.js";
|
|
7
7
|
import { canonicalStringify } from "../../cache/index.js";
|
|
@@ -12,6 +12,12 @@ export function useBackgroundQuery(query, options) {
|
|
|
12
12
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
13
13
|
var fetchPolicy = watchQueryOptions.fetchPolicy, variables = watchQueryOptions.variables;
|
|
14
14
|
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
15
|
+
// This ref tracks the first time query execution is enabled to determine
|
|
16
|
+
// whether to return a query ref or `undefined`. When initialized
|
|
17
|
+
// in a skipped state (either via `skip: true` or `skipToken`) we return
|
|
18
|
+
// `undefined` for the `queryRef` until the query has been enabled. Once
|
|
19
|
+
// enabled, a query ref is always returned regardless of whether the query is
|
|
20
|
+
// skipped again later.
|
|
15
21
|
var didFetchResult = React.useRef(fetchPolicy !== "standby");
|
|
16
22
|
didFetchResult.current || (didFetchResult.current = fetchPolicy !== "standby");
|
|
17
23
|
var cacheKey = __spreadArray([
|
|
@@ -21,28 +27,25 @@ export function useBackgroundQuery(query, options) {
|
|
|
21
27
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
22
28
|
return client.watchQuery(watchQueryOptions);
|
|
23
29
|
});
|
|
24
|
-
var _b = React.useState(
|
|
30
|
+
var _b = React.useState(wrapQueryRef(queryRef)), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
|
|
31
|
+
if (unwrapQueryRef(wrappedQueryRef)[0] !== queryRef) {
|
|
32
|
+
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
33
|
+
}
|
|
25
34
|
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
26
35
|
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
27
|
-
|
|
36
|
+
updateWrappedQueryRef(wrappedQueryRef, promise);
|
|
28
37
|
}
|
|
29
38
|
React.useEffect(function () { return queryRef.retain(); }, [queryRef]);
|
|
30
39
|
var fetchMore = React.useCallback(function (options) {
|
|
31
40
|
var promise = queryRef.fetchMore(options);
|
|
32
|
-
|
|
33
|
-
return new Map(promiseCache).set(queryRef.key, queryRef.promise);
|
|
34
|
-
});
|
|
41
|
+
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
35
42
|
return promise;
|
|
36
43
|
}, [queryRef]);
|
|
37
44
|
var refetch = React.useCallback(function (variables) {
|
|
38
45
|
var promise = queryRef.refetch(variables);
|
|
39
|
-
|
|
40
|
-
return new Map(promiseCache).set(queryRef.key, queryRef.promise);
|
|
41
|
-
});
|
|
46
|
+
setWrappedQueryRef(wrapQueryRef(queryRef));
|
|
42
47
|
return promise;
|
|
43
48
|
}, [queryRef]);
|
|
44
|
-
queryRef.promiseCache = promiseCache;
|
|
45
|
-
var wrappedQueryRef = React.useMemo(function () { return wrapQueryRef(queryRef); }, [queryRef]);
|
|
46
49
|
return [
|
|
47
50
|
didFetchResult.current ? wrappedQueryRef : void 0,
|
|
48
51
|
{ fetchMore: fetchMore, refetch: refetch },
|