@apollo/client 4.0.0-rc.5 → 4.0.0-rc.7
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/CHANGELOG.md +153 -0
- package/README.md +40 -40
- package/__cjs/cache/core/cache.cjs +14 -13
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +77 -71
- package/__cjs/cache/core/types/Cache.cjs +0 -4
- package/__cjs/cache/core/types/Cache.cjs.map +1 -1
- package/__cjs/cache/core/types/Cache.d.cts +200 -15
- package/__cjs/cache/{core/types/DataProxy.cjs → deprecated.cjs} +1 -1
- package/__cjs/cache/deprecated.cjs.map +1 -0
- package/__cjs/cache/deprecated.d.cts +6 -0
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +2 -2
- package/__cjs/cache/inmemory/entityStore.cjs +25 -28
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +17 -16
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +4 -4
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +3 -2
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +1 -1
- package/__cjs/core/ApolloClient.cjs +94 -112
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +758 -182
- package/__cjs/core/ObservableQuery.cjs +10 -10
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +131 -112
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +8 -7
- package/__cjs/core/QueryManager.cjs +15 -15
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +20 -20
- package/__cjs/core/deprecated.cjs +3 -0
- package/__cjs/core/deprecated.cjs.map +1 -0
- package/__cjs/core/deprecated.d.cts +29 -0
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +10 -6
- package/__cjs/core/types.d.cts +69 -157
- package/__cjs/core/watchQueryOptions.d.cts +8 -297
- package/__cjs/dev/setErrorMessageHandler.cjs.map +1 -1
- package/__cjs/dev/setErrorMessageHandler.d.cts +4 -4
- package/__cjs/errors/CombinedGraphQLErrors.cjs +64 -11
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +168 -14
- package/__cjs/errors/CombinedProtocolErrors.cjs +54 -1
- package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedProtocolErrors.d.cts +132 -2
- package/__cjs/errors/LinkError.cjs +45 -2
- package/__cjs/errors/LinkError.cjs.map +1 -1
- package/__cjs/errors/LinkError.d.cts +45 -2
- package/__cjs/errors/LocalStateError.cjs +35 -5
- package/__cjs/errors/LocalStateError.cjs.map +1 -1
- package/__cjs/errors/LocalStateError.d.cts +41 -5
- package/__cjs/errors/ServerError.cjs +51 -8
- package/__cjs/errors/ServerError.cjs.map +1 -1
- package/__cjs/errors/ServerError.d.cts +71 -11
- package/__cjs/errors/ServerParseError.cjs +46 -8
- package/__cjs/errors/ServerParseError.cjs.map +1 -1
- package/__cjs/errors/ServerParseError.d.cts +72 -16
- package/__cjs/errors/UnconventionalError.cjs +46 -2
- package/__cjs/errors/UnconventionalError.cjs.map +1 -1
- package/__cjs/errors/UnconventionalError.d.cts +46 -2
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +4 -4
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
- package/__cjs/incremental/handlers/notImplemented.d.cts +2 -2
- package/__cjs/incremental/types.d.cts +4 -4
- package/__cjs/invariantErrorCodes.cjs +81 -85
- package/__cjs/link/batch/batchLink.cjs +3 -9
- package/__cjs/link/batch/batchLink.cjs.map +1 -1
- package/__cjs/link/batch/batchLink.d.cts +2 -3
- package/__cjs/link/batch/batching.cjs +1 -1
- package/__cjs/link/batch/batching.cjs.map +1 -1
- package/__cjs/link/batch/batching.d.cts +7 -7
- package/__cjs/link/batch-http/batchHttpLink.cjs +8 -5
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +1 -2
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +4 -4
- package/__cjs/link/context/index.cjs +1 -1
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +4 -5
- package/__cjs/link/core/ApolloLink.cjs +227 -55
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +355 -9
- package/__cjs/link/core/concat.cjs +4 -0
- package/__cjs/link/core/concat.cjs.map +1 -1
- package/__cjs/link/core/concat.d.cts +4 -0
- package/__cjs/link/core/deprecated.cjs +3 -0
- package/__cjs/link/core/deprecated.cjs.map +1 -0
- package/__cjs/link/core/deprecated.d.cts +10 -0
- package/__cjs/link/core/empty.cjs +4 -0
- package/__cjs/link/core/empty.cjs.map +1 -1
- package/__cjs/link/core/empty.d.cts +4 -0
- package/__cjs/link/core/from.cjs +4 -0
- package/__cjs/link/core/from.cjs.map +1 -1
- package/__cjs/link/core/from.d.cts +4 -0
- package/__cjs/link/core/split.cjs +4 -0
- package/__cjs/link/core/split.cjs.map +1 -1
- package/__cjs/link/core/split.d.cts +4 -0
- package/__cjs/link/core/types.d.cts +2 -33
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +20 -6
- package/__cjs/link/http/BaseHttpLink.cjs +2 -2
- package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.cjs +4 -1
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +3 -3
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +41 -26
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.d.cts +2 -2
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +3 -3
- package/__cjs/link/http/selectURI.cjs.map +1 -1
- package/__cjs/link/http/selectURI.d.cts +2 -2
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/index.cjs.map +1 -1
- package/__cjs/link/index.d.cts +2 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +11 -12
- package/__cjs/link/retry/delayFunction.cjs.map +1 -1
- package/__cjs/link/retry/delayFunction.d.cts +3 -3
- package/__cjs/link/retry/retryFunction.cjs.map +1 -1
- package/__cjs/link/retry/retryFunction.d.cts +4 -4
- package/__cjs/link/retry/retryLink.cjs +2 -2
- package/__cjs/link/retry/retryLink.cjs.map +1 -1
- package/__cjs/link/retry/retryLink.d.cts +1 -2
- package/__cjs/link/schema/index.cjs.map +1 -1
- package/__cjs/link/schema/index.d.cts +2 -3
- package/__cjs/link/subscriptions/index.cjs.map +1 -1
- package/__cjs/link/subscriptions/index.d.cts +1 -2
- package/__cjs/link/utils/createOperation.cjs +12 -4
- package/__cjs/link/utils/createOperation.cjs.map +1 -1
- package/__cjs/link/utils/createOperation.d.cts +2 -2
- package/__cjs/link/utils/index.cjs +1 -5
- package/__cjs/link/utils/index.cjs.map +1 -1
- package/__cjs/link/utils/index.d.cts +0 -2
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +1 -2
- package/__cjs/local-state/LocalState.cjs +55 -9
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/local-state/LocalState.d.cts +94 -0
- package/__cjs/masking/GraphQLCodegenDataMasking.d.cts +6 -7
- package/__cjs/masking/internal/types.d.cts +70 -70
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/utils.cjs +3 -3
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/hooks/internal/useDeepMemo.cjs +0 -3
- package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs.map +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.d.cts +2 -2
- package/__cjs/react/hooks/internal/wrapHook.cjs +1 -0
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +8 -7
- package/__cjs/react/hooks/useApolloClient.cjs +2 -2
- package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.d.cts +2 -2
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +850 -90
- package/__cjs/react/hooks/useFragment.cjs +7 -0
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +53 -2
- package/__cjs/react/hooks/useLazyQuery.cjs +0 -38
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +317 -165
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +153 -175
- package/__cjs/react/hooks/useMutation.cjs +6 -7
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +87 -65
- package/__cjs/react/hooks/useQuery.cjs +1 -35
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +207 -103
- package/__cjs/react/hooks/useQueryRefHandlers.cjs +2 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +34 -5
- package/__cjs/react/hooks/useReactiveVar.cjs +2 -1
- package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
- package/__cjs/react/hooks/useReactiveVar.d.cts +2 -1
- package/__cjs/react/hooks/useReadQuery.cjs +29 -0
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +92 -16
- package/__cjs/react/hooks/useSubscription.cjs +8 -9
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +108 -33
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +61 -29
- package/__cjs/react/hooks/useSuspenseQuery.cjs +4 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +471 -69
- package/__cjs/react/index.cjs +1 -3
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +0 -1
- package/__cjs/react/index.react-server.cjs +1 -3
- package/__cjs/react/index.react-server.cjs.map +1 -1
- package/__cjs/react/index.react-server.d.cts +0 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +2 -3
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +14 -12
- package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.d.cts +2 -2
- package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.d.cts +6 -4
- package/__cjs/react/internal/index.cjs +1 -0
- package/__cjs/react/internal/index.cjs.map +1 -1
- package/__cjs/react/internal/index.d.cts +1 -1
- package/__cjs/react/internal/types.d.cts +3 -3
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +60 -51
- package/__cjs/react/ssr/prerenderStatic.cjs +5 -4
- package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -1
- package/__cjs/react/ssr/prerenderStatic.d.cts +11 -9
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
- package/__cjs/react/types/deprecated.d.cts +1 -1
- package/__cjs/react/types/types.documentation.d.cts +15 -15
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +8 -8
- package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +3 -4
- package/__cjs/testing/core/types/deprecated.d.cts +3 -2
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +2 -3
- package/__cjs/utilities/HKT.d.cts +8 -7
- package/__cjs/utilities/caching/sizes.cjs +3 -3
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +4 -6
- package/__cjs/utilities/graphql/DocumentTransform.cjs +2 -2
- package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
- package/__cjs/utilities/index.cjs +2 -3
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +1 -2
- package/__cjs/utilities/{shared → internal}/canonicalStringify.cjs +5 -7
- package/__cjs/utilities/internal/canonicalStringify.cjs.map +1 -0
- package/__cjs/utilities/{shared → internal}/canonicalStringify.d.cts +1 -1
- package/__cjs/utilities/internal/checkDocument.cjs +2 -2
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/createFragmentMap.cjs.map +1 -1
- package/__cjs/{core → utilities/internal}/equalByQuery.cjs +13 -7
- package/__cjs/utilities/internal/equalByQuery.cjs.map +1 -0
- package/__cjs/utilities/internal/equalByQuery.d.cts +5 -0
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +13 -3
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.d.cts +13 -3
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getStoreKeyName.cjs +1 -2
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
- package/__cjs/utilities/internal/index.cjs +6 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +2 -0
- package/__cjs/utilities/internal/mergeOptions.cjs.map +1 -1
- package/__cjs/utilities/internal/mergeOptions.d.cts +2 -2
- package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -1
- package/__cjs/utilities/internal/toQueryResult.d.cts +2 -2
- package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +32 -26
- package/__cjs/utilities/internal/types/NoInfer.d.cts +31 -25
- package/__cjs/utilities/internal/types/VariablesOption.d.cts +2 -6
- package/__cjs/utilities/subscriptions/relay/index.cjs +2 -0
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +77 -71
- package/cache/core/cache.js +15 -14
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +200 -15
- package/cache/core/types/Cache.js +1 -3
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/deprecated.d.ts +6 -0
- package/cache/deprecated.js +2 -0
- package/cache/deprecated.js.map +1 -0
- package/cache/index.d.ts +2 -2
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +17 -16
- package/cache/inmemory/entityStore.js +25 -28
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +4 -4
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.d.ts +3 -2
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.js +4 -4
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +758 -182
- package/core/ApolloClient.js +94 -112
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +131 -112
- package/core/ObservableQuery.js +10 -10
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +8 -7
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +20 -20
- package/core/QueryManager.js +15 -15
- package/core/QueryManager.js.map +1 -1
- package/core/deprecated.d.ts +29 -0
- package/core/deprecated.js +2 -0
- package/core/deprecated.js.map +1 -0
- package/core/index.d.ts +10 -6
- package/core/index.js.map +1 -1
- package/core/types.d.ts +69 -157
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +9 -298
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/setErrorMessageHandler.d.ts +4 -4
- package/dev/setErrorMessageHandler.js.map +1 -1
- package/errors/CombinedGraphQLErrors.d.ts +169 -15
- package/errors/CombinedGraphQLErrors.js +65 -12
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/CombinedProtocolErrors.d.ts +133 -3
- package/errors/CombinedProtocolErrors.js +55 -2
- package/errors/CombinedProtocolErrors.js.map +1 -1
- package/errors/LinkError.d.ts +45 -2
- package/errors/LinkError.js +45 -2
- package/errors/LinkError.js.map +1 -1
- package/errors/LocalStateError.d.ts +42 -6
- package/errors/LocalStateError.js +36 -6
- package/errors/LocalStateError.js.map +1 -1
- package/errors/ServerError.d.ts +72 -12
- package/errors/ServerError.js +52 -9
- package/errors/ServerError.js.map +1 -1
- package/errors/ServerParseError.d.ts +73 -17
- package/errors/ServerParseError.js +47 -9
- package/errors/ServerParseError.js.map +1 -1
- package/errors/UnconventionalError.d.ts +46 -2
- package/errors/UnconventionalError.js +46 -2
- package/errors/UnconventionalError.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +4 -4
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/notImplemented.d.ts +2 -2
- package/incremental/handlers/notImplemented.js +1 -1
- package/incremental/handlers/notImplemented.js.map +1 -1
- package/incremental/types.d.ts +4 -4
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +81 -85
- package/link/batch/batchLink.d.ts +2 -3
- package/link/batch/batchLink.js +3 -9
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +7 -7
- package/link/batch/batching.js +2 -2
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batchHttpLink.d.ts +1 -2
- package/link/batch-http/batchHttpLink.js +7 -4
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/client-awareness/ClientAwarenessLink.d.ts +4 -4
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
- package/link/context/index.d.ts +4 -5
- package/link/context/index.js +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +355 -9
- package/link/core/ApolloLink.js +228 -57
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/concat.d.ts +4 -0
- package/link/core/concat.js +4 -0
- package/link/core/concat.js.map +1 -1
- package/link/core/deprecated.d.ts +10 -0
- package/link/core/deprecated.js +2 -0
- package/link/core/deprecated.js.map +1 -0
- package/link/core/empty.d.ts +4 -0
- package/link/core/empty.js +4 -0
- package/link/core/empty.js.map +1 -1
- package/link/core/from.d.ts +4 -0
- package/link/core/from.js +4 -0
- package/link/core/from.js.map +1 -1
- package/link/core/split.d.ts +4 -0
- package/link/core/split.js +4 -0
- package/link/core/split.js.map +1 -1
- package/link/core/types.d.ts +2 -33
- package/link/core/types.js.map +1 -1
- package/link/error/index.d.ts +20 -6
- package/link/error/index.js.map +1 -1
- package/link/http/BaseHttpLink.js +2 -2
- package/link/http/BaseHttpLink.js.map +1 -1
- package/link/http/HttpLink.d.ts +3 -3
- package/link/http/HttpLink.js +4 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
- package/link/http/parseAndCheckHttpResponse.js +41 -26
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +3 -3
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.d.ts +2 -2
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/index.d.ts +2 -1
- package/link/index.js.map +1 -1
- package/link/persisted-queries/index.d.ts +11 -12
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/index.js.map +1 -1
- package/link/retry/delayFunction.d.ts +3 -3
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retryFunction.d.ts +4 -4
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.d.ts +1 -2
- package/link/retry/retryLink.js +2 -2
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +2 -3
- package/link/schema/index.js.map +1 -1
- package/link/subscriptions/index.d.ts +1 -2
- package/link/subscriptions/index.js.map +1 -1
- package/link/utils/createOperation.d.ts +2 -2
- package/link/utils/createOperation.js +12 -4
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/index.d.ts +0 -2
- package/link/utils/index.js +0 -2
- package/link/utils/index.js.map +1 -1
- package/link/ws/index.d.ts +1 -2
- package/link/ws/index.js.map +1 -1
- package/local-state/LocalState.d.ts +94 -0
- package/local-state/LocalState.js +55 -9
- package/local-state/LocalState.js.map +1 -1
- package/masking/GraphQLCodegenDataMasking.d.ts +6 -7
- package/masking/GraphQLCodegenDataMasking.js.map +1 -1
- package/masking/internal/types.d.ts +70 -70
- package/masking/internal/types.js.map +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/types.js.map +1 -1
- package/masking/utils.js +3 -3
- package/package.json +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/useDeepMemo.js +0 -3
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.d.ts +2 -2
- package/react/hooks/internal/validateSuspenseHookOptions.js.map +1 -1
- package/react/hooks/internal/wrapHook.d.ts +8 -7
- package/react/hooks/internal/wrapHook.js +1 -0
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useApolloClient.d.ts +2 -2
- package/react/hooks/useApolloClient.js +2 -2
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +850 -90
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +54 -3
- package/react/hooks/useFragment.js +7 -0
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +317 -165
- package/react/hooks/useLazyQuery.js +0 -38
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +153 -175
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +87 -65
- package/react/hooks/useMutation.js +6 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +207 -103
- package/react/hooks/useQuery.js +1 -35
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +34 -5
- package/react/hooks/useQueryRefHandlers.js +2 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +2 -1
- package/react/hooks/useReactiveVar.js +2 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +93 -17
- package/react/hooks/useReadQuery.js +29 -0
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +108 -33
- package/react/hooks/useSubscription.js +8 -9
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +62 -30
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +471 -69
- package/react/hooks/useSuspenseQuery.js +4 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/internal/useDeepMemo.js +0 -3
- package/react/hooks-compiled/internal/useDeepMemo.js.map +1 -1
- package/react/hooks-compiled/internal/validateSuspenseHookOptions.d.ts +2 -2
- package/react/hooks-compiled/internal/validateSuspenseHookOptions.js.map +1 -1
- package/react/hooks-compiled/internal/wrapHook.d.ts +8 -7
- package/react/hooks-compiled/internal/wrapHook.js +1 -0
- package/react/hooks-compiled/internal/wrapHook.js.map +1 -1
- package/react/hooks-compiled/useApolloClient.d.ts +2 -2
- package/react/hooks-compiled/useApolloClient.js +2 -2
- package/react/hooks-compiled/useApolloClient.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +850 -90
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useFragment.d.ts +54 -3
- package/react/hooks-compiled/useFragment.js +7 -0
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +317 -165
- package/react/hooks-compiled/useLazyQuery.js +0 -38
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +153 -175
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +87 -65
- package/react/hooks-compiled/useMutation.js +6 -7
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +207 -103
- package/react/hooks-compiled/useQuery.js +1 -35
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.d.ts +34 -5
- package/react/hooks-compiled/useQueryRefHandlers.js +2 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useReactiveVar.d.ts +2 -1
- package/react/hooks-compiled/useReactiveVar.js +2 -1
- package/react/hooks-compiled/useReactiveVar.js.map +1 -1
- package/react/hooks-compiled/useReadQuery.d.ts +93 -17
- package/react/hooks-compiled/useReadQuery.js +29 -0
- package/react/hooks-compiled/useReadQuery.js.map +1 -1
- package/react/hooks-compiled/useSubscription.d.ts +108 -33
- package/react/hooks-compiled/useSubscription.js +8 -9
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseFragment.d.ts +62 -30
- package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +471 -69
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/index.compiled.d.ts +0 -1
- package/react/index.compiled.js +0 -1
- package/react/index.compiled.js.map +1 -1
- package/react/index.d.ts +0 -1
- package/react/index.js +0 -1
- package/react/index.js.map +1 -1
- package/react/index.react-server.d.ts +0 -1
- package/react/index.react-server.js +0 -2
- package/react/index.react-server.js.map +1 -1
- package/react/internal/cache/FragmentReference.d.ts +2 -3
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +14 -12
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +2 -2
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/cache/getSuspenseCache.d.ts +6 -4
- package/react/internal/cache/getSuspenseCache.js.map +1 -1
- package/react/internal/index.d.ts +1 -1
- package/react/internal/index.js +1 -0
- package/react/internal/index.js.map +1 -1
- package/react/internal/types.d.ts +3 -3
- package/react/internal/types.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +60 -51
- package/react/query-preloader/createQueryPreloader.js +1 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/prerenderStatic.d.ts +11 -9
- package/react/ssr/prerenderStatic.js +5 -4
- package/react/ssr/prerenderStatic.js.map +1 -1
- package/react/ssr/useSSRQuery.js.map +1 -1
- package/react/types/deprecated.d.ts +1 -1
- package/react/types/deprecated.js.map +1 -1
- package/react/types/types.documentation.d.ts +15 -15
- package/react/types/types.documentation.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +8 -8
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -4
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/types/deprecated.d.ts +3 -2
- package/testing/core/types/deprecated.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +2 -3
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/HKT.d.ts +8 -7
- package/utilities/HKT.js.map +1 -1
- package/utilities/caching/sizes.d.ts +4 -6
- package/utilities/caching/sizes.js +3 -3
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/index.d.ts +1 -2
- package/utilities/index.js +1 -2
- package/utilities/index.js.map +1 -1
- package/utilities/{shared → internal}/canonicalStringify.d.ts +1 -1
- package/utilities/{shared → internal}/canonicalStringify.js +4 -6
- package/utilities/internal/canonicalStringify.js.map +1 -0
- package/utilities/internal/checkDocument.js +1 -1
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/createFragmentMap.js.map +1 -1
- package/utilities/internal/equalByQuery.d.ts +5 -0
- package/{core → utilities/internal}/equalByQuery.js +7 -1
- package/utilities/internal/equalByQuery.js.map +1 -0
- package/utilities/internal/getFragmentQueryDocument.d.ts +13 -3
- package/utilities/internal/getFragmentQueryDocument.js +13 -3
- package/utilities/internal/getFragmentQueryDocument.js.map +1 -1
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/getStoreKeyName.js +1 -2
- package/utilities/internal/getStoreKeyName.js.map +1 -1
- package/utilities/internal/index.d.ts +2 -0
- package/utilities/internal/index.js +2 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/mergeOptions.d.ts +2 -2
- package/utilities/internal/mergeOptions.js.map +1 -1
- package/utilities/internal/toQueryResult.d.ts +2 -2
- package/utilities/internal/toQueryResult.js.map +1 -1
- package/utilities/internal/types/DocumentationTypes.d.ts +32 -26
- package/utilities/internal/types/DocumentationTypes.js.map +1 -1
- package/utilities/internal/types/NoInfer.d.ts +31 -25
- package/utilities/internal/types/NoInfer.js.map +1 -1
- package/utilities/internal/types/VariablesOption.d.ts +2 -6
- package/utilities/subscriptions/relay/index.js +2 -0
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/cache/core/types/DataProxy.cjs.map +0 -1
- package/__cjs/cache/core/types/DataProxy.d.cts +0 -140
- package/__cjs/core/equalByQuery.cjs.map +0 -1
- package/__cjs/core/equalByQuery.d.cts +0 -4
- package/__cjs/link/utils/transformOperation.cjs +0 -22
- package/__cjs/link/utils/transformOperation.cjs.map +0 -1
- package/__cjs/link/utils/transformOperation.d.cts +0 -3
- package/__cjs/link/utils/validateOperation.cjs +0 -21
- package/__cjs/link/utils/validateOperation.cjs.map +0 -1
- package/__cjs/link/utils/validateOperation.d.cts +0 -3
- package/__cjs/react/context/ApolloConsumer.cjs +0 -16
- package/__cjs/react/context/ApolloConsumer.cjs.map +0 -1
- package/__cjs/react/context/ApolloConsumer.d.cts +0 -10
- package/__cjs/utilities/shared/canonicalStringify.cjs.map +0 -1
- package/cache/core/types/DataProxy.d.ts +0 -140
- package/cache/core/types/DataProxy.js +0 -2
- package/cache/core/types/DataProxy.js.map +0 -1
- package/core/equalByQuery.d.ts +0 -4
- package/core/equalByQuery.js.map +0 -1
- package/link/utils/transformOperation.d.ts +0 -3
- package/link/utils/transformOperation.js +0 -19
- package/link/utils/transformOperation.js.map +0 -1
- package/link/utils/validateOperation.d.ts +0 -3
- package/link/utils/validateOperation.js +0 -18
- package/link/utils/validateOperation.js.map +0 -1
- package/react/context/ApolloConsumer.d.ts +0 -10
- package/react/context/ApolloConsumer.js +0 -11
- package/react/context/ApolloConsumer.js.map +0 -1
- package/utilities/shared/canonicalStringify.js.map +0 -1
|
@@ -93,7 +93,10 @@ function useSuspenseQuery_(query, options) {
|
|
|
93
93
|
export function useWatchQueryOptions({ client, query, options, }) {
|
|
94
94
|
return useDeepMemo(() => {
|
|
95
95
|
if (options === skipToken) {
|
|
96
|
-
return {
|
|
96
|
+
return {
|
|
97
|
+
query,
|
|
98
|
+
fetchPolicy: "standby",
|
|
99
|
+
};
|
|
97
100
|
}
|
|
98
101
|
const fetchPolicy = options.fetchPolicy ||
|
|
99
102
|
client.defaultOptions.watchQuery?.fetchPolicy ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmB/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,OAA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AI;YACjB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,SAAS;YACT,OAAO;YACP,eAAe;SAKhB,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;AAC5D,CAAC;AAWD,MAAM,UAAU,oBAAoB,CAGlC,EACA,MAAM,EACN,KAAK,EACL,OAAO,GAC4C;IAInD,OAAO,WAAW,CAAuC,GAAG,EAAE;QAC5D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAGrC,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GACf,OAAO,CAAC,WAAW;YACnB,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,WAAW;YAC7C,aAAa,CAAC;QAEhB,MAAM,iBAAiB,GAAyC;YAC9D,GAAG,OAAO;YACV,WAAW;YACX,KAAK;YACL,2BAA2B,EAAE,KAAK;YAClC,eAAe,EAAE,KAAK,CAAC;SACxB,CAAC;QAEF,IAAI,OAAO,EAAE,CAAC;YACZ,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;QACjD,CAAC;QAED,0EAA0E;QAC1E,qEAAqE;QACrE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,iBAAiB,CAAC,WAAW,GAAG,SAAS,CAAC;QAC5C,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n ApolloQueryResult,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorLike,\n ErrorPolicy,\n GetDataState,\n MaybeMasked,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n WatchQueryOptions,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport { NetworkStatus } from \"@apollo/client\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type {\n CacheKey,\n FetchMoreFunction,\n QueryKey,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport { getSuspenseCache } from \"@apollo/client/react/internal\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { SkipToken } from \"./constants.js\";\nimport { skipToken } from \"./constants.js\";\nimport { __use, useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { validateSuspenseHookOptions } from \"./internal/validateSuspenseHookOptions.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useSuspenseQuery {\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export namespace Base {\n export interface Options<\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy_suspense:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: FetchPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#queryKey:member} */\n queryKey?: string | number | any[];\n\n /**\n * {@inheritDoc @apollo/client!QueryOptionsDocumentation#skip_deprecated:member}\n *\n * @example Recommended usage of `skipToken`:\n * ```ts\n * import { skipToken, useSuspenseQuery } from '@apollo/client';\n *\n * const { data } = useSuspenseQuery(query, id ? { variables: { id } } : skipToken);\n * ```\n */\n skip?: boolean;\n }\n }\n export type Options<\n TVariables extends OperationVariables = OperationVariables,\n > = Base.Options<TVariables> & VariablesOption<TVariables>;\n\n export namespace DocumentationTypes {\n export interface Options<\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options<TVariables> {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#variables:member} */\n variables?: TVariables;\n }\n }\n\n export namespace Base {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#error:member} */\n error: ErrorLike | undefined;\n\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#fetchMore:member} */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#networkStatus:member} */\n networkStatus: NetworkStatus;\n\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member} */\n refetch: RefetchFunction<TData, TVariables>;\n\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#subscribeToMore:member} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n }\n }\n export type Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = Base.Result<TData, TVariables> &\n GetDataState<MaybeMasked<TData>, TStates>;\n\n export namespace DocumentationTypes {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Result<TData, TVariables>,\n UtilityDocumentationTypes.DataState<TData> {}\n }\n}\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: true;\n errorPolicy: \"ignore\" | \"all\";\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n errorPolicy: \"ignore\" | \"all\";\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: true;\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"empty\" | \"streaming\" | \"partial\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: true;\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"partial\" | \"streaming\" | \"complete\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useSuspenseQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: true;\n })\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"empty\" | \"streaming\" | \"complete\" | \"partial\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: useSuspenseQuery.Options<NoInfer<TVariables>>]\n : [options: useSuspenseQuery.Options<NoInfer<TVariables>>]\n): useSuspenseQuery.Result<TData, TVariables, \"complete\" | \"streaming\">;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]\n : [options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"empty\" | \"streaming\" | \"complete\" | \"partial\"\n> {\n \"use no memo\";\n return wrapHook(\n \"useSuspenseQuery\",\n // eslint-disable-next-line react-compiler/react-compiler\n useSuspenseQuery_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(query, options ?? ({} as any));\n}\n\nfunction useSuspenseQuery_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | (SkipToken & Partial<useSuspenseQuery.Options<TVariables>>)\n | useSuspenseQuery.Options<TVariables>\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"partial\" | \"complete\" | \"streaming\" | \"empty\"\n> {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions<any, any>({\n client,\n query,\n options,\n });\n const { fetchPolicy, variables } = watchQueryOptions;\n const { queryKey = [] } = options;\n\n const cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery(watchQueryOptions)\n );\n\n let [current, setPromise] = React.useState<\n [QueryKey, Promise<ApolloQueryResult<any>>]\n >([queryRef.key, queryRef.promise]);\n\n // This saves us a re-execution of the render function when a variable changed.\n if (current[0] !== queryRef.key) {\n // eslint-disable-next-line react-compiler/react-compiler\n current[0] = queryRef.key;\n current[1] = queryRef.promise;\n }\n let promise = current[1];\n\n if (queryRef.didChangeOptions(watchQueryOptions)) {\n current[1] = promise = queryRef.applyOptions(watchQueryOptions);\n }\n\n React.useEffect(() => {\n const dispose = queryRef.retain();\n\n const removeListener = queryRef.listen((promise) => {\n setPromise([queryRef.key, promise]);\n });\n\n return () => {\n removeListener();\n dispose();\n };\n }, [queryRef]);\n\n const skipResult = React.useMemo<ApolloQueryResult<TData>>(() => {\n const error = queryRef.result.error;\n const complete = !!queryRef.result.data;\n\n return {\n loading: false,\n data: queryRef.result.data,\n dataState: queryRef.result.dataState,\n networkStatus: error ? NetworkStatus.error : NetworkStatus.ready,\n error,\n complete,\n partial: !complete,\n };\n }, [queryRef.result]);\n\n const result = fetchPolicy === \"standby\" ? skipResult : __use(promise);\n\n const fetchMore = React.useCallback<\n FetchMoreFunction<unknown, OperationVariables>\n >(\n (options) => {\n const promise = queryRef.fetchMore(options);\n setPromise([queryRef.key, queryRef.promise]);\n\n return promise;\n },\n [queryRef]\n ) as FetchMoreFunction<TData | undefined, TVariables>;\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n setPromise([queryRef.key, queryRef.promise]);\n\n return promise;\n },\n [queryRef]\n );\n\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n const subscribeToMore = queryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData | undefined, TVariables>;\n\n return React.useMemo<\n useSuspenseQuery.Result<TData, TVariables, DataState<TData>[\"dataState\"]>\n >(() => {\n return {\n client,\n data: result.data,\n dataState: result.dataState,\n error: result.error,\n networkStatus: result.networkStatus,\n fetchMore,\n refetch,\n subscribeToMore,\n } as useSuspenseQuery.Result<\n TData,\n TVariables,\n DataState<TData>[\"dataState\"]\n >;\n }, [client, fetchMore, refetch, result, subscribeToMore]);\n}\n\ninterface UseWatchQueryOptionsHookOptions<\n TData,\n TVariables extends OperationVariables,\n> {\n client: ApolloClient;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: SkipToken | useSuspenseQuery.Options<TVariables>;\n}\n\nexport function useWatchQueryOptions<\n TData,\n TVariables extends OperationVariables,\n>({\n client,\n query,\n options,\n}: UseWatchQueryOptionsHookOptions<TData, TVariables>): WatchQueryOptions<\n TVariables,\n TData\n> {\n return useDeepMemo<WatchQueryOptions<TVariables, TData>>(() => {\n if (options === skipToken) {\n return { query, fetchPolicy: \"standby\" } as WatchQueryOptions<\n TVariables,\n TData\n >;\n }\n\n const fetchPolicy =\n options.fetchPolicy ||\n client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\";\n\n const watchQueryOptions: WatchQueryOptions<TVariables, TData> = {\n ...options,\n fetchPolicy,\n query,\n notifyOnNetworkStatusChange: false,\n nextFetchPolicy: void 0,\n };\n\n if (__DEV__) {\n validateSuspenseHookOptions(watchQueryOptions);\n }\n\n // Assign the updated fetch policy after our validation since `standby` is\n // not a supported fetch policy on its own without the use of `skip`.\n if (options.skip) {\n watchQueryOptions.fetchPolicy = \"standby\";\n }\n\n return watchQueryOptions;\n }, [client, options, query]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAQ/D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,2CAA2C,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA2SvD,MAAM,UAAU,gBAAgB,CAI9B,KAA0D,EAC1D,OAAmE;IAMnE,aAAa,CAAC;IACd,OAAO,QAAQ,CACb,kBAAkB;IAClB,yDAAyD;IACzD,iBAAiB,EACjB,eAAe,CAAC,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAC1E,CAAC,KAAK,EAAE,OAAO,IAAK,EAAU,CAAC,CAAC;AACnC,CAAC;AAED,SAAS,iBAAiB,CAIxB,KAA0D,EAC1D,OAEwC;IAMxC,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,C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I,OAAO,EAAE,CAAC;YACZ,2BAA2B,CAAC,iBAAiB,CAAC,CAAC;QACjD,CAAC;QAED,0EAA0E;QAC1E,qEAAqE;QACrE,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,iBAAiB,CAAC,WAAW,GAAG,SAAS,CAAC;QAC5C,CAAC;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import * as React from \"react\";\n\nimport type {\n ApolloClient,\n DataState,\n DefaultContext,\n DocumentNode,\n ErrorLike,\n ErrorPolicy,\n GetDataState,\n MaybeMasked,\n ObservableQuery,\n OperationVariables,\n RefetchWritePolicy,\n TypedDocumentNode,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport type { SubscribeToMoreFunction } from \"@apollo/client\";\nimport { NetworkStatus } from \"@apollo/client\";\nimport { canonicalStringify } from \"@apollo/client/cache\";\nimport type {\n CacheKey,\n FetchMoreFunction,\n QueryKey,\n RefetchFunction,\n} from \"@apollo/client/react/internal\";\nimport { getSuspenseCache } from \"@apollo/client/react/internal\";\nimport { __DEV__ } from \"@apollo/client/utilities/environment\";\nimport type {\n DocumentationTypes as UtilityDocumentationTypes,\n NoInfer,\n VariablesOption,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { SkipToken } from \"./constants.js\";\nimport { skipToken } from \"./constants.js\";\nimport { __use, useDeepMemo, wrapHook } from \"./internal/index.js\";\nimport { validateSuspenseHookOptions } from \"./internal/validateSuspenseHookOptions.js\";\nimport { useApolloClient } from \"./useApolloClient.js\";\n\nexport declare namespace useSuspenseQuery {\n export type FetchPolicy = Extract<\n WatchQueryFetchPolicy,\n \"cache-first\" | \"network-only\" | \"no-cache\" | \"cache-and-network\"\n >;\n\n export namespace Base {\n export interface Options<\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client?: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#context:member} */\n context?: DefaultContext;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#errorPolicy:member} */\n errorPolicy?: ErrorPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#returnPartialData:member} */\n returnPartialData?: boolean;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#refetchWritePolicy_suspense:member} */\n refetchWritePolicy?: RefetchWritePolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#fetchPolicy:member} */\n fetchPolicy?: FetchPolicy;\n\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#queryKey:member} */\n queryKey?: string | number | any[];\n\n /**\n * {@inheritDoc @apollo/client!QueryOptionsDocumentation#skip_deprecated:member}\n *\n * @example Recommended usage of `skipToken`:\n *\n * ```ts\n * import { skipToken, useSuspenseQuery } from \"@apollo/client\";\n *\n * const { data } = useSuspenseQuery(\n * query,\n * id ? { variables: { id } } : skipToken\n * );\n * ```\n */\n skip?: boolean;\n }\n }\n export type Options<\n TVariables extends OperationVariables = OperationVariables,\n > = Base.Options<TVariables> & VariablesOption<TVariables>;\n\n export namespace DocumentationTypes {\n namespace useSuspenseQuery {\n export interface Options<\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Options<TVariables>,\n UtilityDocumentationTypes.VariableOptions<TVariables> {}\n }\n }\n\n export namespace Base {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > {\n /** {@inheritDoc @apollo/client!QueryOptionsDocumentation#client:member} */\n client: ApolloClient;\n\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#error:member} */\n error: ErrorLike | undefined;\n\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#fetchMore:member}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n fetchMore: FetchMoreFunction<TData, TVariables>;\n\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#networkStatus:member} */\n networkStatus: NetworkStatus;\n\n /**\n * {@inheritDoc @apollo/client!QueryResultDocumentation#refetch:member}\n *\n * @remarks\n * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).\n */\n refetch: RefetchFunction<TData, TVariables>;\n\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#subscribeToMore:member} */\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n }\n }\n export type Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n TStates extends\n DataState<TData>[\"dataState\"] = DataState<TData>[\"dataState\"],\n > = Base.Result<TData, TVariables> &\n GetDataState<MaybeMasked<TData>, TStates>;\n\n export namespace DocumentationTypes {\n namespace useSuspenseQuery {\n export interface Result<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n > extends Base.Result<TData, TVariables>,\n UtilityDocumentationTypes.DataState<TData> {}\n }\n }\n export namespace DocumentationTypes {\n /** Test {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\n export function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n >(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: useSuspenseQuery.Options<TVariables>\n ): useSuspenseQuery.Result<TData, TVariables>;\n }\n}\n\n/**\n * For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).\n *\n * @example\n *\n * ```jsx\n * import { Suspense } from \"react\";\n * import { useSuspenseQuery } from \"@apollo/client\";\n *\n * const listQuery = gql`\n * query {\n * list {\n * id\n * }\n * }\n * `;\n *\n * function App() {\n * return (\n * <Suspense fallback={<Spinner />}>\n * <List />\n * </Suspense>\n * );\n * }\n *\n * function List() {\n * const { data } = useSuspenseQuery(listQuery);\n *\n * return (\n * <ol>\n * {data.list.map((item) => (\n * <Item key={item.id} id={item.id} />\n * ))}\n * </ol>\n * );\n * }\n * ```\n *\n * @param query - A GraphQL query document parsed into an AST by `gql`.\n * @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.\n */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: true;\n errorPolicy: \"ignore\" | \"all\";\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"partial\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n errorPolicy: \"ignore\" | \"all\";\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: true;\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"empty\" | \"streaming\" | \"partial\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: true;\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"partial\" | \"streaming\" | \"complete\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: useSuspenseQuery.Options<NoInfer<TVariables>> & {\n skip: boolean;\n }\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | SkipToken\n | (useSuspenseQuery.Options<NoInfer<TVariables>> & {\n returnPartialData: true;\n })\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"empty\" | \"streaming\" | \"complete\" | \"partial\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: useSuspenseQuery.Options<NoInfer<TVariables>>]\n : [options: useSuspenseQuery.Options<NoInfer<TVariables>>]\n): useSuspenseQuery.Result<TData, TVariables, \"complete\" | \"streaming\">;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n ...[options]: {} extends TVariables ?\n [options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]\n : [options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\n/** {@inheritDoc @apollo/client/react!useSuspenseQuery:function(1)} */\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"complete\" | \"streaming\" | \"empty\"\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"empty\" | \"streaming\" | \"complete\" | \"partial\"\n> {\n \"use no memo\";\n return wrapHook(\n \"useSuspenseQuery\",\n // eslint-disable-next-line react-compiler/react-compiler\n useSuspenseQuery_,\n useApolloClient(typeof options === \"object\" ? options.client : undefined)\n )(query, options ?? ({} as any));\n}\n\nfunction useSuspenseQuery_<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables,\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options:\n | (SkipToken & Partial<useSuspenseQuery.Options<TVariables>>)\n | useSuspenseQuery.Options<TVariables>\n): useSuspenseQuery.Result<\n TData,\n TVariables,\n \"partial\" | \"complete\" | \"streaming\" | \"empty\"\n> {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions<any, any>({\n client,\n query,\n options,\n });\n const { fetchPolicy, variables } = watchQueryOptions;\n const { queryKey = [] } = options;\n\n const cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery(watchQueryOptions)\n );\n\n let [current, setPromise] = React.useState<\n [QueryKey, Promise<ObservableQuery.Result<any>>]\n >([queryRef.key, queryRef.promise]);\n\n // This saves us a re-execution of the render function when a variable changed.\n if (current[0] !== queryRef.key) {\n // eslint-disable-next-line react-compiler/react-compiler\n current[0] = queryRef.key;\n current[1] = queryRef.promise;\n }\n let promise = current[1];\n\n if (queryRef.didChangeOptions(watchQueryOptions)) {\n current[1] = promise = queryRef.applyOptions(watchQueryOptions);\n }\n\n React.useEffect(() => {\n const dispose = queryRef.retain();\n\n const removeListener = queryRef.listen((promise) => {\n setPromise([queryRef.key, promise]);\n });\n\n return () => {\n removeListener();\n dispose();\n };\n }, [queryRef]);\n\n const skipResult = React.useMemo<ObservableQuery.Result<TData>>(() => {\n const error = queryRef.result.error;\n const complete = !!queryRef.result.data;\n\n return {\n loading: false,\n data: queryRef.result.data,\n dataState: queryRef.result.dataState,\n networkStatus: error ? NetworkStatus.error : NetworkStatus.ready,\n error,\n complete,\n partial: !complete,\n };\n }, [queryRef.result]);\n\n const result = fetchPolicy === \"standby\" ? skipResult : __use(promise);\n\n const fetchMore = React.useCallback<\n FetchMoreFunction<unknown, OperationVariables>\n >(\n (options) => {\n const promise = queryRef.fetchMore(options);\n setPromise([queryRef.key, queryRef.promise]);\n\n return promise;\n },\n [queryRef]\n ) as FetchMoreFunction<TData | undefined, TVariables>;\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n setPromise([queryRef.key, queryRef.promise]);\n\n return promise;\n },\n [queryRef]\n );\n\n // TODO: The internalQueryRef doesn't have TVariables' type information so we have to cast it here\n const subscribeToMore = queryRef.observable\n .subscribeToMore as SubscribeToMoreFunction<TData | undefined, TVariables>;\n\n return React.useMemo<\n useSuspenseQuery.Result<TData, TVariables, DataState<TData>[\"dataState\"]>\n >(() => {\n return {\n client,\n data: result.data,\n dataState: result.dataState,\n error: result.error,\n networkStatus: result.networkStatus,\n fetchMore,\n refetch,\n subscribeToMore,\n } as useSuspenseQuery.Result<\n TData,\n TVariables,\n DataState<TData>[\"dataState\"]\n >;\n }, [client, fetchMore, refetch, result, subscribeToMore]);\n}\n\ninterface UseWatchQueryOptionsHookOptions<\n TData,\n TVariables extends OperationVariables,\n> {\n client: ApolloClient;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: SkipToken | useSuspenseQuery.Options<TVariables>;\n}\n\nexport function useWatchQueryOptions<\n TData,\n TVariables extends OperationVariables,\n>({\n client,\n query,\n options,\n}: UseWatchQueryOptionsHookOptions<\n TData,\n TVariables\n>): ApolloClient.WatchQueryOptions<TData, TVariables> {\n return useDeepMemo<ApolloClient.WatchQueryOptions<TData, TVariables>>(() => {\n if (options === skipToken) {\n return {\n query,\n fetchPolicy: \"standby\",\n } as ApolloClient.WatchQueryOptions<TData, TVariables>;\n }\n\n const fetchPolicy =\n options.fetchPolicy ||\n client.defaultOptions.watchQuery?.fetchPolicy ||\n \"cache-first\";\n\n const watchQueryOptions: ApolloClient.WatchQueryOptions<TData, TVariables> =\n {\n ...options,\n fetchPolicy,\n query,\n notifyOnNetworkStatusChange: false,\n nextFetchPolicy: void 0,\n };\n\n if (__DEV__) {\n validateSuspenseHookOptions(watchQueryOptions);\n }\n\n // Assign the updated fetch policy after our validation since `standby` is\n // not a supported fetch policy on its own without the use of `skip`.\n if (options.skip) {\n watchQueryOptions.fetchPolicy = \"standby\";\n }\n\n return watchQueryOptions;\n }, [client, options, query]);\n}\n"]}
|
|
@@ -2,12 +2,9 @@ import { equal } from "@wry/equality";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
export function useDeepMemo(memoFn, deps) {
|
|
4
4
|
const ref = React.useRef(void 0);
|
|
5
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
6
5
|
if (!ref.current || !equal(ref.current.deps, deps)) {
|
|
7
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
8
6
|
ref.current = { value: memoFn(), deps };
|
|
9
7
|
}
|
|
10
|
-
// eslint-disable-next-line react-compiler/react-compiler
|
|
11
8
|
return ref.current.value;
|
|
12
9
|
}
|
|
13
10
|
//# sourceMappingURL=useDeepMemo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,UAAU,WAAW,CACzB,MAAoB,EACpB,IAAoB;IAEpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAA0C,KAAK,CAAC,CAAC,CAAC;IAC1E,
|
|
1
|
+
{"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,UAAU,WAAW,CACzB,MAAoB,EACpB,IAAoB;IAEpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAA0C,KAAK,CAAC,CAAC,CAAC;IAC1E,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,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC;AAC3B,CAAC","sourcesContent":["import { equal } from \"@wry/equality\";\nimport type { DependencyList } from \"react\";\nimport * as React from \"react\";\n\nexport function useDeepMemo<TValue>(\n memoFn: () => TValue,\n deps: DependencyList\n) {\n const ref = React.useRef<{ deps: DependencyList; value: TValue }>(void 0);\n if (!ref.current || !equal(ref.current.deps, deps)) {\n ref.current = { value: memoFn(), deps };\n }\n return ref.current.value;\n}\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function validateSuspenseHookOptions<TData, TVariables extends OperationVariables>(options: WatchQueryOptions<
|
|
1
|
+
import type { ApolloClient, OperationVariables } from "@apollo/client";
|
|
2
|
+
export declare function validateSuspenseHookOptions<TData, TVariables extends OperationVariables>(options: ApolloClient.WatchQueryOptions<TData, TVariables>): void;
|
|
3
3
|
//# sourceMappingURL=validateSuspenseHookOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateSuspenseHookOptions.js","sources":["../../../../src/react/hooks/internal/validateSuspenseHookOptions.ts"],"sourcesContent":["import type {\n
|
|
1
|
+
{"version":3,"file":"validateSuspenseHookOptions.js","sources":["../../../../src/react/hooks/internal/validateSuspenseHookOptions.ts"],"sourcesContent":["import type {\n ApolloClient,\n OperationVariables,\n WatchQueryFetchPolicy,\n} from \"@apollo/client\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nexport function validateSuspenseHookOptions<\n TData,\n TVariables extends OperationVariables,\n>(options: ApolloClient.WatchQueryOptions<TData, TVariables>) {\n const { fetchPolicy, returnPartialData } = options;\n\n validateFetchPolicy(fetchPolicy);\n validatePartialDataReturn(fetchPolicy, returnPartialData);\n}\n\nfunction validateFetchPolicy(\n fetchPolicy: WatchQueryFetchPolicy = \"cache-first\"\n) {\n const supportedFetchPolicies: WatchQueryFetchPolicy[] = [\n \"cache-first\",\n \"network-only\",\n \"no-cache\",\n \"cache-and-network\",\n ];\n\n invariant(\n supportedFetchPolicies.includes(fetchPolicy),\n `The fetch policy \\`%s\\` is not supported with suspense.`,\n fetchPolicy\n );\n}\n\nfunction validatePartialDataReturn(\n fetchPolicy: WatchQueryFetchPolicy | undefined,\n returnPartialData: boolean | undefined\n) {\n if (fetchPolicy === \"no-cache\" && returnPartialData) {\n invariant.warn(\n \"Using `returnPartialData` with a `no-cache` fetch policy has no effect. To read partial data from the cache, consider using an alternate fetch policy.\"\n );\n }\n}\n"],"names":[],"mappings":";AAKA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,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A,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAC0B,CAAC,CAD3B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACmC,CAAC,CADpC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAC+C,OAE3C,CAHJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAIG;AACH;AAEA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAS,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAkC,CAChC,CADF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACgD,EAC9C,CAFF,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAEwC,EAFxC;IAIE,CAAF,EAAA,CAAM,CAAN,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAsB,CAAtB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAoC,CAApC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqD,EAAE;mBACnD,CAAJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAC,CAAd,CAAA,CAAA,KAEK;IACH;AACF;"}
|
|
@@ -5,14 +5,14 @@ import type { useBackgroundQuery, useFragment, useQuery, useQueryRefHandlers, us
|
|
|
5
5
|
export declare const wrapperSymbol: unique symbol;
|
|
6
6
|
type FunctionSignature<T> = T extends (...args: infer A) => infer R ? (...args: A) => R : never;
|
|
7
7
|
interface WrappableHooks {
|
|
8
|
-
createQueryPreloader: typeof createQueryPreloader
|
|
8
|
+
createQueryPreloader: FunctionSignature<typeof createQueryPreloader>;
|
|
9
9
|
useQuery: FunctionSignature<typeof useQuery>;
|
|
10
|
-
useSuspenseQuery: typeof useSuspenseQuery
|
|
11
|
-
useSuspenseFragment: typeof useSuspenseFragment
|
|
12
|
-
useBackgroundQuery: typeof useBackgroundQuery
|
|
13
|
-
useReadQuery: typeof useReadQuery
|
|
14
|
-
useFragment: typeof useFragment
|
|
15
|
-
useQueryRefHandlers: typeof useQueryRefHandlers
|
|
10
|
+
useSuspenseQuery: FunctionSignature<typeof useSuspenseQuery>;
|
|
11
|
+
useSuspenseFragment: FunctionSignature<typeof useSuspenseFragment>;
|
|
12
|
+
useBackgroundQuery: FunctionSignature<typeof useBackgroundQuery>;
|
|
13
|
+
useReadQuery: FunctionSignature<typeof useReadQuery>;
|
|
14
|
+
useFragment: FunctionSignature<typeof useFragment>;
|
|
15
|
+
useQueryRefHandlers: FunctionSignature<typeof useQueryRefHandlers>;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* @internal
|
|
@@ -31,6 +31,7 @@ export type HookWrappers = {
|
|
|
31
31
|
* That means that the Apollo Client instance can expose a "wrapper" that will be
|
|
32
32
|
* used to wrap the original hook implementation with additional logic.
|
|
33
33
|
* @example
|
|
34
|
+
*
|
|
34
35
|
* ```tsx
|
|
35
36
|
* // this is already done in `@apollo/client` for all wrappable hooks (see `WrappableHooks`)
|
|
36
37
|
* // following this pattern
|
|
@@ -9,6 +9,7 @@ export const wrapperSymbol = Symbol.for("apollo.hook.wrappers");
|
|
|
9
9
|
* That means that the Apollo Client instance can expose a "wrapper" that will be
|
|
10
10
|
* used to wrap the original hook implementation with additional logic.
|
|
11
11
|
* @example
|
|
12
|
+
*
|
|
12
13
|
* ```tsx
|
|
13
14
|
* // this is already done in `@apollo/client` for all wrappable hooks (see `WrappableHooks`)
|
|
14
15
|
* // following this pattern
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapHook.js","sources":["../../../../src/react/hooks/internal/wrapHook.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type { ApolloClient } from \"@apollo/client\";\nimport type { ObservableQuery } from \"@apollo/client\";\nimport type { createQueryPreloader } from \"@apollo/client/react\";\nimport type {\n useBackgroundQuery,\n useFragment,\n useQuery,\n useQueryRefHandlers,\n useReadQuery,\n useSuspenseFragment,\n useSuspenseQuery,\n} from \"@apollo/client/react\";\n\
|
|
1
|
+
{"version":3,"file":"wrapHook.js","sources":["../../../../src/react/hooks/internal/wrapHook.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type { ApolloClient, InternalTypes } from \"@apollo/client\";\nimport type { ObservableQuery } from \"@apollo/client\";\nimport type { createQueryPreloader } from \"@apollo/client/react\";\nimport type {\n useBackgroundQuery,\n useFragment,\n useQuery,\n useQueryRefHandlers,\n useReadQuery,\n useSuspenseFragment,\n useSuspenseQuery,\n} from \"@apollo/client/react\";\n\n// direct import to avoid circular dependency\nimport { getApolloContext } from \"../../context/ApolloContext.js\";\n\nexport const wrapperSymbol = Symbol.for(\"apollo.hook.wrappers\");\n\ntype FunctionSignature<T> =\n T extends (...args: infer A) => infer R ? (...args: A) => R : never;\n\ninterface WrappableHooks {\n createQueryPreloader: FunctionSignature<typeof createQueryPreloader>;\n useQuery: FunctionSignature<typeof useQuery>;\n useSuspenseQuery: FunctionSignature<typeof useSuspenseQuery>;\n useSuspenseFragment: FunctionSignature<typeof useSuspenseFragment>;\n useBackgroundQuery: FunctionSignature<typeof useBackgroundQuery>;\n useReadQuery: FunctionSignature<typeof useReadQuery>;\n useFragment: FunctionSignature<typeof useFragment>;\n useQueryRefHandlers: FunctionSignature<typeof useQueryRefHandlers>;\n}\n\n/**\n * @internal\n * Can be used to correctly type the [Symbol.for(\"apollo.hook.wrappers\")] property of\n * `QueryManager`, to override/wrap hook functionality.\n */\nexport type HookWrappers = {\n [K in keyof WrappableHooks]?: (\n originalHook: WrappableHooks[K]\n ) => WrappableHooks[K];\n};\n\ninterface QueryManagerWithWrappers extends InternalTypes.QueryManager {\n [wrapperSymbol]?: HookWrappers;\n}\n\n/**\n * @internal\n *\n * Makes an Apollo Client hook \"wrappable\".\n * That means that the Apollo Client instance can expose a \"wrapper\" that will be\n * used to wrap the original hook implementation with additional logic.\n * @example\n *\n * ```tsx\n * // this is already done in `@apollo/client` for all wrappable hooks (see `WrappableHooks`)\n * // following this pattern\n * function useQuery() {\n * return wrapHook('useQuery', _useQuery, options.client)(query, options);\n * }\n * function _useQuery(query, options) {\n * // original implementation\n * }\n *\n * // this is what a library like `@apollo/client-react-streaming` would do\n * class ApolloClientWithStreaming extends ApolloClient {\n * constructor(options) {\n * super(options);\n * this.queryManager[Symbol.for(\"apollo.hook.wrappers\")] = {\n * useQuery: (original) => (query, options) => {\n * console.log(\"useQuery was called with options\", options);\n * return original(query, options);\n * }\n * }\n * }\n * }\n *\n * // this will now log the options and then call the original `useQuery`\n * const client = new ApolloClientWithStreaming({ ... });\n * useQuery(query, { client });\n * ```\n */\nexport function wrapHook<Hook extends (...args: any[]) => any>(\n hookName: keyof WrappableHooks,\n useHook: Hook,\n clientOrObsQuery: ObservableQuery<any> | ApolloClient\n): Hook {\n // Priority-wise, the later entries in this array wrap\n // previous entries and could prevent them (and in the end,\n // even the original hook) from running\n const wrapperSources = [\n (\n clientOrObsQuery as unknown as {\n // both `ApolloClient` and `ObservableQuery` have a `queryManager` property\n // but they're both `private`, so we have to cast around for a bit here.\n queryManager: QueryManagerWithWrappers;\n }\n )[\"queryManager\"],\n // if we are a hook (not `preloadQuery`), we are guaranteed to be inside of\n // a React render and can use context\n hookName.startsWith(\"use\") ?\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useContext(getApolloContext())\n : undefined,\n ];\n\n let wrapped = useHook;\n for (const source of wrapperSources) {\n const wrapper = source?.[wrapperSymbol]?.[hookName];\n if (wrapper) {\n wrapped = wrapper(wrap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A,CAAA,CAAA,CAAA,CAAA,CAAgB;AAChB;"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ApolloClient } from "@apollo/client";
|
|
2
2
|
/**
|
|
3
3
|
* @example
|
|
4
|
+
*
|
|
4
5
|
* ```jsx
|
|
5
|
-
* import { useApolloClient } from
|
|
6
|
+
* import { useApolloClient } from "@apollo/client";
|
|
6
7
|
*
|
|
7
8
|
* function SomeComponent() {
|
|
8
9
|
* const client = useApolloClient();
|
|
@@ -11,7 +12,6 @@ import type { ApolloClient } from "@apollo/client";
|
|
|
11
12
|
* }
|
|
12
13
|
* ```
|
|
13
14
|
*
|
|
14
|
-
* @since 3.0.0
|
|
15
15
|
* @returns The `ApolloClient` instance being used by the application.
|
|
16
16
|
*/
|
|
17
17
|
export declare function useApolloClient(override?: ApolloClient): ApolloClient;
|
|
@@ -4,8 +4,9 @@ import { invariant } from "@apollo/client/utilities/invariant";
|
|
|
4
4
|
import { getApolloContext } from "../context/ApolloContext.js";
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
|
+
*
|
|
7
8
|
* ```jsx
|
|
8
|
-
* import { useApolloClient } from
|
|
9
|
+
* import { useApolloClient } from "@apollo/client";
|
|
9
10
|
*
|
|
10
11
|
* function SomeComponent() {
|
|
11
12
|
* const client = useApolloClient();
|
|
@@ -14,7 +15,6 @@ import { getApolloContext } from "../context/ApolloContext.js";
|
|
|
14
15
|
* }
|
|
15
16
|
* ```
|
|
16
17
|
*
|
|
17
|
-
* @since 3.0.0
|
|
18
18
|
* @returns The `ApolloClient` instance being used by the application.
|
|
19
19
|
*/
|
|
20
20
|
export function useApolloClient(override) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApolloClient.js","sources":["../../../src/react/hooks/useApolloClient.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type { ApolloClient } from \"@apollo/client\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nimport { getApolloContext } from \"../context/ApolloContext.js\";\n\n/**\n * @example\n * ```jsx\n * import { useApolloClient } from
|
|
1
|
+
{"version":3,"file":"useApolloClient.js","sources":["../../../src/react/hooks/useApolloClient.ts"],"sourcesContent":["import * as React from \"react\";\n\nimport type { ApolloClient } from \"@apollo/client\";\nimport { invariant } from \"@apollo/client/utilities/invariant\";\n\nimport { getApolloContext } from \"../context/ApolloContext.js\";\n\n/**\n * @example\n *\n * ```jsx\n * import { useApolloClient } from \"@apollo/client\";\n *\n * function SomeComponent() {\n * const client = useApolloClient();\n * // `client` is now set to the `ApolloClient` instance being used by the\n * // application (that was configured using something like `ApolloProvider`)\n * }\n * ```\n *\n * @returns The `ApolloClient` instance being used by the application.\n */\nexport function useApolloClient(override?: ApolloClient): ApolloClient {\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"],"names":[],"mappings":";AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAP,CAAA,EAAY,CAAZ,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,EAAuB,CAAvB,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8B;AAG9B,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAA0B,CAA1B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8D;AAE9D,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,EAAE,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,EAAiC,CAAjC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8D;AAE9D,CAAA,CAAA;;;;;;;;;;;;;;CAcA,CAAA;;;;;;;;;;;;;;;;;"}
|