@apollo/client 3.8.0-alpha.12 → 3.8.0-alpha.14
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 +272 -215
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +1 -1
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +1 -1
- package/cache/core/cache.d.ts +4 -4
- package/cache/core/cache.d.ts.map +1 -1
- 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 +4 -4
- 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.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 +5 -5
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- 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.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 +1 -1
- 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 +2 -2
- 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.map +1 -1
- package/core/ApolloClient.d.ts +10 -9
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +6 -6
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +1 -1
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +9 -8
- package/core/ObservableQuery.d.ts.map +1 -1
- 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 +6 -6
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +1 -1
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +1 -1
- package/core/equalByQuery.d.ts +2 -2
- package/core/equalByQuery.d.ts.map +1 -1
- package/core/equalByQuery.js.map +1 -1
- package/core/types.d.ts +11 -11
- package/core/types.d.ts.map +1 -1
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +6 -6
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/errors/index.d.ts +4 -4
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +41 -29
- 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/batchHttpLink.d.ts +3 -2
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- 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.map +1 -1
- package/link/core/types.d.ts +4 -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/createHttpLink.d.ts +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +1 -1
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +1 -1
- 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.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 +1 -2
- 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/persisted-queries/index.d.ts +4 -3
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +12 -13
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +12 -13
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +12 -13
- 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 +70 -0
- package/link/remove-typename/remove-typename.cjs.map +1 -0
- package/link/remove-typename/remove-typename.cjs.native.js +70 -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 +62 -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 +2 -2
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +1 -1
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +1 -1
- 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 +1 -1
- package/link/utils/filterOperationVariables.d.ts.map +1 -1
- package/link/utils/filterOperationVariables.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.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/validateOperation.d.ts +1 -1
- package/link/utils/validateOperation.d.ts.map +1 -1
- 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 +26 -22
- package/react/cache/{QuerySubscription.d.ts → QueryReference.d.ts} +15 -7
- 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 +5 -5
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js +8 -7
- 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 +1 -1
- 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 +13 -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 -12
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/context/context.cjs +22 -21
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +22 -21
- 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.map +1 -1
- 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.map +1 -1
- package/react/hooks/hooks.cjs +133 -69
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +133 -69
- 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/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/useApolloClient.d.ts +1 -1
- package/react/hooks/useApolloClient.d.ts.map +1 -1
- 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 +71 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -0
- package/react/hooks/useFragment.d.ts +13 -8
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js +1 -1
- 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.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 +1 -1
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +3 -3
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +2 -2
- 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 +25 -13
- 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 +1 -1
- package/react/hooks/useSuspenseCache.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +29 -7
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +44 -59
- package/react/hooks/useSuspenseQuery.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 +5 -5
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/react/react.cjs +73 -51
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +73 -51
- 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 +9 -11
- 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/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 +2 -2
- 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 +2 -1
- 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/react/MockedProvider.d.ts +7 -6
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js.map +1 -1
- 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 +1 -1
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/omitDeep.d.ts +10 -2
- package/utilities/common/omitDeep.d.ts.map +1 -1
- package/utilities/common/omitDeep.js +22 -10
- package/utilities/common/omitDeep.js.map +1 -1
- 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/stripTypename.d.ts +9 -1
- package/utilities/common/stripTypename.d.ts.map +1 -1
- package/utilities/common/stripTypename.js +3 -2
- package/utilities/common/stripTypename.js.map +1 -1
- 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/graphql/directives.d.ts +1 -1
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +4 -4
- 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 +3 -3
- 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 +8 -8
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +2 -2
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +14 -4
- 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 +2 -2
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +3 -2
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -1
- 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 +2 -0
- package/utilities/promises/decoration.d.ts.map +1 -1
- package/utilities/promises/decoration.js +12 -0
- package/utilities/promises/decoration.js.map +1 -1
- package/utilities/types/DeepOmit.d.ts +4 -3
- package/utilities/types/DeepOmit.d.ts.map +1 -1
- package/utilities/types/DeepOmit.js.map +1 -1
- 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 +68 -31
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +68 -31
- package/version.js +1 -1
- package/react/cache/QuerySubscription.d.ts.map +0 -1
- package/react/cache/QuerySubscription.js +0 -88
- package/react/cache/QuerySubscription.js.map +0 -1
|
@@ -8,8 +8,8 @@ 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
14
|
var cache = require('../../cache');
|
|
15
15
|
|
|
@@ -248,7 +248,7 @@ var InternalState = (function () {
|
|
|
248
248
|
toMerge.push(this.queryHookOptions.defaultOptions);
|
|
249
249
|
}
|
|
250
250
|
toMerge.push(utilities.compact(this.observable && this.observable.options, this.watchQueryOptions));
|
|
251
|
-
return toMerge.reduce(
|
|
251
|
+
return toMerge.reduce(utilities.mergeOptions);
|
|
252
252
|
};
|
|
253
253
|
InternalState.prototype.createWatchQueryOptions = function (_a) {
|
|
254
254
|
var _b;
|
|
@@ -466,7 +466,7 @@ function useMutation(mutation, options) {
|
|
|
466
466
|
});
|
|
467
467
|
}
|
|
468
468
|
var mutationId = ++ref.current.mutationId;
|
|
469
|
-
var clientOptions =
|
|
469
|
+
var clientOptions = utilities.mergeOptions(baseOptions, executeOptions);
|
|
470
470
|
return client.mutate(clientOptions).then(function (response) {
|
|
471
471
|
var _a;
|
|
472
472
|
var data = response.data, errors$1 = response.errors;
|
|
@@ -612,9 +612,13 @@ function useSubscription(subscription, options) {
|
|
|
612
612
|
if (!observable) {
|
|
613
613
|
return;
|
|
614
614
|
}
|
|
615
|
+
var subscriptionStopped = false;
|
|
615
616
|
var subscription = observable.subscribe({
|
|
616
617
|
next: function (fetchResult) {
|
|
617
618
|
var _a, _b;
|
|
619
|
+
if (subscriptionStopped) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
618
622
|
var result = {
|
|
619
623
|
loading: false,
|
|
620
624
|
data: fetchResult.data,
|
|
@@ -637,26 +641,33 @@ function useSubscription(subscription, options) {
|
|
|
637
641
|
},
|
|
638
642
|
error: function (error) {
|
|
639
643
|
var _a, _b;
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
644
|
+
if (!subscriptionStopped) {
|
|
645
|
+
setResult({
|
|
646
|
+
loading: false,
|
|
647
|
+
data: void 0,
|
|
648
|
+
error: error,
|
|
649
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
650
|
+
});
|
|
651
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
652
|
+
}
|
|
647
653
|
},
|
|
648
654
|
complete: function () {
|
|
649
655
|
var _a, _b;
|
|
650
|
-
if (
|
|
651
|
-
ref.current.options.onComplete
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
ref.current.options.onSubscriptionComplete
|
|
656
|
+
if (!subscriptionStopped) {
|
|
657
|
+
if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
|
|
658
|
+
ref.current.options.onComplete();
|
|
659
|
+
}
|
|
660
|
+
else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
|
|
661
|
+
ref.current.options.onSubscriptionComplete();
|
|
662
|
+
}
|
|
655
663
|
}
|
|
656
664
|
},
|
|
657
665
|
});
|
|
658
666
|
return function () {
|
|
659
|
-
|
|
667
|
+
subscriptionStopped = true;
|
|
668
|
+
setTimeout(function () {
|
|
669
|
+
subscription.unsubscribe();
|
|
670
|
+
});
|
|
660
671
|
};
|
|
661
672
|
}, [observable]);
|
|
662
673
|
return result;
|
|
@@ -680,7 +691,7 @@ function useReactiveVar(rv) {
|
|
|
680
691
|
function useFragment_experimental(options) {
|
|
681
692
|
var cache = useApolloClient().cache;
|
|
682
693
|
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"]);
|
|
683
|
-
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
694
|
+
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
684
695
|
var resultRef = React.useRef();
|
|
685
696
|
var latestDiff = cache.diff(diffOptions);
|
|
686
697
|
var getSnapshot = function () {
|
|
@@ -748,47 +759,51 @@ function useSuspenseCache(override) {
|
|
|
748
759
|
var suspenseCache = override || context$1.suspenseCache;
|
|
749
760
|
globals.__DEV__ ? globals.invariant(suspenseCache, 'Could not find a "suspenseCache" in the context or passed in as an option. ' +
|
|
750
761
|
'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +
|
|
751
|
-
'or pass a SuspenseCache instance in via options.') : globals.invariant(suspenseCache,
|
|
762
|
+
'or pass a SuspenseCache instance in via options.') : globals.invariant(suspenseCache, 35);
|
|
752
763
|
return suspenseCache;
|
|
753
764
|
}
|
|
754
765
|
|
|
755
766
|
function useSuspenseQuery_experimental(query, options) {
|
|
756
767
|
if (options === void 0) { options = Object.create(null); }
|
|
757
|
-
var didPreviouslySuspend = React.useRef(false);
|
|
758
768
|
var client = useApolloClient(options.client);
|
|
759
769
|
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
760
770
|
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
761
|
-
var
|
|
762
|
-
var
|
|
763
|
-
var shouldSuspend = suspensePolicy === 'always' || !didPreviouslySuspend.current;
|
|
771
|
+
var variables = watchQueryOptions.variables;
|
|
772
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
764
773
|
var cacheKey = [client, query, cache.canonicalStringify(variables)].concat(queryKey);
|
|
765
|
-
var
|
|
774
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
766
775
|
return client.watchQuery(watchQueryOptions);
|
|
767
776
|
});
|
|
768
|
-
var
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
if (!equality.equal(variables, previousVariables.current)) {
|
|
774
|
-
if (result.networkStatus !== core.NetworkStatus.ready) {
|
|
775
|
-
result = tslib.__assign(tslib.__assign({}, result), { data: previousData.current, networkStatus: core.NetworkStatus.setVariables });
|
|
776
|
-
}
|
|
777
|
-
previousVariables.current = variables;
|
|
778
|
-
previousData.current = result.data;
|
|
777
|
+
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
778
|
+
var promise = promiseCache.get(queryRef.key);
|
|
779
|
+
if (!promise) {
|
|
780
|
+
promise = queryRef.promise;
|
|
781
|
+
promiseCache.set(queryRef.key, promise);
|
|
779
782
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
})
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
|
|
789
|
-
var fetchMore = React.useCallback(function (options) {
|
|
790
|
-
|
|
791
|
-
|
|
783
|
+
useTrackedQueryRefs(queryRef);
|
|
784
|
+
React.useEffect(function () {
|
|
785
|
+
return queryRef.listen(function (promise) {
|
|
786
|
+
setPromiseCache(function (promiseCache) {
|
|
787
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
788
|
+
});
|
|
789
|
+
});
|
|
790
|
+
}, [queryRef]);
|
|
791
|
+
var result = __use(promise);
|
|
792
|
+
var fetchMore = React.useCallback(function (options) {
|
|
793
|
+
var promise = queryRef.fetchMore(options);
|
|
794
|
+
setPromiseCache(function (previousPromiseCache) {
|
|
795
|
+
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
796
|
+
});
|
|
797
|
+
return promise;
|
|
798
|
+
}, [queryRef]);
|
|
799
|
+
var refetch = React.useCallback(function (variables) {
|
|
800
|
+
var promise = queryRef.refetch(variables);
|
|
801
|
+
setPromiseCache(function (previousPromiseCache) {
|
|
802
|
+
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
803
|
+
});
|
|
804
|
+
return promise;
|
|
805
|
+
}, [queryRef]);
|
|
806
|
+
var subscribeToMore = React.useCallback(function (options) { return queryRef.observable.subscribeToMore(options); }, [queryRef]);
|
|
792
807
|
return React.useMemo(function () {
|
|
793
808
|
return {
|
|
794
809
|
client: client,
|
|
@@ -815,7 +830,7 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
815
830
|
'no-cache',
|
|
816
831
|
'cache-and-network',
|
|
817
832
|
];
|
|
818
|
-
globals.__DEV__ ? globals.invariant(supportedFetchPolicies.includes(fetchPolicy), "The fetch policy `".concat(fetchPolicy, "` is not supported with suspense.")) : globals.invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
833
|
+
globals.__DEV__ ? globals.invariant(supportedFetchPolicies.includes(fetchPolicy), "The fetch policy `".concat(fetchPolicy, "` is not supported with suspense.")) : globals.invariant(supportedFetchPolicies.includes(fetchPolicy), 36);
|
|
819
834
|
}
|
|
820
835
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
821
836
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
@@ -827,45 +842,94 @@ function toApolloError(result) {
|
|
|
827
842
|
? new core.ApolloError({ graphQLErrors: result.errors })
|
|
828
843
|
: result.error;
|
|
829
844
|
}
|
|
830
|
-
function
|
|
831
|
-
var
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
};
|
|
845
|
+
function useTrackedQueryRefs(queryRef) {
|
|
846
|
+
var trackedQueryRefs = React.useRef(new Set());
|
|
847
|
+
trackedQueryRefs.current.add(queryRef);
|
|
848
|
+
useStrictModeSafeCleanupEffect(function () {
|
|
849
|
+
trackedQueryRefs.current.forEach(function (sub) { return sub.dispose(); });
|
|
850
|
+
});
|
|
836
851
|
}
|
|
837
852
|
function useWatchQueryOptions(_a) {
|
|
838
853
|
var query = _a.query, options = _a.options;
|
|
839
|
-
var watchQueryOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, options), { query: query, notifyOnNetworkStatusChange:
|
|
854
|
+
var watchQueryOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, options), { query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 })); }, [options, query]);
|
|
840
855
|
if (globals.__DEV__) {
|
|
841
856
|
validateOptions(watchQueryOptions);
|
|
842
857
|
}
|
|
843
858
|
return watchQueryOptions;
|
|
844
859
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
if (
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
+
|
|
861
|
+
function useBackgroundQuery_experimental(query, options) {
|
|
862
|
+
if (options === void 0) { options = Object.create(null); }
|
|
863
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
864
|
+
var client = useApolloClient(options.client);
|
|
865
|
+
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
866
|
+
var variables = watchQueryOptions.variables;
|
|
867
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
868
|
+
var cacheKey = [client, query, cache.canonicalStringify(variables)].concat(queryKey);
|
|
869
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
870
|
+
return client.watchQuery(watchQueryOptions);
|
|
871
|
+
});
|
|
872
|
+
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
873
|
+
useTrackedQueryRefs(queryRef);
|
|
874
|
+
var fetchMore = React.useCallback(function (options) {
|
|
875
|
+
var promise = queryRef.fetchMore(options);
|
|
876
|
+
setPromiseCache(function (promiseCache) {
|
|
877
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
878
|
+
});
|
|
879
|
+
return promise;
|
|
880
|
+
}, [queryRef]);
|
|
881
|
+
var refetch = React.useCallback(function (variables) {
|
|
882
|
+
var promise = queryRef.refetch(variables);
|
|
883
|
+
setPromiseCache(function (promiseCache) {
|
|
884
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
885
|
+
});
|
|
886
|
+
return promise;
|
|
887
|
+
}, [queryRef]);
|
|
888
|
+
queryRef.promiseCache = promiseCache;
|
|
889
|
+
return React.useMemo(function () {
|
|
890
|
+
return [
|
|
891
|
+
queryRef,
|
|
892
|
+
{
|
|
893
|
+
fetchMore: fetchMore,
|
|
894
|
+
refetch: refetch,
|
|
895
|
+
},
|
|
896
|
+
];
|
|
897
|
+
}, [queryRef, fetchMore, refetch]);
|
|
898
|
+
}
|
|
899
|
+
function useReadQuery_experimental(queryRef) {
|
|
900
|
+
var _a = React.useState(0), forceUpdate = _a[1];
|
|
901
|
+
globals.__DEV__ ? globals.invariant(queryRef.promiseCache, 'It appears that `useReadQuery` was used outside of `useBackgroundQuery`. ' +
|
|
902
|
+
'`useReadQuery` is only supported for use with `useBackgroundQuery`. ' +
|
|
903
|
+
'Please ensure you are passing the `queryRef` returned from `useBackgroundQuery`.') : globals.invariant(queryRef.promiseCache, 34);
|
|
904
|
+
var promise = queryRef.promiseCache.get(queryRef.key);
|
|
905
|
+
if (!promise) {
|
|
906
|
+
promise = queryRef.promise;
|
|
907
|
+
queryRef.promiseCache.set(queryRef.key, promise);
|
|
860
908
|
}
|
|
909
|
+
React.useEffect(function () {
|
|
910
|
+
return queryRef.listen(function (promise) {
|
|
911
|
+
queryRef.promiseCache.set(queryRef.key, promise);
|
|
912
|
+
forceUpdate(function (prevState) { return prevState + 1; });
|
|
913
|
+
});
|
|
914
|
+
}, [queryRef]);
|
|
915
|
+
var result = __use(promise);
|
|
916
|
+
return React.useMemo(function () {
|
|
917
|
+
return {
|
|
918
|
+
data: result.data,
|
|
919
|
+
networkStatus: result.networkStatus,
|
|
920
|
+
error: toApolloError(result),
|
|
921
|
+
};
|
|
922
|
+
}, [result]);
|
|
861
923
|
}
|
|
862
924
|
|
|
863
925
|
exports.useApolloClient = useApolloClient;
|
|
926
|
+
exports.useBackgroundQuery_experimental = useBackgroundQuery_experimental;
|
|
864
927
|
exports.useFragment_experimental = useFragment_experimental;
|
|
865
928
|
exports.useLazyQuery = useLazyQuery;
|
|
866
929
|
exports.useMutation = useMutation;
|
|
867
930
|
exports.useQuery = useQuery;
|
|
868
931
|
exports.useReactiveVar = useReactiveVar;
|
|
932
|
+
exports.useReadQuery_experimental = useReadQuery_experimental;
|
|
869
933
|
exports.useSubscription = useSubscription;
|
|
870
934
|
exports.useSuspenseQuery_experimental = useSuspenseQuery_experimental;
|
|
871
935
|
//# 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_experimental, UseSuspenseQueryResult, FetchMoreFunction, RefetchFunction, SubscribeToMoreFunction, } from './useSuspenseQuery';
|
|
10
|
+
export { useBackgroundQuery_experimental, useReadQuery_experimental, UseBackgroundQueryResult, } from './useBackgroundQuery';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,6BAA6B,EAC7B,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,+BAA+B,EAC/B,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC"}
|
package/react/hooks/index.js
CHANGED
|
@@ -6,5 +6,6 @@ export { useQuery } from "./useQuery.js";
|
|
|
6
6
|
export * from "./useSubscription.js";
|
|
7
7
|
export * from "./useReactiveVar.js";
|
|
8
8
|
export * from "./useFragment.js";
|
|
9
|
-
export
|
|
9
|
+
export { useSuspenseQuery_experimental, } from "./useSuspenseQuery.js";
|
|
10
|
+
export { useBackgroundQuery_experimental, useReadQuery_experimental, } from "./useBackgroundQuery.js";
|
|
10
11
|
//# sourceMappingURL=index.js.map
|
package/react/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,6BAA6B,GAK9B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,+BAA+B,EAC/B,yBAAyB,GAE1B,MAAM,sBAAsB,CAAC","sourcesContent":["import '../../utilities/globals';\n\nexport * from './useApolloClient';\nexport * from './useLazyQuery';\nexport * from './useMutation';\nexport { useQuery } from './useQuery';\nexport * from './useSubscription';\nexport * from './useReactiveVar';\nexport * from './useFragment';\nexport {\n useSuspenseQuery_experimental,\n UseSuspenseQueryResult,\n FetchMoreFunction,\n RefetchFunction,\n SubscribeToMoreFunction,\n} from './useSuspenseQuery';\nexport {\n useBackgroundQuery_experimental,\n useReadQuery_experimental,\n UseBackgroundQueryResult,\n} from './useBackgroundQuery';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepMemo.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useDeepMemo.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAI5C,wBAAgB,WAAW,CAAC,MAAM,EAChC,MAAM,EAAE,MAAM,MAAM,EACpB,IAAI,EAAE,cAAc,UASrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDeepMemo.js","sourceRoot":"","sources":["../../../../src/react/hooks/internal/useDeepMemo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,MAAoB,EACpB,IAAoB;IAEpB,IAAM,GAAG,GAAG,MAAM,EAA2C,CAAC;IAE9D,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;QAClD,GAAG,CAAC,OAAO,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,MAAA,EAAE,CAAC;KACzC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC;AAC3B,CAAC","sourcesContent":["import type { DependencyList } from 'react';\nimport { useRef } from 'react';\nimport { equal } from '@wry/equality';\n\nexport function useDeepMemo<TValue>(\n memoFn: () => TValue,\n deps: DependencyList\n) {\n const ref = useRef<{ deps: DependencyList; value: TValue }>();\n\n if (!ref.current || !equal(ref.current.deps, deps)) {\n ref.current = { value: memoFn(), deps };\n }\n\n return ref.current.value;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApolloClient.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"useApolloClient.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,wBAAgB,eAAe,CAC7B,QAAQ,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,GAC9B,YAAY,CAAC,MAAM,CAAC,CAWtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApolloClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,UAAU,eAAe,CAC7B,QAA+B;IAE/B,IAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC/C,IAAM,MAAM,GAAG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAC1C,SAAS,CACP,CAAC,CAAC,MAAM,EACR,oEAAoE;QACpE,0EAA0E;QAC1E,0BAA0B,CAC3B,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\nimport { useContext } from 'react';\nimport { ApolloClient } from '../../core';\nimport { getApolloContext } from '../context';\n\nexport function useApolloClient(\n override?: ApolloClient<object>,\n): ApolloClient<object> {\n const context = useContext(getApolloContext());\n const client = override || context.client;\n invariant(\n !!client,\n 'Could not find \"client\" in the context or passed in as an option. ' +\n 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +\n 'instance in via options.',\n );\n\n return client;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useApolloClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useApolloClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,UAAU,eAAe,CAC7B,QAA+B;IAE/B,IAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC/C,IAAM,MAAM,GAAG,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAC1C,SAAS,CACP,CAAC,CAAC,MAAM,EACR,oEAAoE;QACpE,0EAA0E;QAC1E,0BAA0B,CAC3B,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\nimport { useContext } from 'react';\nimport type { ApolloClient } from '../../core';\nimport { getApolloContext } from '../context';\n\nexport function useApolloClient(\n override?: ApolloClient<object>,\n): ApolloClient<object> {\n const context = useContext(getApolloContext());\n const client = override || context.client;\n invariant(\n !!client,\n 'Could not find \"client\" in the context or passed in as an option. ' +\n 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +\n 'instance in via options.',\n );\n\n return client;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { DocumentNode, OperationVariables, TypedDocumentNode } from '../../core';
|
|
2
|
+
import type { QueryReference } from '../cache/QueryReference';
|
|
3
|
+
import type { SuspenseQueryHookOptions, ObservableQueryFields } from '../types/types';
|
|
4
|
+
import type { FetchMoreFunction } from './useSuspenseQuery';
|
|
5
|
+
export type UseBackgroundQueryResult<TData = any, TVariables extends OperationVariables = OperationVariables> = [
|
|
6
|
+
QueryReference<TData>,
|
|
7
|
+
{
|
|
8
|
+
fetchMore: FetchMoreFunction<TData, TVariables>;
|
|
9
|
+
refetch: ObservableQueryFields<TData, TVariables>['refetch'];
|
|
10
|
+
}
|
|
11
|
+
];
|
|
12
|
+
export declare function useBackgroundQuery_experimental<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: Omit<SuspenseQueryHookOptions<TData, TVariables>, 'returnPartialData' | 'refetchWritePolicy'>): UseBackgroundQueryResult<TData>;
|
|
13
|
+
export declare function useReadQuery_experimental<TData>(queryRef: QueryReference<TData>): {
|
|
14
|
+
data: TData;
|
|
15
|
+
networkStatus: import("../../core").NetworkStatus;
|
|
16
|
+
error: import("../../errors").ApolloError | undefined;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useBackgroundQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackgroundQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,KAAK,EAAE,iBAAiB,EAAmB,MAAM,oBAAoB,CAAC;AAI7E,MAAM,MAAM,wBAAwB,CAClC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,IACxD;IACF,cAAc,CAAC,KAAK,CAAC;IACrB;QACE,SAAS,EAAE,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAChD,OAAO,EAAE,qBAAqB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;KAC9D;CACF,CAAC;AAEF,wBAAgB,+BAA+B,CAC7C,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAE1D,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1D,OAAO,GAAE,IAAI,CACX,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC3C,mBAAmB,GAAG,oBAAoB,CACrB,GACtB,wBAAwB,CAAC,KAAK,CAAC,CA0DjC;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAC7C,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC;;;;EAkChC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useEffect, useState, useMemo, useCallback } from 'react';
|
|
2
|
+
import { useApolloClient } from "./useApolloClient.js";
|
|
3
|
+
import { __use } from "./internal/index.js";
|
|
4
|
+
import { useSuspenseCache } from "./useSuspenseCache.js";
|
|
5
|
+
import { toApolloError, useTrackedQueryRefs, useWatchQueryOptions, } from "./useSuspenseQuery.js";
|
|
6
|
+
import { canonicalStringify } from "../../cache/index.js";
|
|
7
|
+
import { invariant, __DEV__ } from "../../utilities/globals/index.js";
|
|
8
|
+
export function useBackgroundQuery_experimental(query, options) {
|
|
9
|
+
if (options === void 0) { options = Object.create(null); }
|
|
10
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
11
|
+
var client = useApolloClient(options.client);
|
|
12
|
+
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
13
|
+
var variables = watchQueryOptions.variables;
|
|
14
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
15
|
+
var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
|
|
16
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
17
|
+
return client.watchQuery(watchQueryOptions);
|
|
18
|
+
});
|
|
19
|
+
var _b = useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
20
|
+
useTrackedQueryRefs(queryRef);
|
|
21
|
+
var fetchMore = useCallback(function (options) {
|
|
22
|
+
var promise = queryRef.fetchMore(options);
|
|
23
|
+
setPromiseCache(function (promiseCache) {
|
|
24
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
25
|
+
});
|
|
26
|
+
return promise;
|
|
27
|
+
}, [queryRef]);
|
|
28
|
+
var refetch = useCallback(function (variables) {
|
|
29
|
+
var promise = queryRef.refetch(variables);
|
|
30
|
+
setPromiseCache(function (promiseCache) {
|
|
31
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
32
|
+
});
|
|
33
|
+
return promise;
|
|
34
|
+
}, [queryRef]);
|
|
35
|
+
queryRef.promiseCache = promiseCache;
|
|
36
|
+
return useMemo(function () {
|
|
37
|
+
return [
|
|
38
|
+
queryRef,
|
|
39
|
+
{
|
|
40
|
+
fetchMore: fetchMore,
|
|
41
|
+
refetch: refetch,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}, [queryRef, fetchMore, refetch]);
|
|
45
|
+
}
|
|
46
|
+
export function useReadQuery_experimental(queryRef) {
|
|
47
|
+
var _a = useState(0), forceUpdate = _a[1];
|
|
48
|
+
__DEV__ ? invariant(queryRef.promiseCache, 'It appears that `useReadQuery` was used outside of `useBackgroundQuery`. ' +
|
|
49
|
+
'`useReadQuery` is only supported for use with `useBackgroundQuery`. ' +
|
|
50
|
+
'Please ensure you are passing the `queryRef` returned from `useBackgroundQuery`.') : invariant(queryRef.promiseCache, 34);
|
|
51
|
+
var promise = queryRef.promiseCache.get(queryRef.key);
|
|
52
|
+
if (!promise) {
|
|
53
|
+
promise = queryRef.promise;
|
|
54
|
+
queryRef.promiseCache.set(queryRef.key, promise);
|
|
55
|
+
}
|
|
56
|
+
useEffect(function () {
|
|
57
|
+
return queryRef.listen(function (promise) {
|
|
58
|
+
queryRef.promiseCache.set(queryRef.key, promise);
|
|
59
|
+
forceUpdate(function (prevState) { return prevState + 1; });
|
|
60
|
+
});
|
|
61
|
+
}, [queryRef]);
|
|
62
|
+
var result = __use(promise);
|
|
63
|
+
return useMemo(function () {
|
|
64
|
+
return {
|
|
65
|
+
data: result.data,
|
|
66
|
+
networkStatus: result.networkStatus,
|
|
67
|
+
error: toApolloError(result),
|
|
68
|
+
};
|
|
69
|
+
}, [result]);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=useBackgroundQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBackgroundQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useBackgroundQuery.ts"],"names":[],"mappings":"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","sourcesContent":["import { useEffect, useState, useMemo, useCallback } from 'react';\nimport type {\n DocumentNode,\n OperationVariables,\n TypedDocumentNode,\n} from '../../core';\nimport { useApolloClient } from './useApolloClient';\nimport type { QueryReference } from '../cache/QueryReference';\nimport type {\n SuspenseQueryHookOptions,\n ObservableQueryFields,\n} from '../types/types';\nimport { __use } from './internal';\nimport { useSuspenseCache } from './useSuspenseCache';\nimport {\n toApolloError,\n useTrackedQueryRefs,\n useWatchQueryOptions,\n} from './useSuspenseQuery';\nimport type { FetchMoreFunction, RefetchFunction } from './useSuspenseQuery';\nimport { canonicalStringify } from '../../cache';\nimport { invariant } from '../../utilities/globals';\n\nexport type UseBackgroundQueryResult<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n> = [\n QueryReference<TData>,\n {\n fetchMore: FetchMoreFunction<TData, TVariables>;\n refetch: ObservableQueryFields<TData, TVariables>['refetch'];\n }\n];\n\nexport function useBackgroundQuery_experimental<\n TData = any,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: Omit<\n SuspenseQueryHookOptions<TData, TVariables>,\n 'returnPartialData' | 'refetchWritePolicy'\n > = Object.create(null)\n): UseBackgroundQueryResult<TData> {\n const suspenseCache = useSuspenseCache(options.suspenseCache);\n const client = useApolloClient(options.client);\n const watchQueryOptions = useWatchQueryOptions({ query, options });\n const { variables } = watchQueryOptions;\n const { queryKey = [] } = options;\n\n const cacheKey = (\n [client, query, canonicalStringify(variables)] as any[]\n ).concat(queryKey);\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery(watchQueryOptions)\n );\n\n const [promiseCache, setPromiseCache] = useState(\n () => new Map([[queryRef.key, queryRef.promise]])\n );\n\n useTrackedQueryRefs(queryRef);\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = useCallback(\n (options) => {\n const promise = queryRef.fetchMore(options);\n\n setPromiseCache((promiseCache) =>\n new Map(promiseCache).set(queryRef.key, promise)\n );\n\n return promise;\n },\n [queryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n\n setPromiseCache((promiseCache) =>\n new Map(promiseCache).set(queryRef.key, promise)\n );\n\n return promise;\n },\n [queryRef]\n );\n\n queryRef.promiseCache = promiseCache;\n\n return useMemo(() => {\n return [\n queryRef,\n {\n fetchMore,\n refetch,\n },\n ];\n }, [queryRef, fetchMore, refetch]);\n}\n\nexport function useReadQuery_experimental<TData>(\n queryRef: QueryReference<TData>\n) {\n const [, forceUpdate] = useState(0);\n\n invariant(\n queryRef.promiseCache,\n 'It appears that `useReadQuery` was used outside of `useBackgroundQuery`. ' +\n '`useReadQuery` is only supported for use with `useBackgroundQuery`. ' +\n 'Please ensure you are passing the `queryRef` returned from `useBackgroundQuery`.'\n );\n\n let promise = queryRef.promiseCache.get(queryRef.key);\n\n if (!promise) {\n promise = queryRef.promise;\n queryRef.promiseCache.set(queryRef.key, promise);\n }\n\n useEffect(() => {\n return queryRef.listen((promise) => {\n queryRef.promiseCache!.set(queryRef.key, promise);\n forceUpdate((prevState) => prevState + 1);\n });\n }, [queryRef]);\n\n const result = __use(promise);\n\n return useMemo(() => {\n return {\n data: result.data,\n networkStatus: result.networkStatus,\n error: toApolloError(result),\n };\n }, [result]);\n}\n"]}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import type { DeepPartial } from "../../utilities";
|
|
2
|
+
import type { Cache, Reference, StoreObject, MissingTree } from "../../cache";
|
|
3
|
+
import type { OperationVariables } from "../../core";
|
|
4
|
+
import type { NoInfer } from "../types/types";
|
|
5
|
+
export interface UseFragmentOptions<TData, TVars> extends Omit<Cache.DiffOptions<NoInfer<TData>, NoInfer<TVars>>, "id" | "query" | "optimistic" | "previousResult" | "returnPartialData">, Omit<Cache.ReadFragmentOptions<TData, TVars>, "id" | "variables" | "returnPartialData"> {
|
|
5
6
|
from: StoreObject | Reference | string;
|
|
6
7
|
optimistic?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export
|
|
9
|
-
data: TData
|
|
10
|
-
complete:
|
|
9
|
+
export type UseFragmentResult<TData> = {
|
|
10
|
+
data: TData;
|
|
11
|
+
complete: true;
|
|
12
|
+
missing?: never;
|
|
13
|
+
} | {
|
|
14
|
+
data: DeepPartial<TData>;
|
|
15
|
+
complete: false;
|
|
11
16
|
missing?: MissingTree;
|
|
12
|
-
}
|
|
17
|
+
};
|
|
13
18
|
export declare function useFragment_experimental<TData = any, TVars = OperationVariables>(options: UseFragmentOptions<TData, TVars>): UseFragmentResult<TData>;
|
|
14
19
|
//# sourceMappingURL=useFragment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFragment.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFragment.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,WAAW,EACX,WAAW,EACZ,MAAM,aAAa,CAAC;AAIrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAChD,SAAQ,IAAI,CACV,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAC/C,IAAI,GACJ,OAAO,GACP,YAAY,GACZ,gBAAgB,GAChB,mBAAmB,CACtB,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,EAC3C,IAAI,GACJ,WAAW,GACX,mBAAmB,CACtB;IACC,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;IAEvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,MAAM,iBAAiB,CAAC,KAAK,IAC/B;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,QAAQ,EAAE,IAAI,CAAC;IACf,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,GACD;IACE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC;IAChB,OAAO,CAAC,EAAE,WAAW,CAAC;CACvB,CAAC;AAEN,wBAAgB,wBAAwB,CACtC,KAAK,GAAG,GAAG,EACX,KAAK,GAAG,kBAAkB,EAE1B,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,GACxC,iBAAiB,CAAC,KAAK,CAAC,CA+C1B"}
|
|
@@ -7,7 +7,7 @@ import { useSyncExternalStore } from "./useSyncExternalStore.js";
|
|
|
7
7
|
export function useFragment_experimental(options) {
|
|
8
8
|
var cache = useApolloClient().cache;
|
|
9
9
|
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = __rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
10
|
-
var diffOptions = __assign(__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
10
|
+
var diffOptions = __assign(__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
11
11
|
var resultRef = useRef();
|
|
12
12
|
var latestDiff = cache.diff(diffOptions);
|
|
13
13
|
var getSnapshot = function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"useFragment.js","sourceRoot":"","sources":["../../../src/react/hooks/useFragment.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAkC9D,MAAM,UAAU,wBAAwB,CAItC,OAAyC;IAEjC,IAAA,KAAK,GAAK,eAAe,EAAE,MAAtB,CAAuB;IAGlC,IAAA,QAAQ,GAKN,OAAO,SALD,EACR,YAAY,GAIV,OAAO,aAJG,EACZ,IAAI,GAGF,OAAO,KAHL,EACJ,KAEE,OAAO,WAFQ,EAAjB,UAAU,mBAAG,IAAI,KAAA,EACd,IAAI,UACL,OAAO,EANL,kDAML,CADQ,CACG;IAEZ,IAAM,WAAW,yBACZ,IAAI,KACP,iBAAiB,EAAE,IAAI,EACvB,EAAE,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAC1D,KAAK,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,YAAY,CAAC,EACtD,UAAU,YAAA,GACX,CAAC;IAEF,IAAM,SAAS,GAAG,MAAM,EAA4B,CAAC;IACrD,IAAI,UAAU,GAAG,KAAK,CAAC,IAAI,CAAQ,WAAW,CAAC,CAAC;IAGhD,IAAM,WAAW,GAAG;QAClB,IAAM,kBAAkB,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;QACpD,OAAO,SAAS,CAAC,OAAO;YACtB,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC;YACtD,CAAC,CAAC,SAAS,CAAC,OAAO;YACnB,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,GAAG,kBAAkB,CAAC,CAAC;IAC/C,CAAC,CAAC;IAEF,OAAO,oBAAoB,CACzB,UAAC,WAAW;QACV,OAAO,KAAK,CAAC,KAAK,uBACb,WAAW,KACd,SAAS,EAAE,IAAI,EACf,QAAQ,YAAC,IAAI;gBACX,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE;oBAC5B,SAAS,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC;oBACtD,WAAW,EAAE,CAAC;iBACf;YACH,CAAC,IACD,CAAC;IACL,CAAC,EACD,WAAW,EACX,WAAW,CACZ,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,IAA6B;IAE7B,IAAM,MAAM,GAAG;QACb,IAAI,EAAE,IAAI,CAAC,MAAO;QAClB,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ;KACE,CAAC;IAE9B,IAAI,IAAI,CAAC,OAAO,EAAE;QAChB,MAAM,CAAC,OAAO,GAAG,cAAc,CAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,OAAO,EAAb,CAAa,CAAC,CACzC,CAAC;KACH;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { useRef } from \"react\";\nimport { equal } from \"@wry/equality\";\n\nimport type { DeepPartial} from \"../../utilities\";\nimport { mergeDeepArray } from \"../../utilities\";\nimport type {\n Cache,\n Reference,\n StoreObject,\n MissingTree,\n} from \"../../cache\";\n\nimport { useApolloClient } from \"./useApolloClient\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore\";\nimport type { OperationVariables } from \"../../core\";\nimport type { NoInfer } from \"../types/types\";\n\nexport interface UseFragmentOptions<TData, TVars>\nextends Omit<\n Cache.DiffOptions<NoInfer<TData>, NoInfer<TVars>>,\n | \"id\"\n | \"query\"\n | \"optimistic\"\n | \"previousResult\"\n | \"returnPartialData\"\n>, Omit<Cache.ReadFragmentOptions<TData, TVars>,\n | \"id\"\n | \"variables\"\n | \"returnPartialData\"\n> {\n from: StoreObject | Reference | string;\n // Override this field to make it optional (default: true).\n optimistic?: boolean;\n}\n\nexport type UseFragmentResult<TData> =\n | {\n data: TData;\n complete: true;\n missing?: never;\n }\n | {\n data: DeepPartial<TData>;\n complete: false;\n missing?: MissingTree;\n };\n\nexport function useFragment_experimental<\n TData = any,\n TVars = OperationVariables\n>(\n options: UseFragmentOptions<TData, TVars>,\n): UseFragmentResult<TData> {\n const { cache } = useApolloClient();\n\n const {\n fragment,\n fragmentName,\n from,\n optimistic = true,\n ...rest\n } = options;\n\n const diffOptions: Cache.DiffOptions<TData, TVars> = {\n ...rest,\n returnPartialData: true,\n id: typeof from === \"string\" ? from : cache.identify(from),\n query: cache[\"getFragmentDoc\"](fragment, fragmentName),\n optimistic\n };\n\n const resultRef = useRef<UseFragmentResult<TData>>();\n let latestDiff = cache.diff<TData>(diffOptions);\n\n // Used for both getSnapshot and getServerSnapshot\n const getSnapshot = () => {\n const latestDiffToResult = diffToResult(latestDiff);\n return resultRef.current &&\n equal(resultRef.current.data, latestDiffToResult.data)\n ? resultRef.current\n : (resultRef.current = latestDiffToResult);\n };\n\n return useSyncExternalStore(\n (forceUpdate) => {\n return cache.watch({\n ...diffOptions,\n immediate: true,\n callback(diff) {\n if (!equal(diff, latestDiff)) {\n resultRef.current = diffToResult((latestDiff = diff));\n forceUpdate();\n }\n },\n });\n },\n getSnapshot,\n getSnapshot\n );\n}\n\nfunction diffToResult<TData>(\n diff: Cache.DiffResult<TData>,\n): UseFragmentResult<TData> {\n const result = {\n data: diff.result!,\n complete: !!diff.complete,\n } as UseFragmentResult<TData>;\n\n if (diff.missing) {\n result.missing = mergeDeepArray(\n diff.missing.map(error => error.missing),\n );\n }\n\n return result;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DocumentNode } from 'graphql';
|
|
2
|
-
import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
-
import { OperationVariables } from '../../core';
|
|
4
|
-
import { LazyQueryHookOptions, LazyQueryResultTuple, NoInfer } from '../types/types';
|
|
1
|
+
import type { DocumentNode } from 'graphql';
|
|
2
|
+
import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
import type { OperationVariables } from '../../core';
|
|
4
|
+
import type { LazyQueryHookOptions, LazyQueryResultTuple, NoInfer } from '../types/types';
|
|
5
5
|
export declare function useLazyQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: LazyQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): LazyQueryResultTuple<TData, TVariables>;
|
|
6
6
|
//# sourceMappingURL=useLazyQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLazyQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useLazyQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"useLazyQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useLazyQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,EAEV,oBAAoB,EACpB,oBAAoB,EACpB,OAAO,EAER,MAAM,gBAAgB,CAAC;AAexB,wBAAgB,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,EAClG,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1D,OAAO,CAAC,EAAE,oBAAoB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,GAClE,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,CA8EzC"}
|