@apollo/client 3.8.0-alpha.8 → 3.8.0-beta.0
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/apollo-client.cjs +1064 -680
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +49 -34
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +49 -34
- package/cache/core/cache.d.ts +5 -4
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js +1 -0
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +2 -2
- package/cache/core/types/Cache.d.ts.map +1 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +6 -5
- package/cache/core/types/DataProxy.d.ts.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +3 -3
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +5 -5
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +2 -2
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.d.ts +1 -1
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +6 -5
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -7
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +14 -15
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.d.ts +1 -1
- package/cache/inmemory/key-extractor.d.ts.map +1 -1
- package/cache/inmemory/key-extractor.js +2 -2
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/policies.d.ts +7 -6
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +20 -9
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.d.ts.map +1 -1
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +6 -6
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +10 -5
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +6 -6
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +6 -6
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +7 -8
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/setup.d.ts +1 -0
- package/config/jest/setup.d.ts.map +1 -1
- package/config/jest/setup.js +3 -0
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +15 -12
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +28 -20
- package/core/ApolloClient.js.map +1 -1
- package/core/DocumentTransform.d.ts +24 -0
- package/core/DocumentTransform.d.ts.map +1 -0
- package/core/DocumentTransform.js +68 -0
- package/core/DocumentTransform.js.map +1 -0
- package/core/LocalState.d.ts +7 -9
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +6 -10
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +11 -8
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +48 -28
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +9 -9
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +15 -11
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +115 -108
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +342 -176
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +342 -176
- package/core/equalByQuery.d.ts +4 -0
- package/core/equalByQuery.d.ts.map +1 -0
- package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
- package/core/equalByQuery.js.map +1 -0
- package/core/index.d.ts +2 -1
- package/core/index.d.ts.map +1 -1
- package/core/index.js +2 -1
- package/core/index.js.map +1 -1
- package/core/networkStatus.d.ts +1 -0
- package/core/networkStatus.d.ts.map +1 -1
- package/core/networkStatus.js +3 -0
- package/core/networkStatus.js.map +1 -1
- package/core/types.d.ts +14 -14
- package/core/types.d.ts.map +1 -1
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +6 -7
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +642 -0
- package/dev/dev.cjs.map +1 -0
- package/dev/dev.cjs.native.js +642 -0
- package/dev/index.d.ts +4 -0
- package/dev/index.d.ts.map +1 -0
- package/dev/index.js +4 -0
- package/dev/index.js.map +1 -0
- package/dev/loadDevMessages.d.ts +2 -0
- package/dev/loadDevMessages.d.ts.map +1 -0
- package/dev/loadDevMessages.js +6 -0
- package/dev/loadDevMessages.js.map +1 -0
- package/dev/loadErrorMessageHandler.d.ts +3 -0
- package/dev/loadErrorMessageHandler.d.ts.map +1 -0
- package/dev/loadErrorMessageHandler.js +26 -0
- package/dev/loadErrorMessageHandler.js.map +1 -0
- package/dev/loadErrorMessages.d.ts +2 -0
- package/dev/loadErrorMessages.d.ts.map +1 -0
- package/dev/loadErrorMessages.js +6 -0
- package/dev/loadErrorMessages.js.map +1 -0
- package/dev/package.json +8 -0
- package/errors/errors.cjs +17 -17
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +17 -17
- package/errors/index.d.ts +26 -10
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +17 -19
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.d.ts +13 -0
- package/invariantErrorCodes.d.ts.map +1 -0
- package/invariantErrorCodes.js +331 -144
- package/invariantErrorCodes.js.map +1 -0
- package/link/batch/batchLink.d.ts +4 -3
- package/link/batch/batchLink.d.ts.map +1 -1
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +1 -1
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +23 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +23 -2
- package/link/batch-http/batchHttpLink.d.ts +3 -2
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +7 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/index.d.ts +3 -2
- package/link/context/index.d.ts.map +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +3 -2
- package/link/core/ApolloLink.d.ts.map +1 -1
- package/link/core/ApolloLink.js +3 -13
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +2 -12
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -12
- package/link/core/types.d.ts +8 -3
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/error/index.d.ts +4 -3
- package/link/error/index.d.ts.map +1 -1
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +3 -2
- package/link/http/HttpLink.d.ts.map +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +2 -2
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.d.ts +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +21 -20
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +73 -43
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +73 -43
- package/link/http/iterators/nodeStream.d.ts +1 -1
- package/link/http/iterators/nodeStream.d.ts.map +1 -1
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +47 -26
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts +1 -1
- package/link/http/responseIterator.d.ts.map +1 -1
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +1 -1
- package/link/http/rewriteURIForGET.d.ts.map +1 -1
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +3 -2
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.d.ts +1 -1
- package/link/http/selectURI.d.ts.map +1 -1
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.d.ts +1 -1
- package/link/http/serializeFetchParameter.d.ts.map +1 -1
- package/link/http/serializeFetchParameter.js +2 -2
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts +4 -3
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +16 -20
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +15 -19
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +15 -19
- package/link/remove-typename/index.d.ts +2 -0
- package/link/remove-typename/index.d.ts.map +1 -0
- package/link/remove-typename/index.js +2 -0
- package/link/remove-typename/index.js.map +1 -0
- package/link/remove-typename/package.json +8 -0
- package/link/remove-typename/remove-typename.cjs +82 -0
- package/link/remove-typename/remove-typename.cjs.map +1 -0
- package/link/remove-typename/remove-typename.cjs.native.js +82 -0
- package/link/remove-typename/removeTypenameFromVariables.d.ts +11 -0
- package/link/remove-typename/removeTypenameFromVariables.d.ts.map +1 -0
- package/link/remove-typename/removeTypenameFromVariables.js +74 -0
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -0
- package/link/retry/delayFunction.d.ts +1 -1
- package/link/retry/delayFunction.d.ts.map +1 -1
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retryFunction.d.ts +1 -1
- package/link/retry/retryFunction.d.ts.map +1 -1
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.d.ts +4 -3
- package/link/retry/retryLink.d.ts.map +1 -1
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +3 -2
- package/link/schema/index.d.ts.map +1 -1
- package/link/schema/index.js.map +1 -1
- package/link/subscriptions/index.d.ts +2 -1
- package/link/subscriptions/index.d.ts.map +1 -1
- package/link/subscriptions/index.js +8 -3
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +8 -3
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +8 -3
- package/link/utils/createOperation.d.ts +1 -1
- package/link/utils/createOperation.d.ts.map +1 -1
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/filterOperationVariables.d.ts +5 -0
- package/link/utils/filterOperationVariables.d.ts.map +1 -0
- package/link/utils/filterOperationVariables.js +18 -0
- package/link/utils/filterOperationVariables.js.map +1 -0
- package/link/utils/index.d.ts +1 -0
- package/link/utils/index.d.ts.map +1 -1
- package/link/utils/index.js +1 -0
- package/link/utils/index.js.map +1 -1
- package/link/utils/throwServerError.d.ts +1 -1
- package/link/utils/throwServerError.d.ts.map +1 -1
- package/link/utils/throwServerError.js.map +1 -1
- package/link/utils/toPromise.d.ts +1 -1
- package/link/utils/toPromise.d.ts.map +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/transformOperation.d.ts +1 -1
- package/link/utils/transformOperation.d.ts.map +1 -1
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +20 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +20 -2
- package/link/utils/validateOperation.d.ts +1 -1
- package/link/utils/validateOperation.d.ts.map +1 -1
- package/link/utils/validateOperation.js +2 -2
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +5 -3
- package/link/ws/index.d.ts.map +1 -1
- package/link/ws/index.js.map +1 -1
- package/package.json +37 -34
- package/react/cache/QueryReference.d.ts +34 -0
- package/react/cache/QueryReference.d.ts.map +1 -0
- package/react/cache/QueryReference.js +107 -0
- package/react/cache/QueryReference.js.map +1 -0
- package/react/cache/SuspenseCache.d.ts +10 -13
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js +18 -41
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/cache/types.d.ts +2 -0
- package/react/cache/types.d.ts.map +1 -0
- package/react/cache/types.js +2 -0
- package/react/cache/types.js.map +1 -0
- package/react/components/Mutation.d.ts +2 -2
- package/react/components/Mutation.d.ts.map +1 -1
- package/react/components/Mutation.js.map +1 -1
- package/react/components/Query.d.ts +2 -2
- package/react/components/Query.d.ts.map +1 -1
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.d.ts +2 -2
- package/react/components/Subscription.d.ts.map +1 -1
- package/react/components/Subscription.js.map +1 -1
- package/react/components/types.d.ts +4 -4
- package/react/components/types.d.ts.map +1 -1
- package/react/components/types.js.map +1 -1
- package/react/context/ApolloConsumer.d.ts +1 -1
- package/react/context/ApolloConsumer.d.ts.map +1 -1
- package/react/context/ApolloConsumer.js +2 -3
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +10 -3
- package/react/context/ApolloContext.d.ts.map +1 -1
- package/react/context/ApolloContext.js +10 -8
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +2 -2
- package/react/context/ApolloProvider.d.ts.map +1 -1
- package/react/context/ApolloProvider.js +8 -13
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/context/context.cjs +18 -22
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +18 -22
- package/react/context/index.d.ts +1 -1
- package/react/context/index.d.ts.map +1 -1
- package/react/context/index.js +1 -1
- package/react/context/index.js.map +1 -1
- package/react/hoc/graphql.d.ts +3 -3
- package/react/hoc/graphql.d.ts.map +1 -1
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts +2 -2
- package/react/hoc/hoc-utils.d.ts.map +1 -1
- package/react/hoc/hoc-utils.js +2 -3
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs +2 -4
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -4
- package/react/hoc/mutation-hoc.d.ts +4 -4
- package/react/hoc/mutation-hoc.d.ts.map +1 -1
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +2 -2
- package/react/hoc/query-hoc.d.ts.map +1 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +2 -2
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/types.d.ts +4 -4
- package/react/hoc/types.d.ts.map +1 -1
- package/react/hoc/types.js.map +1 -1
- package/react/hoc/withApollo.d.ts +1 -1
- package/react/hoc/withApollo.d.ts.map +1 -1
- package/react/hoc/withApollo.js +2 -3
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +226 -216
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +226 -216
- package/react/hooks/index.d.ts +2 -1
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +2 -1
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/internal/__use.d.ts +4 -0
- package/react/hooks/internal/__use.d.ts.map +1 -0
- package/react/hooks/internal/__use.js +17 -0
- package/react/hooks/internal/__use.js.map +1 -0
- package/react/hooks/internal/index.d.ts +2 -0
- package/react/hooks/internal/index.d.ts.map +1 -1
- package/react/hooks/internal/index.js +2 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useDeepMemo.d.ts +1 -1
- package/react/hooks/internal/useDeepMemo.d.ts.map +1 -1
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +2 -2
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts +2 -0
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts.map +1 -0
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.js +11 -0
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.js.map +1 -0
- package/react/hooks/useApolloClient.d.ts +1 -1
- package/react/hooks/useApolloClient.d.ts.map +1 -1
- package/react/hooks/useApolloClient.js +2 -4
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +18 -0
- package/react/hooks/useBackgroundQuery.d.ts.map +1 -0
- package/react/hooks/useBackgroundQuery.js +69 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -0
- package/react/hooks/useFragment.d.ts +14 -9
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js +2 -2
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +4 -4
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +13 -22
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +4 -4
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +3 -2
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +6 -6
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +30 -29
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +1 -1
- package/react/hooks/useReactiveVar.d.ts.map +1 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +4 -4
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +27 -19
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseCache.d.ts +1 -1
- package/react/hooks/useSuspenseCache.d.ts.map +1 -1
- package/react/hooks/useSuspenseCache.js +2 -4
- package/react/hooks/useSuspenseCache.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +39 -7
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +68 -144
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -1
- package/react/index.js.map +1 -1
- package/react/parser/index.d.ts +1 -1
- package/react/parser/index.d.ts.map +1 -1
- package/react/parser/index.js +20 -17
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +19 -16
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +19 -16
- package/react/react.cjs +116 -35
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +116 -35
- package/react/ssr/RenderPromises.d.ts +2 -2
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/renderToStringWithData.d.ts +1 -1
- package/react/ssr/renderToStringWithData.d.ts.map +1 -1
- package/react/ssr/renderToStringWithData.js.map +1 -1
- package/react/types/types.d.ts +10 -13
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +1 -1
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockClient.d.ts +2 -2
- package/testing/core/mocking/mockClient.d.ts.map +1 -1
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +2 -1
- package/testing/core/mocking/mockLink.d.ts.map +1 -1
- package/testing/core/mocking/mockLink.js +3 -3
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -2
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts +2 -2
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -1
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +2 -2
- package/testing/core/observableToPromise.d.ts.map +1 -1
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/subscribeAndCount.d.ts +1 -1
- package/testing/core/subscribeAndCount.d.ts.map +1 -1
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/matchers/index.d.ts +2 -0
- package/testing/matchers/index.d.ts.map +1 -0
- package/testing/matchers/index.js +6 -0
- package/testing/matchers/index.js.map +1 -0
- package/testing/matchers/toMatchDocument.d.ts +4 -0
- package/testing/matchers/toMatchDocument.d.ts.map +1 -0
- package/testing/matchers/toMatchDocument.js +34 -0
- package/testing/matchers/toMatchDocument.js.map +1 -0
- package/testing/react/MockedProvider.d.ts +8 -7
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +7 -6
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +7 -51
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +7 -51
- package/utilities/common/compact.d.ts +1 -1
- package/utilities/common/compact.d.ts.map +1 -1
- package/utilities/common/compact.js.map +1 -1
- package/utilities/common/errorHandling.d.ts +1 -1
- package/utilities/common/errorHandling.d.ts.map +1 -1
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +2 -1
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js +4 -0
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/objects.d.ts +1 -0
- package/utilities/common/objects.d.ts.map +1 -1
- package/utilities/common/objects.js +6 -0
- package/utilities/common/objects.js.map +1 -1
- package/utilities/common/omitDeep.d.ts +3 -0
- package/utilities/common/omitDeep.d.ts.map +1 -0
- package/utilities/common/omitDeep.js +41 -0
- package/utilities/common/omitDeep.js.map +1 -0
- package/utilities/common/responseIterator.d.ts +2 -2
- package/utilities/common/responseIterator.d.ts.map +1 -1
- package/utilities/common/responseIterator.js.map +1 -1
- package/utilities/common/stringifyForDisplay.d.ts +1 -1
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -1
- package/utilities/common/stringifyForDisplay.js +3 -2
- package/utilities/common/stringifyForDisplay.js.map +1 -1
- package/utilities/common/stripTypename.d.ts +2 -0
- package/utilities/common/stripTypename.d.ts.map +1 -0
- package/utilities/common/stripTypename.js +5 -0
- package/utilities/common/stripTypename.js.map +1 -0
- package/utilities/globals/global.d.ts +6 -3
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +67 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +67 -1
- package/utilities/globals/index.d.ts +2 -2
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +2 -2
- package/utilities/globals/index.js.map +1 -1
- package/utilities/globals/invariantWrappers.d.ts +24 -0
- package/utilities/globals/invariantWrappers.d.ts.map +1 -0
- package/utilities/globals/invariantWrappers.js +53 -0
- package/utilities/globals/invariantWrappers.js.map +1 -0
- package/utilities/graphql/directives.d.ts +1 -1
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +6 -7
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +8 -5
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +1 -1
- package/utilities/graphql/getFromAST.d.ts.map +1 -1
- package/utilities/graphql/getFromAST.js +16 -12
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/operations.d.ts +5 -0
- package/utilities/graphql/operations.d.ts.map +1 -0
- package/utilities/graphql/operations.js +16 -0
- package/utilities/graphql/operations.js.map +1 -0
- package/utilities/graphql/storeUtils.d.ts +2 -2
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +16 -7
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +30 -21
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +6 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +4 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +2 -1
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/Observable.d.ts +2 -1
- package/utilities/observables/Observable.d.ts.map +1 -1
- package/utilities/observables/Observable.js +1 -1
- package/utilities/observables/Observable.js.map +1 -1
- package/utilities/observables/asyncMap.d.ts.map +1 -1
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/observables/iteration.d.ts +1 -1
- package/utilities/observables/iteration.d.ts.map +1 -1
- package/utilities/observables/iteration.js.map +1 -1
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/promises/decoration.d.ts +17 -0
- package/utilities/promises/decoration.d.ts.map +1 -0
- package/utilities/promises/decoration.js +37 -0
- package/utilities/promises/decoration.js.map +1 -0
- package/utilities/types/DeepOmit.d.ts +10 -0
- package/utilities/types/DeepOmit.d.ts.map +1 -0
- package/utilities/types/DeepOmit.js +2 -0
- package/utilities/types/DeepOmit.js.map +1 -0
- package/utilities/types/DeepPartial.d.ts +12 -0
- package/utilities/types/DeepPartial.d.ts.map +1 -0
- package/utilities/types/DeepPartial.js +2 -0
- package/utilities/types/DeepPartial.js.map +1 -0
- package/utilities/types/Primitive.d.ts +2 -0
- package/utilities/types/Primitive.d.ts.map +1 -0
- package/utilities/types/Primitive.js +2 -0
- package/utilities/types/Primitive.js.map +1 -0
- package/utilities/utilities.cjs +188 -48
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +188 -48
- package/version.js +1 -1
- package/cache/inmemory/__mocks__/optimism.d.ts +0 -2
- package/cache/inmemory/__mocks__/optimism.d.ts.map +0 -1
- package/cache/inmemory/__mocks__/optimism.js +0 -14
- package/cache/inmemory/__mocks__/optimism.js.map +0 -1
- package/react/hooks/compareResults.d.ts +0 -3
- package/react/hooks/compareResults.d.ts.map +0 -1
- package/react/hooks/compareResults.js.map +0 -1
|
@@ -8,9 +8,12 @@ var context = require('../context');
|
|
|
8
8
|
var tslib = require('tslib');
|
|
9
9
|
var utilities = require('../../utilities');
|
|
10
10
|
var equality = require('@wry/equality');
|
|
11
|
-
var core = require('../../core');
|
|
12
11
|
var errors = require('../../errors');
|
|
12
|
+
var core = require('../../core');
|
|
13
13
|
var parser = require('../parser');
|
|
14
|
+
var cache = require('../../cache');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
14
17
|
|
|
15
18
|
function _interopNamespace(e) {
|
|
16
19
|
if (e && e.__esModule) return e;
|
|
@@ -25,26 +28,25 @@ function _interopNamespace(e) {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
31
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
28
32
|
|
|
29
33
|
function useApolloClient(override) {
|
|
30
34
|
var context$1 = React.useContext(context.getApolloContext());
|
|
31
35
|
var client = override || context$1.client;
|
|
32
|
-
globals.
|
|
33
|
-
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
|
|
34
|
-
'instance in via options.') : globals.invariant(!!client, 32);
|
|
36
|
+
globals.invariant(!!client, 49);
|
|
35
37
|
return client;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
var didWarnUncachedGetSnapshot = false;
|
|
39
41
|
var uSESKey = "useSyncExternalStore";
|
|
40
|
-
var realHook = React__namespace[uSESKey];
|
|
41
|
-
var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
42
|
+
var realHook$1 = React__namespace[uSESKey];
|
|
43
|
+
var useSyncExternalStore = realHook$1 || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
42
44
|
var value = getSnapshot();
|
|
43
45
|
if (globals.__DEV__ &&
|
|
44
46
|
!didWarnUncachedGetSnapshot &&
|
|
45
47
|
value !== getSnapshot()) {
|
|
46
48
|
didWarnUncachedGetSnapshot = true;
|
|
47
|
-
globals.__DEV__ && globals.invariant.error(
|
|
49
|
+
globals.__DEV__ && globals.invariant.error(59);
|
|
48
50
|
}
|
|
49
51
|
var _a = React__namespace.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
|
|
50
52
|
if (utilities.canUseLayoutEffect) {
|
|
@@ -103,8 +105,6 @@ var InternalState = (function () {
|
|
|
103
105
|
function InternalState(client, query, previous) {
|
|
104
106
|
this.client = client;
|
|
105
107
|
this.query = query;
|
|
106
|
-
this.asyncResolveFns = new Set();
|
|
107
|
-
this.optionsToIgnoreOnce = new (utilities.canUseWeakSet ? WeakSet : Set)();
|
|
108
108
|
this.ssrDisabledResult = utilities.maybeDeepFreeze({
|
|
109
109
|
loading: true,
|
|
110
110
|
data: void 0,
|
|
@@ -126,22 +126,32 @@ var InternalState = (function () {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
InternalState.prototype.forceUpdate = function () {
|
|
129
|
-
globals.__DEV__ && globals.invariant.warn(
|
|
129
|
+
globals.__DEV__ && globals.invariant.warn(51);
|
|
130
130
|
};
|
|
131
|
-
InternalState.prototype.
|
|
131
|
+
InternalState.prototype.executeQuery = function (options) {
|
|
132
132
|
var _this = this;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
133
|
+
var _a;
|
|
134
|
+
if (options.query) {
|
|
135
|
+
Object.assign(this, { query: options.query });
|
|
136
|
+
}
|
|
137
|
+
this.watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
138
|
+
var concast = this.observable.reobserveAsConcast(this.getObsQueryOptions());
|
|
139
|
+
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
140
|
+
this.result = void 0;
|
|
141
|
+
this.forceUpdate();
|
|
142
|
+
return new Promise(function (resolve) {
|
|
143
|
+
var result;
|
|
144
|
+
concast.subscribe({
|
|
145
|
+
next: function (value) {
|
|
146
|
+
result = value;
|
|
147
|
+
},
|
|
148
|
+
error: function () {
|
|
149
|
+
resolve(_this.toQueryResult(_this.observable.getCurrentResult()));
|
|
150
|
+
},
|
|
151
|
+
complete: function () {
|
|
152
|
+
resolve(_this.toQueryResult(result));
|
|
153
|
+
}
|
|
154
|
+
});
|
|
145
155
|
});
|
|
146
156
|
};
|
|
147
157
|
InternalState.prototype.useQuery = function (options) {
|
|
@@ -190,29 +200,22 @@ var InternalState = (function () {
|
|
|
190
200
|
}
|
|
191
201
|
};
|
|
192
202
|
var subscription = obsQuery.subscribe(onNext, onError);
|
|
193
|
-
return function () { return subscription.unsubscribe(); };
|
|
203
|
+
return function () { return setTimeout(function () { return subscription.unsubscribe(); }); };
|
|
194
204
|
}, [
|
|
195
205
|
obsQuery,
|
|
196
206
|
this.renderPromises,
|
|
197
207
|
this.client.disableNetworkFetches,
|
|
198
208
|
]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
|
|
199
209
|
this.unsafeHandlePartialRefetch(result);
|
|
200
|
-
|
|
201
|
-
if (!queryResult.loading && this.asyncResolveFns.size) {
|
|
202
|
-
this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
|
|
203
|
-
this.asyncResolveFns.clear();
|
|
204
|
-
}
|
|
205
|
-
return queryResult;
|
|
210
|
+
return this.toQueryResult(result);
|
|
206
211
|
};
|
|
207
212
|
InternalState.prototype.useOptions = function (options) {
|
|
208
213
|
var _a;
|
|
209
214
|
var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
210
215
|
var currentWatchQueryOptions = this.watchQueryOptions;
|
|
211
|
-
if (
|
|
212
|
-
!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
216
|
+
if (!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
213
217
|
this.watchQueryOptions = watchQueryOptions;
|
|
214
218
|
if (currentWatchQueryOptions && this.observable) {
|
|
215
|
-
this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
|
|
216
219
|
this.observable.reobserve(this.getObsQueryOptions());
|
|
217
220
|
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
218
221
|
this.result = void 0;
|
|
@@ -243,7 +246,7 @@ var InternalState = (function () {
|
|
|
243
246
|
toMerge.push(this.queryHookOptions.defaultOptions);
|
|
244
247
|
}
|
|
245
248
|
toMerge.push(utilities.compact(this.observable && this.observable.options, this.watchQueryOptions));
|
|
246
|
-
return toMerge.reduce(
|
|
249
|
+
return toMerge.reduce(utilities.mergeOptions);
|
|
247
250
|
};
|
|
248
251
|
InternalState.prototype.createWatchQueryOptions = function (_a) {
|
|
249
252
|
var _b;
|
|
@@ -379,11 +382,15 @@ var EAGER_METHODS = [
|
|
|
379
382
|
'subscribeToMore',
|
|
380
383
|
];
|
|
381
384
|
function useLazyQuery(query, options) {
|
|
382
|
-
var _a
|
|
383
|
-
var abortControllersRef = React.useRef(new Set());
|
|
385
|
+
var _a;
|
|
384
386
|
var execOptionsRef = React.useRef();
|
|
385
|
-
var
|
|
386
|
-
var
|
|
387
|
+
var optionsRef = React.useRef();
|
|
388
|
+
var queryRef = React.useRef();
|
|
389
|
+
var merged = utilities.mergeOptions(options, execOptionsRef.current || {});
|
|
390
|
+
var document = (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query;
|
|
391
|
+
optionsRef.current = merged;
|
|
392
|
+
queryRef.current = document;
|
|
393
|
+
var internalState = useInternalState(useApolloClient(options && options.client), document);
|
|
387
394
|
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
388
395
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
389
396
|
internalState.getDefaultFetchPolicy();
|
|
@@ -409,28 +416,15 @@ function useLazyQuery(query, options) {
|
|
|
409
416
|
return eagerMethods;
|
|
410
417
|
}, []);
|
|
411
418
|
Object.assign(result, eagerMethods);
|
|
412
|
-
React.useEffect(function () {
|
|
413
|
-
return function () {
|
|
414
|
-
abortControllersRef.current.forEach(function (controller) {
|
|
415
|
-
controller.abort();
|
|
416
|
-
});
|
|
417
|
-
};
|
|
418
|
-
}, []);
|
|
419
419
|
var execute = React.useCallback(function (executeOptions) {
|
|
420
|
-
var controller = new AbortController();
|
|
421
|
-
abortControllersRef.current.add(controller);
|
|
422
420
|
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
423
421
|
fetchPolicy: initialFetchPolicy,
|
|
424
422
|
};
|
|
423
|
+
var options = utilities.mergeOptions(optionsRef.current, tslib.__assign({ query: queryRef.current }, execOptionsRef.current));
|
|
425
424
|
var promise = internalState
|
|
426
|
-
.
|
|
427
|
-
.then(function (queryResult) {
|
|
428
|
-
|
|
429
|
-
return Object.assign(queryResult, eagerMethods);
|
|
430
|
-
});
|
|
431
|
-
promise.catch(function () {
|
|
432
|
-
abortControllersRef.current.delete(controller);
|
|
433
|
-
});
|
|
425
|
+
.executeQuery(tslib.__assign(tslib.__assign({}, options), { skip: false }))
|
|
426
|
+
.then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
427
|
+
promise.catch(function () { });
|
|
434
428
|
return promise;
|
|
435
429
|
}, []);
|
|
436
430
|
return [execute, result];
|
|
@@ -457,8 +451,9 @@ function useMutation(mutation, options) {
|
|
|
457
451
|
}
|
|
458
452
|
var execute = React.useCallback(function (executeOptions) {
|
|
459
453
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
460
|
-
var _a = ref.current,
|
|
454
|
+
var _a = ref.current, options = _a.options, mutation = _a.mutation;
|
|
461
455
|
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
456
|
+
var client = executeOptions.client || ref.current.client;
|
|
462
457
|
if (!ref.current.result.loading && !baseOptions.ignoreResults && ref.current.isMounted) {
|
|
463
458
|
setResult(ref.current.result = {
|
|
464
459
|
loading: true,
|
|
@@ -469,7 +464,7 @@ function useMutation(mutation, options) {
|
|
|
469
464
|
});
|
|
470
465
|
}
|
|
471
466
|
var mutationId = ++ref.current.mutationId;
|
|
472
|
-
var clientOptions =
|
|
467
|
+
var clientOptions = utilities.mergeOptions(baseOptions, executeOptions);
|
|
473
468
|
return client.mutate(clientOptions).then(function (response) {
|
|
474
469
|
var _a;
|
|
475
470
|
var data = response.data, errors$1 = response.errors;
|
|
@@ -542,14 +537,10 @@ function useSubscription(subscription, options) {
|
|
|
542
537
|
if (!hasIssuedDeprecationWarningRef.current) {
|
|
543
538
|
hasIssuedDeprecationWarningRef.current = true;
|
|
544
539
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionData) {
|
|
545
|
-
globals.__DEV__ && globals.invariant.warn(options.onData
|
|
546
|
-
? "'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used."
|
|
547
|
-
: "'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead.");
|
|
540
|
+
globals.__DEV__ && globals.invariant.warn(options.onData ? 52 : 53);
|
|
548
541
|
}
|
|
549
542
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionComplete) {
|
|
550
|
-
globals.__DEV__ && globals.invariant.warn(options.onComplete
|
|
551
|
-
? "'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used."
|
|
552
|
-
: "'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead.");
|
|
543
|
+
globals.__DEV__ && globals.invariant.warn(options.onComplete ? 54 : 55);
|
|
553
544
|
}
|
|
554
545
|
}
|
|
555
546
|
var _b = React.useState(function () {
|
|
@@ -615,9 +606,13 @@ function useSubscription(subscription, options) {
|
|
|
615
606
|
if (!observable) {
|
|
616
607
|
return;
|
|
617
608
|
}
|
|
609
|
+
var subscriptionStopped = false;
|
|
618
610
|
var subscription = observable.subscribe({
|
|
619
611
|
next: function (fetchResult) {
|
|
620
612
|
var _a, _b;
|
|
613
|
+
if (subscriptionStopped) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
621
616
|
var result = {
|
|
622
617
|
loading: false,
|
|
623
618
|
data: fetchResult.data,
|
|
@@ -640,26 +635,33 @@ function useSubscription(subscription, options) {
|
|
|
640
635
|
},
|
|
641
636
|
error: function (error) {
|
|
642
637
|
var _a, _b;
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
638
|
+
if (!subscriptionStopped) {
|
|
639
|
+
setResult({
|
|
640
|
+
loading: false,
|
|
641
|
+
data: void 0,
|
|
642
|
+
error: error,
|
|
643
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
644
|
+
});
|
|
645
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
646
|
+
}
|
|
650
647
|
},
|
|
651
648
|
complete: function () {
|
|
652
649
|
var _a, _b;
|
|
653
|
-
if (
|
|
654
|
-
ref.current.options.onComplete
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
ref.current.options.onSubscriptionComplete
|
|
650
|
+
if (!subscriptionStopped) {
|
|
651
|
+
if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
|
|
652
|
+
ref.current.options.onComplete();
|
|
653
|
+
}
|
|
654
|
+
else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
|
|
655
|
+
ref.current.options.onSubscriptionComplete();
|
|
656
|
+
}
|
|
658
657
|
}
|
|
659
658
|
},
|
|
660
659
|
});
|
|
661
660
|
return function () {
|
|
662
|
-
|
|
661
|
+
subscriptionStopped = true;
|
|
662
|
+
setTimeout(function () {
|
|
663
|
+
subscription.unsubscribe();
|
|
664
|
+
});
|
|
663
665
|
};
|
|
664
666
|
}, [observable]);
|
|
665
667
|
return result;
|
|
@@ -680,10 +682,10 @@ function useReactiveVar(rv) {
|
|
|
680
682
|
return value;
|
|
681
683
|
}
|
|
682
684
|
|
|
683
|
-
function
|
|
685
|
+
function useFragment(options) {
|
|
684
686
|
var cache = useApolloClient().cache;
|
|
685
687
|
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
686
|
-
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
688
|
+
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
687
689
|
var resultRef = React.useRef();
|
|
688
690
|
var latestDiff = cache.diff(diffOptions);
|
|
689
691
|
var getSnapshot = function () {
|
|
@@ -721,116 +723,110 @@ function useDeepMemo(memoFn, deps) {
|
|
|
721
723
|
return ref.current.value;
|
|
722
724
|
}
|
|
723
725
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
726
|
+
function useStrictModeSafeCleanupEffect(cleanup) {
|
|
727
|
+
var timeout;
|
|
728
|
+
React.useEffect(function () {
|
|
729
|
+
clearTimeout(timeout);
|
|
730
|
+
return function () {
|
|
731
|
+
timeout = setTimeout(cleanup);
|
|
732
|
+
};
|
|
733
|
+
}, []);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
var useKey = 'use';
|
|
737
|
+
var realHook = React__default[useKey];
|
|
738
|
+
var __use = realHook ||
|
|
739
|
+
function __use(promise) {
|
|
740
|
+
var statefulPromise = utilities.wrapPromiseWithState(promise);
|
|
741
|
+
switch (statefulPromise.status) {
|
|
742
|
+
case 'pending':
|
|
743
|
+
throw statefulPromise;
|
|
744
|
+
case 'rejected':
|
|
745
|
+
throw statefulPromise.reason;
|
|
746
|
+
case 'fulfilled':
|
|
747
|
+
return statefulPromise.value;
|
|
748
|
+
}
|
|
749
|
+
};
|
|
727
750
|
|
|
728
751
|
function useSuspenseCache(override) {
|
|
729
752
|
var context$1 = React.useContext(context.getApolloContext());
|
|
730
753
|
var suspenseCache = override || context$1.suspenseCache;
|
|
731
|
-
globals.
|
|
732
|
-
'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +
|
|
733
|
-
'or pass a SuspenseCache instance in via options.') : globals.invariant(suspenseCache, 33);
|
|
754
|
+
globals.invariant(suspenseCache, 56);
|
|
734
755
|
return suspenseCache;
|
|
735
756
|
}
|
|
736
757
|
|
|
737
|
-
|
|
738
|
-
'cache-first',
|
|
739
|
-
'network-only',
|
|
740
|
-
'no-cache',
|
|
741
|
-
'cache-and-network',
|
|
742
|
-
];
|
|
743
|
-
var DEFAULT_FETCH_POLICY = 'cache-first';
|
|
744
|
-
var DEFAULT_SUSPENSE_POLICY = 'always';
|
|
745
|
-
var DEFAULT_ERROR_POLICY = 'none';
|
|
746
|
-
function useSuspenseQuery_experimental(query, options) {
|
|
758
|
+
function useSuspenseQuery(query, options) {
|
|
747
759
|
if (options === void 0) { options = Object.create(null); }
|
|
748
|
-
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
749
760
|
var client = useApolloClient(options.client);
|
|
750
|
-
var
|
|
751
|
-
var
|
|
752
|
-
var
|
|
753
|
-
var
|
|
754
|
-
var
|
|
755
|
-
var
|
|
756
|
-
return
|
|
757
|
-
})
|
|
758
|
-
var
|
|
759
|
-
var
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
if (result.error &&
|
|
764
|
-
(result.error.networkError || allowsThrownErrors)) {
|
|
765
|
-
throw result.error;
|
|
766
|
-
}
|
|
767
|
-
if (result.loading) {
|
|
768
|
-
if (!cacheEntry) {
|
|
769
|
-
cacheEntry = suspenseCache.add(query, variables, {
|
|
770
|
-
promise: maybeWrapConcastWithCustomPromise(observable.reobserveAsConcast(watchQueryOptions), { deferred: deferred }),
|
|
771
|
-
observable: observable,
|
|
772
|
-
});
|
|
773
|
-
}
|
|
774
|
-
var hasUsableResult = usePartialResult ||
|
|
775
|
-
(fetchPolicy === 'cache-and-network' && hasFullResult);
|
|
776
|
-
if (!hasUsableResult && !cacheEntry.fulfilled) {
|
|
777
|
-
throw cacheEntry.promise;
|
|
778
|
-
}
|
|
761
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
762
|
+
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
763
|
+
var variables = watchQueryOptions.variables;
|
|
764
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
765
|
+
var cacheKey = [client, query, cache.canonicalStringify(variables)].concat(queryKey);
|
|
766
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
767
|
+
return client.watchQuery(watchQueryOptions);
|
|
768
|
+
});
|
|
769
|
+
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
770
|
+
var promise = promiseCache.get(queryRef.key);
|
|
771
|
+
if (!promise) {
|
|
772
|
+
promise = queryRef.promise;
|
|
773
|
+
promiseCache.set(queryRef.key, promise);
|
|
779
774
|
}
|
|
775
|
+
useTrackedQueryRefs(queryRef);
|
|
780
776
|
React.useEffect(function () {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
suspenseCache.remove(previousOpts.query, previousOpts.variables);
|
|
785
|
-
suspenseCache.add(query, variables, {
|
|
786
|
-
promise: observable.reobserve({ query: query, variables: variables }),
|
|
787
|
-
observable: observable,
|
|
777
|
+
return queryRef.listen(function (promise) {
|
|
778
|
+
setPromiseCache(function (promiseCache) {
|
|
779
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
788
780
|
});
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
React.
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
781
|
+
});
|
|
782
|
+
}, [queryRef]);
|
|
783
|
+
var result = __use(promise);
|
|
784
|
+
var fetchMore = React.useCallback(function (options) {
|
|
785
|
+
var promise = queryRef.fetchMore(options);
|
|
786
|
+
setPromiseCache(function (previousPromiseCache) {
|
|
787
|
+
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
788
|
+
});
|
|
789
|
+
return promise;
|
|
790
|
+
}, [queryRef]);
|
|
791
|
+
var refetch = React.useCallback(function (variables) {
|
|
792
|
+
var promise = queryRef.refetch(variables);
|
|
793
|
+
setPromiseCache(function (previousPromiseCache) {
|
|
794
|
+
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
795
|
+
});
|
|
796
|
+
return promise;
|
|
797
|
+
}, [queryRef]);
|
|
798
|
+
var subscribeToMore = React.useCallback(function (options) { return queryRef.observable.subscribeToMore(options); }, [queryRef]);
|
|
797
799
|
return React.useMemo(function () {
|
|
798
800
|
return {
|
|
799
801
|
client: client,
|
|
800
802
|
data: result.data,
|
|
801
|
-
error:
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
observable: observable,
|
|
807
|
-
});
|
|
808
|
-
return promise;
|
|
809
|
-
},
|
|
810
|
-
refetch: function (variables) {
|
|
811
|
-
var promise = observable.refetch(variables);
|
|
812
|
-
suspenseCache.add(query, watchQueryOptions.variables, {
|
|
813
|
-
promise: promise,
|
|
814
|
-
observable: observable,
|
|
815
|
-
});
|
|
816
|
-
return promise;
|
|
817
|
-
},
|
|
818
|
-
subscribeToMore: function (options) { return observable.subscribeToMore(options); },
|
|
803
|
+
error: toApolloError(result),
|
|
804
|
+
networkStatus: result.networkStatus,
|
|
805
|
+
fetchMore: fetchMore,
|
|
806
|
+
refetch: refetch,
|
|
807
|
+
subscribeToMore: subscribeToMore,
|
|
819
808
|
};
|
|
820
|
-
}, [client,
|
|
809
|
+
}, [client, fetchMore, refetch, result, subscribeToMore]);
|
|
821
810
|
}
|
|
822
811
|
function validateOptions(options) {
|
|
823
|
-
var query = options.query,
|
|
812
|
+
var query = options.query, fetchPolicy = options.fetchPolicy, returnPartialData = options.returnPartialData;
|
|
824
813
|
parser.verifyDocumentType(query, parser.DocumentType.Query);
|
|
825
814
|
validateFetchPolicy(fetchPolicy);
|
|
826
815
|
validatePartialDataReturn(fetchPolicy, returnPartialData);
|
|
827
816
|
}
|
|
828
817
|
function validateFetchPolicy(fetchPolicy) {
|
|
829
|
-
|
|
818
|
+
if (fetchPolicy === void 0) { fetchPolicy = 'cache-first'; }
|
|
819
|
+
var supportedFetchPolicies = [
|
|
820
|
+
'cache-first',
|
|
821
|
+
'network-only',
|
|
822
|
+
'no-cache',
|
|
823
|
+
'cache-and-network',
|
|
824
|
+
];
|
|
825
|
+
globals.invariant(supportedFetchPolicies.includes(fetchPolicy), 57, fetchPolicy);
|
|
830
826
|
}
|
|
831
827
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
832
828
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
833
|
-
globals.__DEV__ && globals.invariant.warn(
|
|
829
|
+
globals.__DEV__ && globals.invariant.warn(58);
|
|
834
830
|
}
|
|
835
831
|
}
|
|
836
832
|
function toApolloError(result) {
|
|
@@ -838,78 +834,92 @@ function toApolloError(result) {
|
|
|
838
834
|
? new core.ApolloError({ graphQLErrors: result.errors })
|
|
839
835
|
: result.error;
|
|
840
836
|
}
|
|
841
|
-
function
|
|
842
|
-
var
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
resolve(value);
|
|
848
|
-
subscription.unsubscribe();
|
|
849
|
-
},
|
|
850
|
-
error: reject,
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
return concast.promise;
|
|
837
|
+
function useTrackedQueryRefs(queryRef) {
|
|
838
|
+
var trackedQueryRefs = React.useRef(new Set());
|
|
839
|
+
trackedQueryRefs.current.add(queryRef);
|
|
840
|
+
useStrictModeSafeCleanupEffect(function () {
|
|
841
|
+
trackedQueryRefs.current.forEach(function (sub) { return sub.dispose(); });
|
|
842
|
+
});
|
|
855
843
|
}
|
|
856
844
|
function useWatchQueryOptions(_a) {
|
|
857
|
-
var query = _a.query, options = _a.options
|
|
858
|
-
var
|
|
859
|
-
var watchQueryOptions = useDeepMemo(function () {
|
|
860
|
-
var errorPolicy = options.errorPolicy, fetchPolicy = options.fetchPolicy, _a = options.suspensePolicy, suspensePolicy = _a === void 0 ? DEFAULT_SUSPENSE_POLICY : _a, variables = options.variables, watchQueryOptions = tslib.__rest(options, ["errorPolicy", "fetchPolicy", "suspensePolicy", "variables"]);
|
|
861
|
-
return tslib.__assign(tslib.__assign({}, watchQueryOptions), { query: query, errorPolicy: errorPolicy || (defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.errorPolicy) || DEFAULT_ERROR_POLICY, fetchPolicy: fetchPolicy || (defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.fetchPolicy) || DEFAULT_FETCH_POLICY, notifyOnNetworkStatusChange: suspensePolicy === 'always', fetchOnFirstSubscribe: false, variables: utilities.compact(tslib.__assign(tslib.__assign({}, defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.variables), variables)) });
|
|
862
|
-
}, [options, query, defaultOptions]);
|
|
845
|
+
var query = _a.query, options = _a.options;
|
|
846
|
+
var watchQueryOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, options), { query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 })); }, [options, query]);
|
|
863
847
|
if (globals.__DEV__) {
|
|
864
848
|
validateOptions(watchQueryOptions);
|
|
865
849
|
}
|
|
866
850
|
return watchQueryOptions;
|
|
867
851
|
}
|
|
868
|
-
|
|
869
|
-
|
|
852
|
+
|
|
853
|
+
function useBackgroundQuery(query, options) {
|
|
854
|
+
if (options === void 0) { options = Object.create(null); }
|
|
855
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
856
|
+
var client = useApolloClient(options.client);
|
|
857
|
+
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
858
|
+
var variables = watchQueryOptions.variables;
|
|
859
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
860
|
+
var cacheKey = [client, query, cache.canonicalStringify(variables)].concat(queryKey);
|
|
861
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
862
|
+
return client.watchQuery(watchQueryOptions);
|
|
863
|
+
});
|
|
864
|
+
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
865
|
+
useTrackedQueryRefs(queryRef);
|
|
866
|
+
var fetchMore = React.useCallback(function (options) {
|
|
867
|
+
var promise = queryRef.fetchMore(options);
|
|
868
|
+
setPromiseCache(function (promiseCache) {
|
|
869
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
870
|
+
});
|
|
871
|
+
return promise;
|
|
872
|
+
}, [queryRef]);
|
|
873
|
+
var refetch = React.useCallback(function (variables) {
|
|
874
|
+
var promise = queryRef.refetch(variables);
|
|
875
|
+
setPromiseCache(function (promiseCache) {
|
|
876
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
877
|
+
});
|
|
878
|
+
return promise;
|
|
879
|
+
}, [queryRef]);
|
|
880
|
+
queryRef.promiseCache = promiseCache;
|
|
881
|
+
return React.useMemo(function () {
|
|
882
|
+
return [
|
|
883
|
+
queryRef,
|
|
884
|
+
{
|
|
885
|
+
fetchMore: fetchMore,
|
|
886
|
+
refetch: refetch,
|
|
887
|
+
},
|
|
888
|
+
];
|
|
889
|
+
}, [queryRef, fetchMore, refetch]);
|
|
870
890
|
}
|
|
871
|
-
function
|
|
872
|
-
var
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
891
|
+
function useReadQuery(queryRef) {
|
|
892
|
+
var _a = React.useState(0), forceUpdate = _a[1];
|
|
893
|
+
globals.invariant(queryRef.promiseCache, 50);
|
|
894
|
+
var promise = queryRef.promiseCache.get(queryRef.key);
|
|
895
|
+
if (!promise) {
|
|
896
|
+
promise = queryRef.promise;
|
|
897
|
+
queryRef.promiseCache.set(queryRef.key, promise);
|
|
876
898
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
};
|
|
882
|
-
}, []);
|
|
883
|
-
return useSyncExternalStore(React.useCallback(function (forceUpdate) {
|
|
884
|
-
function handleUpdate() {
|
|
885
|
-
var previousResult = resultRef.current;
|
|
886
|
-
var result = observable.getCurrentResult();
|
|
887
|
-
if (previousResult.loading === result.loading &&
|
|
888
|
-
previousResult.networkStatus === result.networkStatus &&
|
|
889
|
-
equality.equal(previousResult.data, result.data)) {
|
|
890
|
-
return;
|
|
891
|
-
}
|
|
892
|
-
resultRef.current = result;
|
|
893
|
-
if (isMountedRef.current) {
|
|
894
|
-
forceUpdate();
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
var subscription = observable.subscribe({
|
|
898
|
-
next: handleUpdate,
|
|
899
|
-
error: handleUpdate,
|
|
899
|
+
React.useEffect(function () {
|
|
900
|
+
return queryRef.listen(function (promise) {
|
|
901
|
+
queryRef.promiseCache.set(queryRef.key, promise);
|
|
902
|
+
forceUpdate(function (prevState) { return prevState + 1; });
|
|
900
903
|
});
|
|
901
|
-
|
|
902
|
-
|
|
904
|
+
}, [queryRef]);
|
|
905
|
+
var result = __use(promise);
|
|
906
|
+
return React.useMemo(function () {
|
|
907
|
+
return {
|
|
908
|
+
data: result.data,
|
|
909
|
+
networkStatus: result.networkStatus,
|
|
910
|
+
error: toApolloError(result),
|
|
903
911
|
};
|
|
904
|
-
}, [
|
|
912
|
+
}, [result]);
|
|
905
913
|
}
|
|
906
914
|
|
|
907
915
|
exports.useApolloClient = useApolloClient;
|
|
908
|
-
exports.
|
|
916
|
+
exports.useBackgroundQuery = useBackgroundQuery;
|
|
917
|
+
exports.useFragment = useFragment;
|
|
909
918
|
exports.useLazyQuery = useLazyQuery;
|
|
910
919
|
exports.useMutation = useMutation;
|
|
911
920
|
exports.useQuery = useQuery;
|
|
912
921
|
exports.useReactiveVar = useReactiveVar;
|
|
922
|
+
exports.useReadQuery = useReadQuery;
|
|
913
923
|
exports.useSubscription = useSubscription;
|
|
914
|
-
exports.
|
|
924
|
+
exports.useSuspenseQuery = useSuspenseQuery;
|
|
915
925
|
//# sourceMappingURL=hooks.cjs.map
|
package/react/hooks/index.d.ts
CHANGED
|
@@ -6,5 +6,6 @@ export { useQuery } from './useQuery';
|
|
|
6
6
|
export * from './useSubscription';
|
|
7
7
|
export * from './useReactiveVar';
|
|
8
8
|
export * from './useFragment';
|
|
9
|
-
export
|
|
9
|
+
export { useSuspenseQuery, UseSuspenseQueryResult, FetchMoreFunction, RefetchFunction, SubscribeToMoreFunction, } from './useSuspenseQuery';
|
|
10
|
+
export { useBackgroundQuery, useReadQuery, UseBackgroundQueryResult, } from './useBackgroundQuery';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|