@apollo/client 4.0.0-rc.4 → 4.0.0-rc.6
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 +63 -0
- package/README.md +40 -40
- package/__cjs/cache/core/cache.cjs +4 -12
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +96 -66
- 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 +28 -31
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +18 -17
- package/__cjs/cache/inmemory/inMemoryCache.cjs +1 -1
- 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/types.d.cts +1 -1
- 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 +137 -117
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +790 -183
- package/__cjs/core/ObservableQuery.cjs +50 -20
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +184 -68
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +5 -4
- package/__cjs/core/QueryManager.cjs +15 -13
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +17 -17
- 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 +9 -5
- package/__cjs/core/types.d.cts +81 -104
- 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 +59 -11
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +146 -11
- package/__cjs/errors/CombinedProtocolErrors.cjs +48 -1
- package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedProtocolErrors.d.cts +126 -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 +50 -8
- package/__cjs/errors/ServerError.cjs.map +1 -1
- package/__cjs/errors/ServerError.d.cts +70 -11
- package/__cjs/errors/ServerParseError.cjs +45 -8
- package/__cjs/errors/ServerParseError.cjs.map +1 -1
- package/__cjs/errors/ServerParseError.d.cts +71 -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/notImplemented.cjs +1 -1
- package/__cjs/invariantErrorCodes.cjs +72 -80
- package/__cjs/link/batch/batchLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.cjs +2 -2
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- 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 +1 -1
- package/__cjs/link/core/ApolloLink.cjs +2 -2
- package/__cjs/link/core/types.d.cts +2 -2
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +16 -1
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +13 -2
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -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 -11
- package/__cjs/link/retry/delayFunction.cjs.map +1 -1
- package/__cjs/link/retry/delayFunction.d.cts +1 -1
- package/__cjs/link/retry/retryFunction.cjs.map +1 -1
- package/__cjs/link/retry/retryFunction.d.cts +1 -1
- package/__cjs/link/retry/retryLink.cjs.map +1 -1
- package/__cjs/link/schema/index.cjs.map +1 -1
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/link/ws/index.cjs.map +1 -1
- 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 +814 -82
- package/__cjs/react/hooks/useFragment.cjs +11 -9
- 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 +313 -119
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +230 -44
- package/__cjs/react/hooks/useMutation.cjs +6 -7
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +57 -17
- package/__cjs/react/hooks/useQuery.cjs +1 -35
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +407 -238
- package/__cjs/react/hooks/useQueryRefHandlers.cjs +2 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +25 -1
- 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 +95 -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 +153 -69
- 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 +605 -160
- package/__cjs/react/index.cjs +1 -5
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +0 -2
- 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 +1 -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 +11 -11
- 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 +31 -31
- 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 +22 -11
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +3 -2
- 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 +9 -7
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
- package/__cjs/utilities/internal/index.cjs +8 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +4 -0
- package/__cjs/utilities/internal/mergeOptions.cjs.map +1 -1
- package/__cjs/utilities/internal/mergeOptions.d.cts +2 -2
- package/__cjs/utilities/internal/removeFragmentSpreads.cjs +14 -0
- package/__cjs/utilities/internal/removeFragmentSpreads.cjs.map +1 -0
- package/__cjs/utilities/internal/removeFragmentSpreads.d.cts +3 -0
- package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -1
- package/__cjs/utilities/internal/toQueryResult.d.cts +2 -2
- package/__cjs/utilities/internal/types/DocumentationTypes.cjs +3 -0
- package/__cjs/utilities/internal/types/DocumentationTypes.cjs.map +1 -0
- package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +96 -0
- package/__cjs/utilities/internal/types/NoInfer.d.cts +31 -25
- 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 +96 -66
- package/cache/core/cache.js +5 -13
- 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 +18 -17
- package/cache/inmemory/entityStore.js +28 -31
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +4 -4
- package/cache/inmemory/inMemoryCache.js +1 -1
- 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/types.d.ts +1 -1
- package/cache/inmemory/types.js.map +1 -1
- 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 +790 -183
- package/core/ApolloClient.js +138 -118
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +184 -68
- package/core/ObservableQuery.js +50 -20
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +5 -4
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +17 -17
- package/core/QueryManager.js +15 -13
- 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 +9 -5
- package/core/index.js.map +1 -1
- package/core/types.d.ts +81 -104
- 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 +147 -12
- package/errors/CombinedGraphQLErrors.js +60 -12
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/CombinedProtocolErrors.d.ts +127 -3
- package/errors/CombinedProtocolErrors.js +49 -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 +71 -12
- package/errors/ServerError.js +51 -9
- package/errors/ServerError.js.map +1 -1
- package/errors/ServerParseError.d.ts +72 -17
- package/errors/ServerParseError.js +46 -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/notImplemented.js +1 -1
- package/invariantErrorCodes.js +72 -80
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch-http/batchHttpLink.js +1 -1
- 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 +1 -1
- package/link/context/index.js +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.js +2 -2
- package/link/core/types.d.ts +2 -2
- package/link/core/types.js.map +1 -1
- package/link/error/index.d.ts +16 -1
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +13 -2
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.d.ts +11 -11
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/index.js.map +1 -1
- package/link/retry/delayFunction.d.ts +1 -1
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retryFunction.d.ts +1 -1
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- 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 +814 -82
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +54 -3
- package/react/hooks/useFragment.js +11 -9
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +313 -119
- package/react/hooks/useLazyQuery.js +0 -38
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +230 -44
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +57 -17
- package/react/hooks/useMutation.js +6 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +407 -238
- package/react/hooks/useQuery.js +1 -35
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +25 -1
- 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 +96 -17
- package/react/hooks/useReadQuery.js +29 -0
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +153 -69
- 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 +605 -160
- 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 +814 -82
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useFragment.d.ts +54 -3
- package/react/hooks-compiled/useFragment.js +11 -9
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +313 -119
- package/react/hooks-compiled/useLazyQuery.js +0 -38
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +230 -44
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +57 -17
- package/react/hooks-compiled/useMutation.js +6 -7
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +407 -238
- package/react/hooks-compiled/useQuery.js +1 -35
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.d.ts +25 -1
- 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 +96 -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 +153 -69
- 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 +605 -160
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/index.compiled.d.ts +0 -2
- package/react/index.compiled.js +0 -2
- package/react/index.compiled.js.map +1 -1
- package/react/index.d.ts +0 -2
- package/react/index.js +0 -2
- 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 +1 -1
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +11 -11
- 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 +31 -31
- 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 +22 -11
- package/react/types/types.documentation.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +3 -2
- package/testing/core/mocking/mockLink.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 +9 -7
- package/utilities/internal/getStoreKeyName.js.map +1 -1
- package/utilities/internal/index.d.ts +4 -0
- package/utilities/internal/index.js +3 -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/removeFragmentSpreads.d.ts +3 -0
- package/utilities/internal/removeFragmentSpreads.js +11 -0
- package/utilities/internal/removeFragmentSpreads.js.map +1 -0
- package/utilities/internal/toQueryResult.d.ts +2 -2
- package/utilities/internal/toQueryResult.js.map +1 -1
- package/utilities/internal/types/DocumentationTypes.d.ts +96 -0
- package/utilities/internal/types/DocumentationTypes.js +2 -0
- package/utilities/internal/types/DocumentationTypes.js.map +1 -0
- package/utilities/internal/types/NoInfer.d.ts +31 -25
- package/utilities/internal/types/NoInfer.js.map +1 -1
- 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/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/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
|
@@ -1,123 +1,285 @@
|
|
|
1
1
|
import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, OperationVariables, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
|
|
2
2
|
import type { SubscribeToMoreFunction } from "@apollo/client";
|
|
3
3
|
import type { FetchMoreFunction, QueryRef, RefetchFunction } from "@apollo/client/react/internal";
|
|
4
|
-
import type { NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
|
|
4
|
+
import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
|
|
5
5
|
import type { SkipToken } from "./constants.js";
|
|
6
6
|
export declare namespace useBackgroundQuery {
|
|
7
|
+
import _self = useBackgroundQuery;
|
|
7
8
|
type FetchPolicy = Extract<WatchQueryFetchPolicy, "cache-first" | "network-only" | "no-cache" | "cache-and-network">;
|
|
8
|
-
|
|
9
|
+
namespace Base {
|
|
10
|
+
interface Options {
|
|
11
|
+
/**
|
|
12
|
+
* The instance of `ApolloClient` to use to execute the query.
|
|
13
|
+
*
|
|
14
|
+
* By default, the instance that's passed down via context is used, but you can provide a different instance here.
|
|
15
|
+
*
|
|
16
|
+
* @docGroup
|
|
17
|
+
*
|
|
18
|
+
* 1. Operation options
|
|
19
|
+
*/
|
|
20
|
+
client?: ApolloClient;
|
|
21
|
+
/**
|
|
22
|
+
* Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: "overwrite" in their WatchQueryOptions.
|
|
23
|
+
*
|
|
24
|
+
* The default value is "overwrite".
|
|
25
|
+
*
|
|
26
|
+
* @docGroup
|
|
27
|
+
*
|
|
28
|
+
* 3. Caching options
|
|
29
|
+
*/
|
|
30
|
+
refetchWritePolicy?: RefetchWritePolicy;
|
|
31
|
+
/**
|
|
32
|
+
* Specifies how the query handles a response that returns both GraphQL errors and partial results.
|
|
33
|
+
*
|
|
34
|
+
* For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
|
|
35
|
+
*
|
|
36
|
+
* The default value is `none`, meaning that the query result includes error details but not partial results.
|
|
37
|
+
*
|
|
38
|
+
* @docGroup
|
|
39
|
+
*
|
|
40
|
+
* 1. Operation options
|
|
41
|
+
*/
|
|
42
|
+
errorPolicy?: ErrorPolicy;
|
|
43
|
+
/**
|
|
44
|
+
* If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.
|
|
45
|
+
*
|
|
46
|
+
* @docGroup
|
|
47
|
+
*
|
|
48
|
+
* 2. Networking options
|
|
49
|
+
*/
|
|
50
|
+
context?: DefaultContext;
|
|
51
|
+
/**
|
|
52
|
+
* If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.
|
|
53
|
+
*
|
|
54
|
+
* The default value is `false`.
|
|
55
|
+
*
|
|
56
|
+
* @docGroup
|
|
57
|
+
*
|
|
58
|
+
* 3. Caching options
|
|
59
|
+
*/
|
|
60
|
+
returnPartialData?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).
|
|
63
|
+
*
|
|
64
|
+
* For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).
|
|
65
|
+
*
|
|
66
|
+
* The default value is `cache-first`.
|
|
67
|
+
*
|
|
68
|
+
* @docGroup
|
|
69
|
+
*
|
|
70
|
+
* 3. Caching options
|
|
71
|
+
*/
|
|
72
|
+
fetchPolicy?: FetchPolicy;
|
|
73
|
+
/**
|
|
74
|
+
* A unique identifier for the query. Each item in the array must be a stable identifier to prevent infinite fetches.
|
|
75
|
+
*
|
|
76
|
+
* This is useful when using the same query and variables combination in more than one component, otherwise the components may clobber each other. This can also be used to force the query to re-evaluate fresh.
|
|
77
|
+
*
|
|
78
|
+
* @docGroup
|
|
79
|
+
*
|
|
80
|
+
* 1. Operation options
|
|
81
|
+
*/
|
|
82
|
+
queryKey?: string | number | any[];
|
|
83
|
+
/**
|
|
84
|
+
* If `true`, the query is not executed. The default value is `false`.
|
|
85
|
+
*
|
|
86
|
+
* @deprecated
|
|
87
|
+
*
|
|
88
|
+
* We recommend using `skipToken` in place of the `skip` option as it is more type-safe.
|
|
89
|
+
*
|
|
90
|
+
* This option is deprecated and only supported to ease the migration from `useQuery`. It will be removed in a future release. Please use [`skipToken`](https://www.apollographql.com/docs/react/api/react/hooks#skiptoken) instead of the `skip` option as it is more type-safe.
|
|
91
|
+
*
|
|
92
|
+
* @docGroup
|
|
93
|
+
*
|
|
94
|
+
* 1. Operation options
|
|
95
|
+
*
|
|
96
|
+
*
|
|
97
|
+
* @example Recommended usage of `skipToken`:
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { skipToken, useBackgroundQuery } from "@apollo/client";
|
|
101
|
+
*
|
|
102
|
+
* const [queryRef] = useBackgroundQuery(
|
|
103
|
+
* query,
|
|
104
|
+
* id ? { variables: { id } } : skipToken
|
|
105
|
+
* );
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
skip?: boolean;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
type Options<TVariables extends OperationVariables = OperationVariables> = Base.Options & VariablesOption<TVariables>;
|
|
112
|
+
namespace DocumentationTypes {
|
|
113
|
+
namespace useBackgroundQuery {
|
|
114
|
+
interface Options<TVariables extends OperationVariables = OperationVariables> extends Base.Options, UtilityDocumentationTypes.VariableOptions<TVariables> {
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
|
|
9
119
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* By default, the instance that's passed down via context is used, but you can provide a different instance here.
|
|
13
|
-
*
|
|
14
|
-
* @docGroup
|
|
120
|
+
* A function that enables you to execute a [subscription](https://www.apollographql.com/docs/react/data/subscriptions/), usually to subscribe to specific fields that were included in the query.
|
|
15
121
|
*
|
|
16
|
-
*
|
|
122
|
+
* This function returns _another_ function that you can call to terminate the subscription.
|
|
17
123
|
*/
|
|
18
|
-
|
|
124
|
+
subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
|
|
19
125
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* @docGroup
|
|
126
|
+
* A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
|
|
23
127
|
*
|
|
24
|
-
*
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).
|
|
25
131
|
*/
|
|
26
|
-
|
|
132
|
+
fetchMore: FetchMoreFunction<TData, TVariables>;
|
|
27
133
|
/**
|
|
28
|
-
*
|
|
134
|
+
* A function that enables you to re-execute the query, optionally passing in new `variables`.
|
|
29
135
|
*
|
|
30
|
-
*
|
|
136
|
+
* To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).
|
|
31
137
|
*
|
|
32
|
-
*
|
|
138
|
+
* See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).
|
|
33
139
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* 1. Operation options
|
|
37
|
-
*/
|
|
38
|
-
errorPolicy?: ErrorPolicy;
|
|
39
|
-
/**
|
|
40
|
-
* If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.
|
|
140
|
+
* Returns a `ResultPromise` with an additional `.retain()` method. Calling `.retain()` keeps the network operation running even if the `ObservableQuery` no longer requires the result.
|
|
41
141
|
*
|
|
42
142
|
* @docGroup
|
|
43
143
|
*
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
context?: DefaultContext;
|
|
47
|
-
/**
|
|
48
|
-
* If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.
|
|
49
|
-
*
|
|
50
|
-
* The default value is `false`.
|
|
144
|
+
* 3. Helper functions
|
|
51
145
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).
|
|
55
149
|
*/
|
|
56
|
-
|
|
150
|
+
refetch: RefetchFunction<TData, TVariables>;
|
|
151
|
+
}
|
|
152
|
+
namespace DocumentationTypes {
|
|
153
|
+
namespace useBackgroundQuery {
|
|
154
|
+
interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends _self.Result<TData, TVariables> {
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
namespace DocumentationTypes {
|
|
57
159
|
/**
|
|
58
|
-
*
|
|
160
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
59
161
|
*
|
|
60
|
-
*
|
|
162
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
61
163
|
*
|
|
62
|
-
*
|
|
164
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
63
165
|
*
|
|
64
|
-
* @
|
|
166
|
+
* @returns A tuple containing:
|
|
65
167
|
*
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
fetchPolicy?: FetchPolicy;
|
|
69
|
-
/**
|
|
70
|
-
* A unique identifier for the query. Each item in the array must be a stable identifier to prevent infinite fetches.
|
|
168
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
71
169
|
*
|
|
72
|
-
*
|
|
170
|
+
* @example
|
|
171
|
+
* ```jsx
|
|
172
|
+
* import { Suspense } from "react";
|
|
173
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
174
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
73
175
|
*
|
|
74
|
-
*
|
|
176
|
+
* const query = gql`
|
|
177
|
+
* foo {
|
|
178
|
+
* bar
|
|
179
|
+
* }
|
|
180
|
+
* `;
|
|
75
181
|
*
|
|
76
|
-
*
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
* If `true`, the query is not executed. The default value is `false`.
|
|
182
|
+
* const client = new ApolloClient({
|
|
183
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
184
|
+
* cache: new InMemoryCache(),
|
|
185
|
+
* });
|
|
81
186
|
*
|
|
82
|
-
*
|
|
187
|
+
* function SuspenseFallback() {
|
|
188
|
+
* return <div>Loading...</div>;
|
|
189
|
+
* }
|
|
83
190
|
*
|
|
84
|
-
*
|
|
191
|
+
* function Child({ queryRef }) {
|
|
192
|
+
* const { data } = useReadQuery(queryRef);
|
|
85
193
|
*
|
|
86
|
-
*
|
|
194
|
+
* return <div>{data.foo.bar}</div>;
|
|
195
|
+
* }
|
|
87
196
|
*
|
|
88
|
-
*
|
|
197
|
+
* function Parent() {
|
|
198
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
89
199
|
*
|
|
90
|
-
*
|
|
200
|
+
* return (
|
|
201
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
202
|
+
* <Child queryRef={queryRef} />
|
|
203
|
+
* </Suspense>
|
|
204
|
+
* );
|
|
205
|
+
* }
|
|
91
206
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
207
|
+
* function App() {
|
|
208
|
+
* return (
|
|
209
|
+
* <ApolloProvider client={client}>
|
|
210
|
+
* <Parent />
|
|
211
|
+
* </ApolloProvider>
|
|
212
|
+
* );
|
|
213
|
+
* }
|
|
98
214
|
* ```
|
|
99
215
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
*
|
|
106
|
-
* This function returns _another_ function that you can call to terminate the subscription.
|
|
107
|
-
*/
|
|
108
|
-
subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
|
|
109
|
-
/**
|
|
110
|
-
* A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
|
|
111
|
-
*/
|
|
112
|
-
fetchMore: FetchMoreFunction<TData, TVariables>;
|
|
113
|
-
/**
|
|
114
|
-
* Update the variables of this observable query, and fetch the new results. This method should be preferred over `setVariables` in most use cases.
|
|
115
|
-
*
|
|
116
|
-
* @param variables - The new set of variables. If there are missing variables, the previous values of those variables will be used.
|
|
117
|
-
*/
|
|
118
|
-
refetch: RefetchFunction<TData, TVariables>;
|
|
119
|
-
};
|
|
216
|
+
function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<TVariables>): [
|
|
217
|
+
QueryRef<TData, TVariables> | undefined,
|
|
218
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
219
|
+
];
|
|
220
|
+
}
|
|
120
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
224
|
+
*
|
|
225
|
+
* @returns A tuple containing:
|
|
226
|
+
*
|
|
227
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
228
|
+
* 2. An object containing helper functions for the query:
|
|
229
|
+
* - `refetch`: A function to re-execute the query
|
|
230
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
231
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
*
|
|
235
|
+
* ```jsx
|
|
236
|
+
* import { Suspense } from "react";
|
|
237
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
238
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
239
|
+
*
|
|
240
|
+
* const query = gql`
|
|
241
|
+
* foo {
|
|
242
|
+
* bar
|
|
243
|
+
* }
|
|
244
|
+
* `;
|
|
245
|
+
*
|
|
246
|
+
* const client = new ApolloClient({
|
|
247
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
248
|
+
* cache: new InMemoryCache(),
|
|
249
|
+
* });
|
|
250
|
+
*
|
|
251
|
+
* function SuspenseFallback() {
|
|
252
|
+
* return <div>Loading...</div>;
|
|
253
|
+
* }
|
|
254
|
+
*
|
|
255
|
+
* function Child({ queryRef }) {
|
|
256
|
+
* const { data } = useReadQuery(queryRef);
|
|
257
|
+
*
|
|
258
|
+
* return <div>{data.foo.bar}</div>;
|
|
259
|
+
* }
|
|
260
|
+
*
|
|
261
|
+
* function Parent() {
|
|
262
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
263
|
+
*
|
|
264
|
+
* return (
|
|
265
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
266
|
+
* <Child queryRef={queryRef} />
|
|
267
|
+
* </Suspense>
|
|
268
|
+
* );
|
|
269
|
+
* }
|
|
270
|
+
*
|
|
271
|
+
* function App() {
|
|
272
|
+
* return (
|
|
273
|
+
* <ApolloProvider client={client}>
|
|
274
|
+
* <Parent />
|
|
275
|
+
* </ApolloProvider>
|
|
276
|
+
* );
|
|
277
|
+
* }
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
281
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
282
|
+
*/
|
|
121
283
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
122
284
|
/** @deprecated `returnPartialData` has no effect on `no-cache` queries */
|
|
123
285
|
returnPartialData: boolean;
|
|
@@ -126,6 +288,63 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
|
|
|
126
288
|
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
127
289
|
useBackgroundQuery.Result<TData, TVariables>
|
|
128
290
|
];
|
|
291
|
+
/**
|
|
292
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
293
|
+
*
|
|
294
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
295
|
+
*
|
|
296
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
297
|
+
*
|
|
298
|
+
* @returns A tuple containing:
|
|
299
|
+
*
|
|
300
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```jsx
|
|
304
|
+
* import { Suspense } from "react";
|
|
305
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
306
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
307
|
+
*
|
|
308
|
+
* const query = gql`
|
|
309
|
+
* foo {
|
|
310
|
+
* bar
|
|
311
|
+
* }
|
|
312
|
+
* `;
|
|
313
|
+
*
|
|
314
|
+
* const client = new ApolloClient({
|
|
315
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
316
|
+
* cache: new InMemoryCache(),
|
|
317
|
+
* });
|
|
318
|
+
*
|
|
319
|
+
* function SuspenseFallback() {
|
|
320
|
+
* return <div>Loading...</div>;
|
|
321
|
+
* }
|
|
322
|
+
*
|
|
323
|
+
* function Child({ queryRef }) {
|
|
324
|
+
* const { data } = useReadQuery(queryRef);
|
|
325
|
+
*
|
|
326
|
+
* return <div>{data.foo.bar}</div>;
|
|
327
|
+
* }
|
|
328
|
+
*
|
|
329
|
+
* function Parent() {
|
|
330
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
331
|
+
*
|
|
332
|
+
* return (
|
|
333
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
334
|
+
* <Child queryRef={queryRef} />
|
|
335
|
+
* </Suspense>
|
|
336
|
+
* );
|
|
337
|
+
* }
|
|
338
|
+
*
|
|
339
|
+
* function App() {
|
|
340
|
+
* return (
|
|
341
|
+
* <ApolloProvider client={client}>
|
|
342
|
+
* <Parent />
|
|
343
|
+
* </ApolloProvider>
|
|
344
|
+
* );
|
|
345
|
+
* }
|
|
346
|
+
* ```
|
|
347
|
+
*/
|
|
129
348
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
130
349
|
returnPartialData: false;
|
|
131
350
|
errorPolicy: "ignore" | "all";
|
|
@@ -133,6 +352,63 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
|
|
|
133
352
|
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
134
353
|
useBackgroundQuery.Result<TData, TVariables>
|
|
135
354
|
];
|
|
355
|
+
/**
|
|
356
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
357
|
+
*
|
|
358
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
359
|
+
*
|
|
360
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
361
|
+
*
|
|
362
|
+
* @returns A tuple containing:
|
|
363
|
+
*
|
|
364
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```jsx
|
|
368
|
+
* import { Suspense } from "react";
|
|
369
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
370
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
371
|
+
*
|
|
372
|
+
* const query = gql`
|
|
373
|
+
* foo {
|
|
374
|
+
* bar
|
|
375
|
+
* }
|
|
376
|
+
* `;
|
|
377
|
+
*
|
|
378
|
+
* const client = new ApolloClient({
|
|
379
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
380
|
+
* cache: new InMemoryCache(),
|
|
381
|
+
* });
|
|
382
|
+
*
|
|
383
|
+
* function SuspenseFallback() {
|
|
384
|
+
* return <div>Loading...</div>;
|
|
385
|
+
* }
|
|
386
|
+
*
|
|
387
|
+
* function Child({ queryRef }) {
|
|
388
|
+
* const { data } = useReadQuery(queryRef);
|
|
389
|
+
*
|
|
390
|
+
* return <div>{data.foo.bar}</div>;
|
|
391
|
+
* }
|
|
392
|
+
*
|
|
393
|
+
* function Parent() {
|
|
394
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
395
|
+
*
|
|
396
|
+
* return (
|
|
397
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
398
|
+
* <Child queryRef={queryRef} />
|
|
399
|
+
* </Suspense>
|
|
400
|
+
* );
|
|
401
|
+
* }
|
|
402
|
+
*
|
|
403
|
+
* function App() {
|
|
404
|
+
* return (
|
|
405
|
+
* <ApolloProvider client={client}>
|
|
406
|
+
* <Parent />
|
|
407
|
+
* </ApolloProvider>
|
|
408
|
+
* );
|
|
409
|
+
* }
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
136
412
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
137
413
|
returnPartialData: boolean;
|
|
138
414
|
errorPolicy: "ignore" | "all";
|
|
@@ -140,12 +416,126 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
|
|
|
140
416
|
QueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">,
|
|
141
417
|
useBackgroundQuery.Result<TData, TVariables>
|
|
142
418
|
];
|
|
419
|
+
/**
|
|
420
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
421
|
+
*
|
|
422
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
423
|
+
*
|
|
424
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
425
|
+
*
|
|
426
|
+
* @returns A tuple containing:
|
|
427
|
+
*
|
|
428
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
429
|
+
*
|
|
430
|
+
* @example
|
|
431
|
+
* ```jsx
|
|
432
|
+
* import { Suspense } from "react";
|
|
433
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
434
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
435
|
+
*
|
|
436
|
+
* const query = gql`
|
|
437
|
+
* foo {
|
|
438
|
+
* bar
|
|
439
|
+
* }
|
|
440
|
+
* `;
|
|
441
|
+
*
|
|
442
|
+
* const client = new ApolloClient({
|
|
443
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
444
|
+
* cache: new InMemoryCache(),
|
|
445
|
+
* });
|
|
446
|
+
*
|
|
447
|
+
* function SuspenseFallback() {
|
|
448
|
+
* return <div>Loading...</div>;
|
|
449
|
+
* }
|
|
450
|
+
*
|
|
451
|
+
* function Child({ queryRef }) {
|
|
452
|
+
* const { data } = useReadQuery(queryRef);
|
|
453
|
+
*
|
|
454
|
+
* return <div>{data.foo.bar}</div>;
|
|
455
|
+
* }
|
|
456
|
+
*
|
|
457
|
+
* function Parent() {
|
|
458
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
459
|
+
*
|
|
460
|
+
* return (
|
|
461
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
462
|
+
* <Child queryRef={queryRef} />
|
|
463
|
+
* </Suspense>
|
|
464
|
+
* );
|
|
465
|
+
* }
|
|
466
|
+
*
|
|
467
|
+
* function App() {
|
|
468
|
+
* return (
|
|
469
|
+
* <ApolloProvider client={client}>
|
|
470
|
+
* <Parent />
|
|
471
|
+
* </ApolloProvider>
|
|
472
|
+
* );
|
|
473
|
+
* }
|
|
474
|
+
* ```
|
|
475
|
+
*/
|
|
143
476
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
144
477
|
errorPolicy: "ignore" | "all";
|
|
145
478
|
}): [
|
|
146
479
|
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
147
480
|
useBackgroundQuery.Result<TData, TVariables>
|
|
148
481
|
];
|
|
482
|
+
/**
|
|
483
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
484
|
+
*
|
|
485
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
486
|
+
*
|
|
487
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
488
|
+
*
|
|
489
|
+
* @returns A tuple containing:
|
|
490
|
+
*
|
|
491
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```jsx
|
|
495
|
+
* import { Suspense } from "react";
|
|
496
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
497
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
498
|
+
*
|
|
499
|
+
* const query = gql`
|
|
500
|
+
* foo {
|
|
501
|
+
* bar
|
|
502
|
+
* }
|
|
503
|
+
* `;
|
|
504
|
+
*
|
|
505
|
+
* const client = new ApolloClient({
|
|
506
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
507
|
+
* cache: new InMemoryCache(),
|
|
508
|
+
* });
|
|
509
|
+
*
|
|
510
|
+
* function SuspenseFallback() {
|
|
511
|
+
* return <div>Loading...</div>;
|
|
512
|
+
* }
|
|
513
|
+
*
|
|
514
|
+
* function Child({ queryRef }) {
|
|
515
|
+
* const { data } = useReadQuery(queryRef);
|
|
516
|
+
*
|
|
517
|
+
* return <div>{data.foo.bar}</div>;
|
|
518
|
+
* }
|
|
519
|
+
*
|
|
520
|
+
* function Parent() {
|
|
521
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
522
|
+
*
|
|
523
|
+
* return (
|
|
524
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
525
|
+
* <Child queryRef={queryRef} />
|
|
526
|
+
* </Suspense>
|
|
527
|
+
* );
|
|
528
|
+
* }
|
|
529
|
+
*
|
|
530
|
+
* function App() {
|
|
531
|
+
* return (
|
|
532
|
+
* <ApolloProvider client={client}>
|
|
533
|
+
* <Parent />
|
|
534
|
+
* </ApolloProvider>
|
|
535
|
+
* );
|
|
536
|
+
* }
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
149
539
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
150
540
|
skip: boolean;
|
|
151
541
|
returnPartialData: false;
|
|
@@ -153,6 +543,63 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
|
|
|
153
543
|
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
154
544
|
useBackgroundQuery.Result<TData, TVariables>
|
|
155
545
|
];
|
|
546
|
+
/**
|
|
547
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
548
|
+
*
|
|
549
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
550
|
+
*
|
|
551
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
552
|
+
*
|
|
553
|
+
* @returns A tuple containing:
|
|
554
|
+
*
|
|
555
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* ```jsx
|
|
559
|
+
* import { Suspense } from "react";
|
|
560
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
561
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
562
|
+
*
|
|
563
|
+
* const query = gql`
|
|
564
|
+
* foo {
|
|
565
|
+
* bar
|
|
566
|
+
* }
|
|
567
|
+
* `;
|
|
568
|
+
*
|
|
569
|
+
* const client = new ApolloClient({
|
|
570
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
571
|
+
* cache: new InMemoryCache(),
|
|
572
|
+
* });
|
|
573
|
+
*
|
|
574
|
+
* function SuspenseFallback() {
|
|
575
|
+
* return <div>Loading...</div>;
|
|
576
|
+
* }
|
|
577
|
+
*
|
|
578
|
+
* function Child({ queryRef }) {
|
|
579
|
+
* const { data } = useReadQuery(queryRef);
|
|
580
|
+
*
|
|
581
|
+
* return <div>{data.foo.bar}</div>;
|
|
582
|
+
* }
|
|
583
|
+
*
|
|
584
|
+
* function Parent() {
|
|
585
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
586
|
+
*
|
|
587
|
+
* return (
|
|
588
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
589
|
+
* <Child queryRef={queryRef} />
|
|
590
|
+
* </Suspense>
|
|
591
|
+
* );
|
|
592
|
+
* }
|
|
593
|
+
*
|
|
594
|
+
* function App() {
|
|
595
|
+
* return (
|
|
596
|
+
* <ApolloProvider client={client}>
|
|
597
|
+
* <Parent />
|
|
598
|
+
* </ApolloProvider>
|
|
599
|
+
* );
|
|
600
|
+
* }
|
|
601
|
+
* ```
|
|
602
|
+
*/
|
|
156
603
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
157
604
|
skip: boolean;
|
|
158
605
|
returnPartialData: boolean;
|
|
@@ -160,25 +607,310 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
|
|
|
160
607
|
QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined,
|
|
161
608
|
useBackgroundQuery.Result<TData, TVariables>
|
|
162
609
|
];
|
|
610
|
+
/**
|
|
611
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
612
|
+
*
|
|
613
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
614
|
+
*
|
|
615
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
616
|
+
*
|
|
617
|
+
* @returns A tuple containing:
|
|
618
|
+
*
|
|
619
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
620
|
+
*
|
|
621
|
+
* @example
|
|
622
|
+
* ```jsx
|
|
623
|
+
* import { Suspense } from "react";
|
|
624
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
625
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
626
|
+
*
|
|
627
|
+
* const query = gql`
|
|
628
|
+
* foo {
|
|
629
|
+
* bar
|
|
630
|
+
* }
|
|
631
|
+
* `;
|
|
632
|
+
*
|
|
633
|
+
* const client = new ApolloClient({
|
|
634
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
635
|
+
* cache: new InMemoryCache(),
|
|
636
|
+
* });
|
|
637
|
+
*
|
|
638
|
+
* function SuspenseFallback() {
|
|
639
|
+
* return <div>Loading...</div>;
|
|
640
|
+
* }
|
|
641
|
+
*
|
|
642
|
+
* function Child({ queryRef }) {
|
|
643
|
+
* const { data } = useReadQuery(queryRef);
|
|
644
|
+
*
|
|
645
|
+
* return <div>{data.foo.bar}</div>;
|
|
646
|
+
* }
|
|
647
|
+
*
|
|
648
|
+
* function Parent() {
|
|
649
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
650
|
+
*
|
|
651
|
+
* return (
|
|
652
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
653
|
+
* <Child queryRef={queryRef} />
|
|
654
|
+
* </Suspense>
|
|
655
|
+
* );
|
|
656
|
+
* }
|
|
657
|
+
*
|
|
658
|
+
* function App() {
|
|
659
|
+
* return (
|
|
660
|
+
* <ApolloProvider client={client}>
|
|
661
|
+
* <Parent />
|
|
662
|
+
* </ApolloProvider>
|
|
663
|
+
* );
|
|
664
|
+
* }
|
|
665
|
+
* ```
|
|
666
|
+
*/
|
|
163
667
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
164
668
|
returnPartialData: false;
|
|
165
669
|
}): [
|
|
166
670
|
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
167
671
|
useBackgroundQuery.Result<TData, TVariables>
|
|
168
672
|
];
|
|
673
|
+
/**
|
|
674
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
675
|
+
*
|
|
676
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
677
|
+
*
|
|
678
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
679
|
+
*
|
|
680
|
+
* @returns A tuple containing:
|
|
681
|
+
*
|
|
682
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
683
|
+
*
|
|
684
|
+
* @example
|
|
685
|
+
* ```jsx
|
|
686
|
+
* import { Suspense } from "react";
|
|
687
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
688
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
689
|
+
*
|
|
690
|
+
* const query = gql`
|
|
691
|
+
* foo {
|
|
692
|
+
* bar
|
|
693
|
+
* }
|
|
694
|
+
* `;
|
|
695
|
+
*
|
|
696
|
+
* const client = new ApolloClient({
|
|
697
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
698
|
+
* cache: new InMemoryCache(),
|
|
699
|
+
* });
|
|
700
|
+
*
|
|
701
|
+
* function SuspenseFallback() {
|
|
702
|
+
* return <div>Loading...</div>;
|
|
703
|
+
* }
|
|
704
|
+
*
|
|
705
|
+
* function Child({ queryRef }) {
|
|
706
|
+
* const { data } = useReadQuery(queryRef);
|
|
707
|
+
*
|
|
708
|
+
* return <div>{data.foo.bar}</div>;
|
|
709
|
+
* }
|
|
710
|
+
*
|
|
711
|
+
* function Parent() {
|
|
712
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
713
|
+
*
|
|
714
|
+
* return (
|
|
715
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
716
|
+
* <Child queryRef={queryRef} />
|
|
717
|
+
* </Suspense>
|
|
718
|
+
* );
|
|
719
|
+
* }
|
|
720
|
+
*
|
|
721
|
+
* function App() {
|
|
722
|
+
* return (
|
|
723
|
+
* <ApolloProvider client={client}>
|
|
724
|
+
* <Parent />
|
|
725
|
+
* </ApolloProvider>
|
|
726
|
+
* );
|
|
727
|
+
* }
|
|
728
|
+
* ```
|
|
729
|
+
*/
|
|
169
730
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
170
731
|
returnPartialData: boolean;
|
|
171
732
|
}): [
|
|
172
733
|
QueryRef<TData, TVariables, "complete" | "streaming" | "partial">,
|
|
173
734
|
useBackgroundQuery.Result<TData, TVariables>
|
|
174
735
|
];
|
|
736
|
+
/**
|
|
737
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
738
|
+
*
|
|
739
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
740
|
+
*
|
|
741
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
742
|
+
*
|
|
743
|
+
* @returns A tuple containing:
|
|
744
|
+
*
|
|
745
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* ```jsx
|
|
749
|
+
* import { Suspense } from "react";
|
|
750
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
751
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
752
|
+
*
|
|
753
|
+
* const query = gql`
|
|
754
|
+
* foo {
|
|
755
|
+
* bar
|
|
756
|
+
* }
|
|
757
|
+
* `;
|
|
758
|
+
*
|
|
759
|
+
* const client = new ApolloClient({
|
|
760
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
761
|
+
* cache: new InMemoryCache(),
|
|
762
|
+
* });
|
|
763
|
+
*
|
|
764
|
+
* function SuspenseFallback() {
|
|
765
|
+
* return <div>Loading...</div>;
|
|
766
|
+
* }
|
|
767
|
+
*
|
|
768
|
+
* function Child({ queryRef }) {
|
|
769
|
+
* const { data } = useReadQuery(queryRef);
|
|
770
|
+
*
|
|
771
|
+
* return <div>{data.foo.bar}</div>;
|
|
772
|
+
* }
|
|
773
|
+
*
|
|
774
|
+
* function Parent() {
|
|
775
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
776
|
+
*
|
|
777
|
+
* return (
|
|
778
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
779
|
+
* <Child queryRef={queryRef} />
|
|
780
|
+
* </Suspense>
|
|
781
|
+
* );
|
|
782
|
+
* }
|
|
783
|
+
*
|
|
784
|
+
* function App() {
|
|
785
|
+
* return (
|
|
786
|
+
* <ApolloProvider client={client}>
|
|
787
|
+
* <Parent />
|
|
788
|
+
* </ApolloProvider>
|
|
789
|
+
* );
|
|
790
|
+
* }
|
|
791
|
+
* ```
|
|
792
|
+
*/
|
|
175
793
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
176
794
|
skip: boolean;
|
|
177
795
|
}): [
|
|
178
796
|
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
179
797
|
useBackgroundQuery.Result<TData, TVariables>
|
|
180
798
|
];
|
|
799
|
+
/**
|
|
800
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
801
|
+
*
|
|
802
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
803
|
+
*
|
|
804
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
805
|
+
*
|
|
806
|
+
* @returns A tuple containing:
|
|
807
|
+
*
|
|
808
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
809
|
+
*
|
|
810
|
+
* @example
|
|
811
|
+
* ```jsx
|
|
812
|
+
* import { Suspense } from "react";
|
|
813
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
814
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
815
|
+
*
|
|
816
|
+
* const query = gql`
|
|
817
|
+
* foo {
|
|
818
|
+
* bar
|
|
819
|
+
* }
|
|
820
|
+
* `;
|
|
821
|
+
*
|
|
822
|
+
* const client = new ApolloClient({
|
|
823
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
824
|
+
* cache: new InMemoryCache(),
|
|
825
|
+
* });
|
|
826
|
+
*
|
|
827
|
+
* function SuspenseFallback() {
|
|
828
|
+
* return <div>Loading...</div>;
|
|
829
|
+
* }
|
|
830
|
+
*
|
|
831
|
+
* function Child({ queryRef }) {
|
|
832
|
+
* const { data } = useReadQuery(queryRef);
|
|
833
|
+
*
|
|
834
|
+
* return <div>{data.foo.bar}</div>;
|
|
835
|
+
* }
|
|
836
|
+
*
|
|
837
|
+
* function Parent() {
|
|
838
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
839
|
+
*
|
|
840
|
+
* return (
|
|
841
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
842
|
+
* <Child queryRef={queryRef} />
|
|
843
|
+
* </Suspense>
|
|
844
|
+
* );
|
|
845
|
+
* }
|
|
846
|
+
*
|
|
847
|
+
* function App() {
|
|
848
|
+
* return (
|
|
849
|
+
* <ApolloProvider client={client}>
|
|
850
|
+
* <Parent />
|
|
851
|
+
* </ApolloProvider>
|
|
852
|
+
* );
|
|
853
|
+
* }
|
|
854
|
+
* ```
|
|
855
|
+
*/
|
|
181
856
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, useBackgroundQuery.Result<TData, TVariables>];
|
|
857
|
+
/**
|
|
858
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
859
|
+
*
|
|
860
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
861
|
+
*
|
|
862
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
|
|
863
|
+
*
|
|
864
|
+
* @returns A tuple containing:
|
|
865
|
+
*
|
|
866
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
|
|
867
|
+
*
|
|
868
|
+
* @example
|
|
869
|
+
* ```jsx
|
|
870
|
+
* import { Suspense } from "react";
|
|
871
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
872
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
873
|
+
*
|
|
874
|
+
* const query = gql`
|
|
875
|
+
* foo {
|
|
876
|
+
* bar
|
|
877
|
+
* }
|
|
878
|
+
* `;
|
|
879
|
+
*
|
|
880
|
+
* const client = new ApolloClient({
|
|
881
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
882
|
+
* cache: new InMemoryCache(),
|
|
883
|
+
* });
|
|
884
|
+
*
|
|
885
|
+
* function SuspenseFallback() {
|
|
886
|
+
* return <div>Loading...</div>;
|
|
887
|
+
* }
|
|
888
|
+
*
|
|
889
|
+
* function Child({ queryRef }) {
|
|
890
|
+
* const { data } = useReadQuery(queryRef);
|
|
891
|
+
*
|
|
892
|
+
* return <div>{data.foo.bar}</div>;
|
|
893
|
+
* }
|
|
894
|
+
*
|
|
895
|
+
* function Parent() {
|
|
896
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
897
|
+
*
|
|
898
|
+
* return (
|
|
899
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
900
|
+
* <Child queryRef={queryRef} />
|
|
901
|
+
* </Suspense>
|
|
902
|
+
* );
|
|
903
|
+
* }
|
|
904
|
+
*
|
|
905
|
+
* function App() {
|
|
906
|
+
* return (
|
|
907
|
+
* <ApolloProvider client={client}>
|
|
908
|
+
* <Parent />
|
|
909
|
+
* </ApolloProvider>
|
|
910
|
+
* );
|
|
911
|
+
* }
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
182
914
|
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
183
915
|
returnPartialData: false;
|
|
184
916
|
})): [
|