@apollo/client 3.8.0-beta.6 → 3.8.0-rc.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 +416 -398
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +12 -12
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +12 -12
- package/cache/core/cache.d.ts +3 -3
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +3 -3
- 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 +2 -2
- 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 +2 -2
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/index.d.ts +14 -14
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +13 -13
- package/cache/index.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 +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +5 -5
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +1 -1
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +8 -8
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +13 -13
- 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/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +2 -3
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts +6 -6
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +9 -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 +7 -7
- 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 +10 -10
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/setup.d.ts +1 -1
- package/config/jest/setup.d.ts.map +1 -1
- package/config/jest/setup.js +7 -2
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +10 -10
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +10 -10
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +5 -5
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +3 -3
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +10 -10
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +11 -11
- 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 +4 -4
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +10 -10
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +17 -17
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +25 -24
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +25 -24
- package/core/equalByQuery.d.ts +2 -2
- package/core/equalByQuery.d.ts.map +1 -1
- package/core/equalByQuery.js +9 -8
- package/core/equalByQuery.js.map +1 -1
- package/core/index.d.ts +13 -13
- package/core/index.d.ts.map +1 -1
- package/core/index.js +12 -13
- package/core/index.js.map +1 -1
- package/core/types.d.ts +10 -10
- package/core/types.d.ts.map +1 -1
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +4 -4
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +29 -39
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +29 -39
- package/dev/index.d.ts +3 -3
- package/dev/index.d.ts.map +1 -1
- package/dev/index.js +3 -3
- package/dev/index.js.map +1 -1
- package/dev/loadDevMessages.js +2 -2
- package/dev/loadDevMessages.js.map +1 -1
- package/dev/loadErrorMessageHandler.d.ts +1 -1
- package/dev/loadErrorMessageHandler.d.ts.map +1 -1
- package/dev/loadErrorMessageHandler.js +2 -2
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/dev/loadErrorMessages.js +2 -2
- package/dev/loadErrorMessages.js.map +1 -1
- package/errors/errors.cjs.map +1 -1
- package/errors/index.d.ts +4 -4
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +2 -2
- package/errors/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/invariantErrorCodes.js +27 -36
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batchLink.d.ts +5 -5
- package/link/batch/batchLink.d.ts.map +1 -1
- package/link/batch/batchLink.js +3 -3
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +2 -2
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +1 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch/index.d.ts +1 -1
- package/link/batch/index.d.ts.map +1 -1
- package/link/batch/index.js +1 -1
- package/link/batch/index.js.map +1 -1
- package/link/batch-http/batch-http.cjs +5 -7
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +5 -7
- package/link/batch-http/batchHttpLink.d.ts +5 -5
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +10 -12
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +1 -1
- package/link/batch-http/index.d.ts.map +1 -1
- package/link/batch-http/index.js +1 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/context/context.cjs.map +1 -1
- package/link/context/index.d.ts +3 -3
- package/link/context/index.d.ts.map +1 -1
- package/link/context/index.js +2 -2
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +3 -3
- package/link/core/ApolloLink.d.ts.map +1 -1
- package/link/core/ApolloLink.js +4 -4
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/concat.d.ts +1 -1
- package/link/core/concat.d.ts.map +1 -1
- package/link/core/concat.js +1 -1
- package/link/core/concat.js.map +1 -1
- package/link/core/core.cjs +1 -1
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +1 -1
- package/link/core/empty.d.ts +1 -1
- package/link/core/empty.d.ts.map +1 -1
- package/link/core/empty.js +1 -1
- package/link/core/empty.js.map +1 -1
- package/link/core/execute.d.ts +1 -1
- package/link/core/execute.d.ts.map +1 -1
- package/link/core/execute.js +1 -1
- package/link/core/execute.js.map +1 -1
- package/link/core/from.d.ts +1 -1
- package/link/core/from.d.ts.map +1 -1
- package/link/core/from.js +1 -1
- package/link/core/from.js.map +1 -1
- package/link/core/index.d.ts +8 -8
- package/link/core/index.d.ts.map +1 -1
- package/link/core/index.js +8 -8
- package/link/core/index.js.map +1 -1
- package/link/core/split.d.ts +1 -1
- package/link/core/split.d.ts.map +1 -1
- package/link/core/split.js +1 -1
- package/link/core/split.js.map +1 -1
- package/link/core/types.d.ts +2 -2
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/error/error.cjs.map +1 -1
- package/link/error/index.d.ts +4 -4
- package/link/error/index.d.ts.map +1 -1
- package/link/error/index.js +2 -2
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +3 -3
- package/link/http/HttpLink.d.ts.map +1 -1
- package/link/http/HttpLink.js +2 -2
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.d.ts +2 -2
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +28 -23
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/createSignalIfSupported.d.ts.map +1 -1
- package/link/http/createSignalIfSupported.js.map +1 -1
- package/link/http/http.cjs +49 -62
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +49 -62
- package/link/http/index.d.ts +10 -10
- package/link/http/index.d.ts.map +1 -1
- package/link/http/index.js +10 -10
- package/link/http/index.js.map +1 -1
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/iterators/promise.js.map +1 -1
- package/link/http/iterators/reader.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +4 -5
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +34 -53
- package/link/http/parseAndCheckHttpResponse.js.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 +1 -1
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +2 -2
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +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 +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts +3 -3
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +4 -4
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/remove-typename/index.d.ts +1 -1
- package/link/remove-typename/index.d.ts.map +1 -1
- package/link/remove-typename/index.js +1 -1
- package/link/remove-typename/index.js.map +1 -1
- package/link/remove-typename/remove-typename.cjs.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts +1 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js +2 -2
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- 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/index.d.ts +1 -1
- package/link/retry/index.d.ts.map +1 -1
- package/link/retry/index.js +1 -1
- package/link/retry/index.js.map +1 -1
- package/link/retry/retry.cjs.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 +5 -5
- package/link/retry/retryLink.d.ts.map +1 -1
- package/link/retry/retryLink.js +4 -4
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +3 -3
- package/link/schema/index.d.ts.map +1 -1
- package/link/schema/index.js +2 -2
- package/link/schema/index.js.map +1 -1
- package/link/schema/schema.cjs.map +1 -1
- package/link/subscriptions/index.d.ts +3 -3
- package/link/subscriptions/index.d.ts.map +1 -1
- package/link/subscriptions/index.js +1 -1
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs.map +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/fromError.d.ts +1 -1
- package/link/utils/fromError.d.ts.map +1 -1
- package/link/utils/fromError.js +1 -1
- package/link/utils/fromError.js.map +1 -1
- package/link/utils/fromPromise.d.ts +1 -1
- package/link/utils/fromPromise.d.ts.map +1 -1
- package/link/utils/fromPromise.js +1 -1
- package/link/utils/fromPromise.js.map +1 -1
- package/link/utils/index.d.ts +9 -9
- package/link/utils/index.d.ts.map +1 -1
- package/link/utils/index.js +9 -9
- package/link/utils/index.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 +2 -2
- 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 +1 -1
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +1 -1
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +1 -1
- package/link/utils/validateOperation.d.ts +1 -1
- package/link/utils/validateOperation.d.ts.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +3 -3
- package/link/ws/index.d.ts.map +1 -1
- package/link/ws/index.js +1 -1
- package/link/ws/index.js.map +1 -1
- package/link/ws/ws.cjs.map +1 -1
- package/package.json +20 -16
- package/react/cache/QueryReference.d.ts +8 -7
- package/react/cache/QueryReference.d.ts.map +1 -1
- package/react/cache/QueryReference.js +84 -53
- package/react/cache/QueryReference.js.map +1 -1
- package/react/cache/SuspenseCache.d.ts +4 -5
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js +2 -2
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/cache/getSuspenseCache.d.ts +16 -0
- package/react/cache/getSuspenseCache.d.ts.map +1 -0
- package/react/cache/getSuspenseCache.js +10 -0
- package/react/cache/getSuspenseCache.js.map +1 -0
- package/react/cache/index.d.ts +6 -1
- package/react/cache/index.d.ts.map +1 -1
- package/react/cache/index.js +15 -1
- package/react/cache/index.js.map +1 -1
- package/react/cache/types.d.ts +2 -1
- package/react/cache/types.d.ts.map +1 -1
- package/react/cache/types.js.map +1 -1
- package/react/components/Mutation.d.ts +3 -3
- package/react/components/Mutation.d.ts.map +1 -1
- package/react/components/Mutation.js +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 +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 +1 -1
- package/react/components/Subscription.js.map +1 -1
- package/react/components/components.cjs.map +1 -1
- package/react/components/index.d.ts +4 -4
- package/react/components/index.d.ts.map +1 -1
- package/react/components/index.js +4 -4
- package/react/components/index.js.map +1 -1
- package/react/components/types.d.ts +2 -2
- 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 -2
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +3 -6
- package/react/context/ApolloContext.d.ts.map +1 -1
- package/react/context/ApolloContext.js +11 -4
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +1 -3
- package/react/context/ApolloProvider.d.ts.map +1 -1
- package/react/context/ApolloProvider.js +5 -5
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/context/context.cjs +12 -5
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +12 -5
- package/react/context/index.d.ts +4 -4
- package/react/context/index.d.ts.map +1 -1
- package/react/context/index.js +4 -4
- package/react/context/index.js.map +1 -1
- package/react/hoc/graphql.d.ts +2 -2
- package/react/hoc/graphql.d.ts.map +1 -1
- package/react/hoc/graphql.js +4 -4
- 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 +1 -1
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/index.d.ts +7 -7
- package/react/hoc/index.d.ts.map +1 -1
- package/react/hoc/index.js +7 -7
- package/react/hoc/index.js.map +1 -1
- package/react/hoc/mutation-hoc.d.ts +3 -3
- package/react/hoc/mutation-hoc.d.ts.map +1 -1
- package/react/hoc/mutation-hoc.js +3 -3
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +1 -1
- package/react/hoc/query-hoc.d.ts.map +1 -1
- package/react/hoc/query-hoc.js +3 -3
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js +3 -3
- 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 -2
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +279 -231
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +279 -231
- package/react/hooks/index.d.ts +11 -11
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +11 -11
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/internal/__use.js +2 -2
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/internal/index.d.ts +3 -4
- package/react/hooks/internal/index.d.ts.map +1 -1
- package/react/hooks/internal/index.js +3 -4
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useDeepMemo.js +2 -2
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +2 -2
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +4 -4
- package/react/hooks/internal/useIsomorphicLayoutEffect.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 +4 -4
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +5 -5
- package/react/hooks/useBackgroundQuery.d.ts.map +1 -1
- package/react/hooks/useBackgroundQuery.js +19 -15
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +4 -4
- 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 +2 -2
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +9 -9
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +2 -2
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +10 -10
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +4 -4
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +17 -17
- 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 +3 -3
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +3 -3
- package/react/hooks/useReadQuery.d.ts.map +1 -1
- package/react/hooks/useReadQuery.js +5 -5
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -2
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +14 -14
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +4 -6
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +33 -33
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +4 -4
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/index.d.ts +6 -6
- package/react/index.d.ts.map +1 -1
- package/react/index.js +6 -6
- package/react/index.js.map +1 -1
- package/react/parser/index.js +6 -6
- 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 +96 -54
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +96 -54
- 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/getDataFromTree.js +2 -2
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/index.d.ts +3 -3
- package/react/ssr/index.d.ts.map +1 -1
- package/react/ssr/index.js +3 -3
- package/react/ssr/index.js.map +1 -1
- package/react/ssr/renderToStringWithData.js +1 -1
- package/react/ssr/renderToStringWithData.js.map +1 -1
- package/react/ssr/ssr.cjs.map +1 -1
- package/react/types/types.d.ts +7 -7
- 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/index.d.ts +7 -7
- package/testing/core/index.d.ts.map +1 -1
- package/testing/core/index.js +7 -7
- package/testing/core/index.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 +3 -3
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +3 -3
- package/testing/core/mocking/mockLink.d.ts.map +1 -1
- package/testing/core/mocking/mockLink.js +4 -4
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +3 -3
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
- package/testing/core/mocking/mockQueryManager.js +3 -3
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -3
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js +2 -2
- 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 +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 +1 -1
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/index.d.ts +3 -3
- package/testing/index.d.ts.map +1 -1
- package/testing/index.js +3 -3
- package/testing/index.js.map +1 -1
- package/testing/matchers/index.js +2 -2
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts +1 -2
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +12 -6
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.d.ts +1 -1
- package/testing/matchers/toMatchDocument.d.ts.map +1 -1
- package/testing/matchers/toMatchDocument.js +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +6 -9
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +8 -10
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +4 -6
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +4 -6
- package/utilities/common/canUse.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/maybeDeepFreeze.d.ts.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +3 -4
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts +1 -1
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeDeep.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.map +1 -1
- package/utilities/common/omitDeep.d.ts +1 -1
- package/utilities/common/omitDeep.d.ts.map +1 -1
- package/utilities/common/omitDeep.js +1 -1
- package/utilities/common/omitDeep.js.map +1 -1
- package/utilities/common/responseIterator.js.map +1 -1
- package/utilities/common/stringifyForDisplay.js.map +1 -1
- package/utilities/common/stripTypename.d.ts +1 -1
- package/utilities/common/stripTypename.d.ts.map +1 -1
- package/utilities/common/stripTypename.js +1 -1
- package/utilities/common/stripTypename.js.map +1 -1
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +4 -16
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +4 -16
- package/utilities/globals/index.d.ts +5 -6
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +2 -5
- package/utilities/globals/index.js.map +1 -1
- package/utilities/globals/invariantWrappers.d.ts +1 -1
- package/utilities/globals/invariantWrappers.d.ts.map +1 -1
- package/utilities/globals/invariantWrappers.js +3 -3
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +4 -4
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/directives.js +5 -5
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.js +4 -4
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.js +10 -10
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/operations.d.ts +1 -1
- package/utilities/graphql/operations.d.ts.map +1 -1
- package/utilities/graphql/operations.js +1 -1
- package/utilities/graphql/operations.js.map +1 -1
- package/utilities/graphql/print.js +1 -1
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +1 -1
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +4 -4
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.js +7 -7
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +34 -34
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +32 -32
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +2 -2
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/asyncMap.d.ts +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/observables/subclassing.d.ts +1 -1
- package/utilities/observables/subclassing.d.ts.map +1 -1
- package/utilities/observables/subclassing.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 +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/types/DeepOmit.d.ts +1 -1
- package/utilities/types/DeepOmit.d.ts.map +1 -1
- package/utilities/types/DeepOmit.js.map +1 -1
- package/utilities/types/DeepPartial.d.ts +1 -1
- package/utilities/types/DeepPartial.d.ts.map +1 -1
- package/utilities/types/DeepPartial.js.map +1 -1
- package/utilities/utilities.cjs +21 -21
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +21 -21
- package/version.js +1 -1
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts +0 -2
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts.map +0 -1
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.js +0 -11
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.js.map +0 -1
- package/react/hooks/useSuspenseCache.d.ts +0 -3
- package/react/hooks/useSuspenseCache.d.ts.map +0 -1
- package/react/hooks/useSuspenseCache.js +0 -10
- package/react/hooks/useSuspenseCache.js.map +0 -1
- package/utilities/globals/DEV.d.ts +0 -3
- package/utilities/globals/DEV.d.ts.map +0 -1
- package/utilities/globals/DEV.js +0 -4
- package/utilities/globals/DEV.js.map +0 -1
- package/utilities/globals/fix-graphql.d.ts +0 -2
- package/utilities/globals/fix-graphql.d.ts.map +0 -1
- package/utilities/globals/fix-graphql.js +0 -6
- package/utilities/globals/fix-graphql.js.map +0 -1
package/react/hooks/hooks.cjs
CHANGED
|
@@ -12,6 +12,7 @@ var errors = require('../../errors');
|
|
|
12
12
|
var core = require('../../core');
|
|
13
13
|
var parser = require('../parser');
|
|
14
14
|
var cache = require('../../cache');
|
|
15
|
+
var trie = require('@wry/trie');
|
|
15
16
|
var invariant = require('ts-invariant');
|
|
16
17
|
|
|
17
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
@@ -29,11 +30,10 @@ function _interopNamespace(e) {
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
32
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
33
33
|
var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant);
|
|
34
34
|
|
|
35
35
|
function useApolloClient(override) {
|
|
36
|
-
var context$1 =
|
|
36
|
+
var context$1 = React__namespace.useContext(context.getApolloContext());
|
|
37
37
|
var client = override || context$1.client;
|
|
38
38
|
globals.invariant(!!client, 47);
|
|
39
39
|
return client;
|
|
@@ -44,11 +44,11 @@ var uSESKey = "useSyncExternalStore";
|
|
|
44
44
|
var realHook$1 = React__namespace[uSESKey];
|
|
45
45
|
var useSyncExternalStore = realHook$1 || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
46
46
|
var value = getSnapshot();
|
|
47
|
-
if (
|
|
47
|
+
if (globalThis.__DEV__ !== false &&
|
|
48
48
|
!didWarnUncachedGetSnapshot &&
|
|
49
49
|
value !== getSnapshot()) {
|
|
50
50
|
didWarnUncachedGetSnapshot = true;
|
|
51
|
-
|
|
51
|
+
globalThis.__DEV__ !== false && globals.invariant.error(56);
|
|
52
52
|
}
|
|
53
53
|
var _a = React__namespace.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
|
|
54
54
|
if (utilities.canUseLayoutEffect) {
|
|
@@ -90,14 +90,14 @@ function useQuery(query, options) {
|
|
|
90
90
|
return useInternalState(useApolloClient(options.client), query).useQuery(options);
|
|
91
91
|
}
|
|
92
92
|
function useInternalState(client, query) {
|
|
93
|
-
var stateRef =
|
|
93
|
+
var stateRef = React__namespace.useRef();
|
|
94
94
|
if (!stateRef.current ||
|
|
95
95
|
client !== stateRef.current.client ||
|
|
96
96
|
query !== stateRef.current.query) {
|
|
97
97
|
stateRef.current = new InternalState(client, query, stateRef.current);
|
|
98
98
|
}
|
|
99
99
|
var state = stateRef.current;
|
|
100
|
-
var _a =
|
|
100
|
+
var _a = React__namespace.useState(0); _a[0]; var setTick = _a[1];
|
|
101
101
|
state.forceUpdate = function () {
|
|
102
102
|
setTick(function (tick) { return tick + 1; });
|
|
103
103
|
};
|
|
@@ -128,7 +128,7 @@ var InternalState = (function () {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
InternalState.prototype.forceUpdate = function () {
|
|
131
|
-
|
|
131
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(48);
|
|
132
132
|
};
|
|
133
133
|
InternalState.prototype.executeQuery = function (options) {
|
|
134
134
|
var _this = this;
|
|
@@ -158,10 +158,10 @@ var InternalState = (function () {
|
|
|
158
158
|
};
|
|
159
159
|
InternalState.prototype.useQuery = function (options) {
|
|
160
160
|
var _this = this;
|
|
161
|
-
this.renderPromises =
|
|
161
|
+
this.renderPromises = React__namespace.useContext(context.getApolloContext()).renderPromises;
|
|
162
162
|
this.useOptions(options);
|
|
163
163
|
var obsQuery = this.useObservableQuery();
|
|
164
|
-
var result = useSyncExternalStore(
|
|
164
|
+
var result = useSyncExternalStore(React__namespace.useCallback(function () {
|
|
165
165
|
if (_this.renderPromises) {
|
|
166
166
|
return function () { };
|
|
167
167
|
}
|
|
@@ -291,7 +291,7 @@ var InternalState = (function () {
|
|
|
291
291
|
&& this.renderPromises.getSSRObservable(this.watchQueryOptions)
|
|
292
292
|
|| this.observable
|
|
293
293
|
|| this.client.watchQuery(this.getObsQueryOptions());
|
|
294
|
-
this.obsQueryFields =
|
|
294
|
+
this.obsQueryFields = React__namespace.useMemo(function () { return ({
|
|
295
295
|
refetch: obsQuery.refetch.bind(obsQuery),
|
|
296
296
|
reobserve: obsQuery.reobserve.bind(obsQuery),
|
|
297
297
|
fetchMore: obsQuery.fetchMore.bind(obsQuery),
|
|
@@ -333,7 +333,7 @@ var InternalState = (function () {
|
|
|
333
333
|
_this.onCompleted(result.data);
|
|
334
334
|
}
|
|
335
335
|
}).catch(function (error) {
|
|
336
|
-
|
|
336
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(error);
|
|
337
337
|
});
|
|
338
338
|
}
|
|
339
339
|
};
|
|
@@ -385,9 +385,9 @@ var EAGER_METHODS = [
|
|
|
385
385
|
];
|
|
386
386
|
function useLazyQuery(query, options) {
|
|
387
387
|
var _a;
|
|
388
|
-
var execOptionsRef =
|
|
389
|
-
var optionsRef =
|
|
390
|
-
var queryRef =
|
|
388
|
+
var execOptionsRef = React__namespace.useRef();
|
|
389
|
+
var optionsRef = React__namespace.useRef();
|
|
390
|
+
var queryRef = React__namespace.useRef();
|
|
391
391
|
var merged = utilities.mergeOptions(options, execOptionsRef.current || {});
|
|
392
392
|
var document = (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query;
|
|
393
393
|
optionsRef.current = merged;
|
|
@@ -399,7 +399,7 @@ function useLazyQuery(query, options) {
|
|
|
399
399
|
var result = Object.assign(useQueryResult, {
|
|
400
400
|
called: !!execOptionsRef.current,
|
|
401
401
|
});
|
|
402
|
-
var eagerMethods =
|
|
402
|
+
var eagerMethods = React__namespace.useMemo(function () {
|
|
403
403
|
var eagerMethods = {};
|
|
404
404
|
var _loop_1 = function (key) {
|
|
405
405
|
var method = result[key];
|
|
@@ -418,7 +418,7 @@ function useLazyQuery(query, options) {
|
|
|
418
418
|
return eagerMethods;
|
|
419
419
|
}, []);
|
|
420
420
|
Object.assign(result, eagerMethods);
|
|
421
|
-
var execute =
|
|
421
|
+
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
422
422
|
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
423
423
|
fetchPolicy: initialFetchPolicy,
|
|
424
424
|
};
|
|
@@ -435,12 +435,12 @@ function useLazyQuery(query, options) {
|
|
|
435
435
|
function useMutation(mutation, options) {
|
|
436
436
|
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
437
437
|
parser.verifyDocumentType(mutation, parser.DocumentType.Mutation);
|
|
438
|
-
var _a =
|
|
438
|
+
var _a = React__namespace.useState({
|
|
439
439
|
called: false,
|
|
440
440
|
loading: false,
|
|
441
441
|
client: client,
|
|
442
442
|
}), result = _a[0], setResult = _a[1];
|
|
443
|
-
var ref =
|
|
443
|
+
var ref = React__namespace.useRef({
|
|
444
444
|
result: result,
|
|
445
445
|
mutationId: 0,
|
|
446
446
|
isMounted: true,
|
|
@@ -451,7 +451,7 @@ function useMutation(mutation, options) {
|
|
|
451
451
|
{
|
|
452
452
|
Object.assign(ref.current, { client: client, options: options, mutation: mutation });
|
|
453
453
|
}
|
|
454
|
-
var execute =
|
|
454
|
+
var execute = React__namespace.useCallback(function (executeOptions) {
|
|
455
455
|
if (executeOptions === void 0) { executeOptions = {}; }
|
|
456
456
|
var _a = ref.current, options = _a.options, mutation = _a.mutation;
|
|
457
457
|
var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
|
|
@@ -512,12 +512,12 @@ function useMutation(mutation, options) {
|
|
|
512
512
|
throw error;
|
|
513
513
|
});
|
|
514
514
|
}, []);
|
|
515
|
-
var reset =
|
|
515
|
+
var reset = React__namespace.useCallback(function () {
|
|
516
516
|
if (ref.current.isMounted) {
|
|
517
517
|
setResult({ called: false, loading: false, client: client });
|
|
518
518
|
}
|
|
519
519
|
}, []);
|
|
520
|
-
|
|
520
|
+
React__namespace.useEffect(function () {
|
|
521
521
|
ref.current.isMounted = true;
|
|
522
522
|
return function () {
|
|
523
523
|
ref.current.isMounted = false;
|
|
@@ -527,10 +527,10 @@ function useMutation(mutation, options) {
|
|
|
527
527
|
}
|
|
528
528
|
|
|
529
529
|
function useSubscription(subscription, options) {
|
|
530
|
-
var hasIssuedDeprecationWarningRef =
|
|
530
|
+
var hasIssuedDeprecationWarningRef = React__namespace.useRef(false);
|
|
531
531
|
var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
|
|
532
532
|
parser.verifyDocumentType(subscription, parser.DocumentType.Subscription);
|
|
533
|
-
var _a =
|
|
533
|
+
var _a = React__namespace.useState({
|
|
534
534
|
loading: !(options === null || options === void 0 ? void 0 : options.skip),
|
|
535
535
|
error: void 0,
|
|
536
536
|
data: void 0,
|
|
@@ -539,13 +539,13 @@ function useSubscription(subscription, options) {
|
|
|
539
539
|
if (!hasIssuedDeprecationWarningRef.current) {
|
|
540
540
|
hasIssuedDeprecationWarningRef.current = true;
|
|
541
541
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionData) {
|
|
542
|
-
|
|
542
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(options.onData ? 50 : 51);
|
|
543
543
|
}
|
|
544
544
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionComplete) {
|
|
545
|
-
|
|
545
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(options.onComplete ? 52 : 53);
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
|
-
var _b =
|
|
548
|
+
var _b = React__namespace.useState(function () {
|
|
549
549
|
if (options === null || options === void 0 ? void 0 : options.skip) {
|
|
550
550
|
return null;
|
|
551
551
|
}
|
|
@@ -556,14 +556,14 @@ function useSubscription(subscription, options) {
|
|
|
556
556
|
context: options === null || options === void 0 ? void 0 : options.context,
|
|
557
557
|
});
|
|
558
558
|
}), observable = _b[0], setObservable = _b[1];
|
|
559
|
-
var canResetObservableRef =
|
|
560
|
-
|
|
559
|
+
var canResetObservableRef = React__namespace.useRef(false);
|
|
560
|
+
React__namespace.useEffect(function () {
|
|
561
561
|
return function () {
|
|
562
562
|
canResetObservableRef.current = true;
|
|
563
563
|
};
|
|
564
564
|
}, []);
|
|
565
|
-
var ref =
|
|
566
|
-
|
|
565
|
+
var ref = React__namespace.useRef({ client: client, subscription: subscription, options: options });
|
|
566
|
+
React__namespace.useEffect(function () {
|
|
567
567
|
var _a, _b, _c, _d;
|
|
568
568
|
var shouldResubscribe = options === null || options === void 0 ? void 0 : options.shouldResubscribe;
|
|
569
569
|
if (typeof shouldResubscribe === 'function') {
|
|
@@ -604,7 +604,7 @@ function useSubscription(subscription, options) {
|
|
|
604
604
|
}
|
|
605
605
|
Object.assign(ref.current, { client: client, subscription: subscription, options: options });
|
|
606
606
|
}, [client, subscription, options, canResetObservableRef.current]);
|
|
607
|
-
|
|
607
|
+
React__namespace.useEffect(function () {
|
|
608
608
|
if (!observable) {
|
|
609
609
|
return;
|
|
610
610
|
}
|
|
@@ -671,8 +671,8 @@ function useSubscription(subscription, options) {
|
|
|
671
671
|
|
|
672
672
|
function useReactiveVar(rv) {
|
|
673
673
|
var value = rv();
|
|
674
|
-
var setValue =
|
|
675
|
-
|
|
674
|
+
var setValue = React__namespace.useState(value)[1];
|
|
675
|
+
React__namespace.useEffect(function () {
|
|
676
676
|
var probablySameValue = rv();
|
|
677
677
|
if (value !== probablySameValue) {
|
|
678
678
|
setValue(probablySameValue);
|
|
@@ -688,7 +688,7 @@ function useFragment(options) {
|
|
|
688
688
|
var cache = useApolloClient().cache;
|
|
689
689
|
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"]);
|
|
690
690
|
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
691
|
-
var resultRef =
|
|
691
|
+
var resultRef = React__namespace.useRef();
|
|
692
692
|
var latestDiff = cache.diff(diffOptions);
|
|
693
693
|
var getSnapshot = function () {
|
|
694
694
|
var latestDiffToResult = diffToResult(latestDiff);
|
|
@@ -718,25 +718,15 @@ function diffToResult(diff) {
|
|
|
718
718
|
}
|
|
719
719
|
|
|
720
720
|
function useDeepMemo(memoFn, deps) {
|
|
721
|
-
var ref =
|
|
721
|
+
var ref = React__namespace.useRef();
|
|
722
722
|
if (!ref.current || !equality.equal(ref.current.deps, deps)) {
|
|
723
723
|
ref.current = { value: memoFn(), deps: deps };
|
|
724
724
|
}
|
|
725
725
|
return ref.current.value;
|
|
726
726
|
}
|
|
727
727
|
|
|
728
|
-
function useStrictModeSafeCleanupEffect(cleanup) {
|
|
729
|
-
var timeout;
|
|
730
|
-
React.useEffect(function () {
|
|
731
|
-
clearTimeout(timeout);
|
|
732
|
-
return function () {
|
|
733
|
-
timeout = setTimeout(cleanup);
|
|
734
|
-
};
|
|
735
|
-
}, []);
|
|
736
|
-
}
|
|
737
|
-
|
|
738
728
|
var useKey = 'use';
|
|
739
|
-
var realHook =
|
|
729
|
+
var realHook = React__namespace[useKey];
|
|
740
730
|
var __use = realHook ||
|
|
741
731
|
function __use(promise) {
|
|
742
732
|
var statefulPromise = utilities.wrapPromiseWithState(promise);
|
|
@@ -750,25 +740,227 @@ var __use = realHook ||
|
|
|
750
740
|
}
|
|
751
741
|
};
|
|
752
742
|
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
743
|
+
var QUERY_REFERENCE_SYMBOL = Symbol();
|
|
744
|
+
var OBSERVED_CHANGED_OPTIONS = [
|
|
745
|
+
'canonizeResults',
|
|
746
|
+
'context',
|
|
747
|
+
'errorPolicy',
|
|
748
|
+
'fetchPolicy',
|
|
749
|
+
'refetchWritePolicy',
|
|
750
|
+
'returnPartialData',
|
|
751
|
+
];
|
|
752
|
+
var InternalQueryReference = (function () {
|
|
753
|
+
function InternalQueryReference(observable, options) {
|
|
754
|
+
var _this = this;
|
|
755
|
+
var _a;
|
|
756
|
+
this.listeners = new Set();
|
|
757
|
+
this.status = 'loading';
|
|
758
|
+
this.references = 0;
|
|
759
|
+
this.listen = this.listen.bind(this);
|
|
760
|
+
this.handleNext = this.handleNext.bind(this);
|
|
761
|
+
this.handleError = this.handleError.bind(this);
|
|
762
|
+
this.initiateFetch = this.initiateFetch.bind(this);
|
|
763
|
+
this.dispose = this.dispose.bind(this);
|
|
764
|
+
this.observable = observable;
|
|
765
|
+
this.result = observable.getCurrentResult(false);
|
|
766
|
+
this.key = options.key;
|
|
767
|
+
if (options.onDispose) {
|
|
768
|
+
this.onDispose = options.onDispose;
|
|
769
|
+
}
|
|
770
|
+
if (core.isNetworkRequestSettled(this.result.networkStatus) ||
|
|
771
|
+
(this.result.data &&
|
|
772
|
+
(!this.result.partial || this.watchQueryOptions.returnPartialData))) {
|
|
773
|
+
this.promise = utilities.createFulfilledPromise(this.result);
|
|
774
|
+
this.status = 'idle';
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
778
|
+
_this.resolve = resolve;
|
|
779
|
+
_this.reject = reject;
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
this.subscription = observable
|
|
783
|
+
.filter(function (_a) {
|
|
784
|
+
var data = _a.data;
|
|
785
|
+
return !equality.equal(data, {});
|
|
786
|
+
})
|
|
787
|
+
.subscribe({
|
|
788
|
+
next: this.handleNext,
|
|
789
|
+
error: this.handleError,
|
|
790
|
+
});
|
|
791
|
+
this.autoDisposeTimeoutId = setTimeout(this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
|
|
792
|
+
}
|
|
793
|
+
Object.defineProperty(InternalQueryReference.prototype, "watchQueryOptions", {
|
|
794
|
+
get: function () {
|
|
795
|
+
return this.observable.options;
|
|
796
|
+
},
|
|
797
|
+
enumerable: false,
|
|
798
|
+
configurable: true
|
|
799
|
+
});
|
|
800
|
+
InternalQueryReference.prototype.retain = function () {
|
|
801
|
+
var _this = this;
|
|
802
|
+
this.references++;
|
|
803
|
+
clearTimeout(this.autoDisposeTimeoutId);
|
|
804
|
+
var disposed = false;
|
|
805
|
+
return function () {
|
|
806
|
+
if (disposed) {
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
disposed = true;
|
|
810
|
+
_this.references--;
|
|
811
|
+
setTimeout(function () {
|
|
812
|
+
if (!_this.references) {
|
|
813
|
+
_this.dispose();
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
};
|
|
817
|
+
};
|
|
818
|
+
InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {
|
|
819
|
+
var _this = this;
|
|
820
|
+
return OBSERVED_CHANGED_OPTIONS.some(function (option) {
|
|
821
|
+
return !equality.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
|
|
822
|
+
});
|
|
823
|
+
};
|
|
824
|
+
InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {
|
|
825
|
+
var _a = this.watchQueryOptions, currentFetchPolicy = _a.fetchPolicy, currentCanonizeResults = _a.canonizeResults;
|
|
826
|
+
if (currentFetchPolicy === 'standby' &&
|
|
827
|
+
currentFetchPolicy !== watchQueryOptions.fetchPolicy) {
|
|
828
|
+
this.observable.reobserve(watchQueryOptions);
|
|
829
|
+
this.initiateFetch();
|
|
830
|
+
}
|
|
831
|
+
else {
|
|
832
|
+
this.observable.silentSetOptions(watchQueryOptions);
|
|
833
|
+
if (currentCanonizeResults !== watchQueryOptions.canonizeResults) {
|
|
834
|
+
this.result = tslib.__assign(tslib.__assign({}, this.result), this.observable.getCurrentResult());
|
|
835
|
+
this.promise = utilities.createFulfilledPromise(this.result);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return this.promise;
|
|
839
|
+
};
|
|
840
|
+
InternalQueryReference.prototype.listen = function (listener) {
|
|
841
|
+
var _this = this;
|
|
842
|
+
this.listeners.add(listener);
|
|
843
|
+
return function () {
|
|
844
|
+
_this.listeners.delete(listener);
|
|
845
|
+
};
|
|
846
|
+
};
|
|
847
|
+
InternalQueryReference.prototype.refetch = function (variables) {
|
|
848
|
+
var promise = this.observable.refetch(variables);
|
|
849
|
+
this.initiateFetch();
|
|
850
|
+
return promise;
|
|
851
|
+
};
|
|
852
|
+
InternalQueryReference.prototype.fetchMore = function (options) {
|
|
853
|
+
var promise = this.observable.fetchMore(options);
|
|
854
|
+
this.initiateFetch();
|
|
855
|
+
return promise;
|
|
856
|
+
};
|
|
857
|
+
InternalQueryReference.prototype.dispose = function () {
|
|
858
|
+
this.subscription.unsubscribe();
|
|
859
|
+
this.onDispose();
|
|
860
|
+
};
|
|
861
|
+
InternalQueryReference.prototype.onDispose = function () {
|
|
862
|
+
};
|
|
863
|
+
InternalQueryReference.prototype.handleNext = function (result) {
|
|
864
|
+
var _a;
|
|
865
|
+
switch (this.status) {
|
|
866
|
+
case 'loading': {
|
|
867
|
+
if (result.data === void 0) {
|
|
868
|
+
result.data = this.result.data;
|
|
869
|
+
}
|
|
870
|
+
this.status = 'idle';
|
|
871
|
+
this.result = result;
|
|
872
|
+
(_a = this.resolve) === null || _a === void 0 ? void 0 : _a.call(this, result);
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
case 'idle': {
|
|
876
|
+
if (result.data === this.result.data) {
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
if (result.data === void 0) {
|
|
880
|
+
result.data = this.result.data;
|
|
881
|
+
}
|
|
882
|
+
this.result = result;
|
|
883
|
+
this.promise = utilities.createFulfilledPromise(result);
|
|
884
|
+
this.deliver(this.promise);
|
|
885
|
+
break;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
InternalQueryReference.prototype.handleError = function (error) {
|
|
890
|
+
var _a;
|
|
891
|
+
switch (this.status) {
|
|
892
|
+
case 'loading': {
|
|
893
|
+
this.status = 'idle';
|
|
894
|
+
(_a = this.reject) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
895
|
+
break;
|
|
896
|
+
}
|
|
897
|
+
case 'idle': {
|
|
898
|
+
this.promise = utilities.createRejectedPromise(error);
|
|
899
|
+
this.deliver(this.promise);
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
InternalQueryReference.prototype.deliver = function (promise) {
|
|
904
|
+
this.listeners.forEach(function (listener) { return listener(promise); });
|
|
905
|
+
};
|
|
906
|
+
InternalQueryReference.prototype.initiateFetch = function () {
|
|
907
|
+
var _this = this;
|
|
908
|
+
this.status = 'loading';
|
|
909
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
910
|
+
_this.resolve = resolve;
|
|
911
|
+
_this.reject = reject;
|
|
912
|
+
});
|
|
913
|
+
this.promise.catch(function () { });
|
|
914
|
+
};
|
|
915
|
+
return InternalQueryReference;
|
|
916
|
+
}());
|
|
917
|
+
|
|
918
|
+
var SuspenseCache = (function () {
|
|
919
|
+
function SuspenseCache(options) {
|
|
920
|
+
if (options === void 0) { options = Object.create(null); }
|
|
921
|
+
this.queryRefs = new trie.Trie(utilities.canUseWeakMap);
|
|
922
|
+
this.options = options;
|
|
923
|
+
}
|
|
924
|
+
SuspenseCache.prototype.getQueryRef = function (cacheKey, createObservable) {
|
|
925
|
+
var ref = this.queryRefs.lookupArray(cacheKey);
|
|
926
|
+
if (!ref.current) {
|
|
927
|
+
ref.current = new InternalQueryReference(createObservable(), {
|
|
928
|
+
key: cacheKey,
|
|
929
|
+
autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
|
|
930
|
+
onDispose: function () {
|
|
931
|
+
delete ref.current;
|
|
932
|
+
},
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
return ref.current;
|
|
936
|
+
};
|
|
937
|
+
return SuspenseCache;
|
|
938
|
+
}());
|
|
939
|
+
|
|
940
|
+
var suspenseCacheSymbol = Symbol.for('apollo.suspenseCache');
|
|
941
|
+
function getSuspenseCache(client) {
|
|
942
|
+
var _a;
|
|
943
|
+
if (!client[suspenseCacheSymbol]) {
|
|
944
|
+
client[suspenseCacheSymbol] = new SuspenseCache((_a = client.defaultOptions.react) === null || _a === void 0 ? void 0 : _a.suspense);
|
|
945
|
+
}
|
|
946
|
+
return client[suspenseCacheSymbol];
|
|
758
947
|
}
|
|
759
948
|
|
|
760
949
|
function useSuspenseQuery(query, options) {
|
|
761
950
|
if (options === void 0) { options = Object.create(null); }
|
|
762
951
|
var client = useApolloClient(options.client);
|
|
763
|
-
var suspenseCache =
|
|
952
|
+
var suspenseCache = getSuspenseCache(client);
|
|
764
953
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
765
954
|
var fetchPolicy = watchQueryOptions.fetchPolicy, variables = watchQueryOptions.variables;
|
|
766
955
|
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
767
|
-
var cacheKey =
|
|
956
|
+
var cacheKey = tslib.__spreadArray([
|
|
957
|
+
query,
|
|
958
|
+
cache.canonicalStringify(variables)
|
|
959
|
+
], [].concat(queryKey), true);
|
|
768
960
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
769
961
|
return client.watchQuery(watchQueryOptions);
|
|
770
962
|
});
|
|
771
|
-
var _b =
|
|
963
|
+
var _b = React__namespace.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
772
964
|
var promise = promiseCache.get(queryRef.key);
|
|
773
965
|
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
774
966
|
promise = queryRef.applyOptions(watchQueryOptions);
|
|
@@ -778,15 +970,19 @@ function useSuspenseQuery(query, options) {
|
|
|
778
970
|
promise = queryRef.promise;
|
|
779
971
|
promiseCache.set(queryRef.key, promise);
|
|
780
972
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
973
|
+
React__namespace.useEffect(function () {
|
|
974
|
+
var dispose = queryRef.retain();
|
|
975
|
+
var removeListener = queryRef.listen(function (promise) {
|
|
784
976
|
setPromiseCache(function (promiseCache) {
|
|
785
977
|
return new Map(promiseCache).set(queryRef.key, promise);
|
|
786
978
|
});
|
|
787
979
|
});
|
|
980
|
+
return function () {
|
|
981
|
+
removeListener();
|
|
982
|
+
dispose();
|
|
983
|
+
};
|
|
788
984
|
}, [queryRef]);
|
|
789
|
-
var skipResult =
|
|
985
|
+
var skipResult = React__namespace.useMemo(function () {
|
|
790
986
|
var error = toApolloError(queryRef.result);
|
|
791
987
|
return {
|
|
792
988
|
loading: false,
|
|
@@ -796,22 +992,22 @@ function useSuspenseQuery(query, options) {
|
|
|
796
992
|
};
|
|
797
993
|
}, [queryRef.result]);
|
|
798
994
|
var result = fetchPolicy === 'standby' ? skipResult : __use(promise);
|
|
799
|
-
var fetchMore =
|
|
995
|
+
var fetchMore = React__namespace.useCallback(function (options) {
|
|
800
996
|
var promise = queryRef.fetchMore(options);
|
|
801
997
|
setPromiseCache(function (previousPromiseCache) {
|
|
802
|
-
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
998
|
+
return new Map(previousPromiseCache).set(queryRef.key, queryRef.promise);
|
|
803
999
|
});
|
|
804
1000
|
return promise;
|
|
805
1001
|
}, [queryRef]);
|
|
806
|
-
var refetch =
|
|
1002
|
+
var refetch = React__namespace.useCallback(function (variables) {
|
|
807
1003
|
var promise = queryRef.refetch(variables);
|
|
808
1004
|
setPromiseCache(function (previousPromiseCache) {
|
|
809
|
-
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
1005
|
+
return new Map(previousPromiseCache).set(queryRef.key, queryRef.promise);
|
|
810
1006
|
});
|
|
811
1007
|
return promise;
|
|
812
1008
|
}, [queryRef]);
|
|
813
|
-
var subscribeToMore =
|
|
814
|
-
return
|
|
1009
|
+
var subscribeToMore = React__namespace.useCallback(function (options) { return queryRef.observable.subscribeToMore(options); }, [queryRef]);
|
|
1010
|
+
return React__namespace.useMemo(function () {
|
|
815
1011
|
return {
|
|
816
1012
|
client: client,
|
|
817
1013
|
data: result.data,
|
|
@@ -837,11 +1033,11 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
837
1033
|
'no-cache',
|
|
838
1034
|
'cache-and-network',
|
|
839
1035
|
];
|
|
840
|
-
globals.invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
1036
|
+
globals.invariant(supportedFetchPolicies.includes(fetchPolicy), 54, fetchPolicy);
|
|
841
1037
|
}
|
|
842
1038
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
843
1039
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
844
|
-
|
|
1040
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(55);
|
|
845
1041
|
}
|
|
846
1042
|
}
|
|
847
1043
|
function toApolloError(result) {
|
|
@@ -849,13 +1045,6 @@ function toApolloError(result) {
|
|
|
849
1045
|
? new core.ApolloError({ graphQLErrors: result.errors })
|
|
850
1046
|
: result.error;
|
|
851
1047
|
}
|
|
852
|
-
function useTrackedQueryRefs(queryRef) {
|
|
853
|
-
var trackedQueryRefs = React.useRef(new Set());
|
|
854
|
-
trackedQueryRefs.current.add(queryRef);
|
|
855
|
-
useStrictModeSafeCleanupEffect(function () {
|
|
856
|
-
trackedQueryRefs.current.forEach(function (sub) { return sub.dispose(); });
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
1048
|
function useWatchQueryOptions(_a) {
|
|
860
1049
|
var client = _a.client, query = _a.query, options = _a.options;
|
|
861
1050
|
return useDeepMemo(function () {
|
|
@@ -864,7 +1053,7 @@ function useWatchQueryOptions(_a) {
|
|
|
864
1053
|
((_a = client.defaultOptions.watchQuery) === null || _a === void 0 ? void 0 : _a.fetchPolicy) ||
|
|
865
1054
|
'cache-first';
|
|
866
1055
|
var watchQueryOptions = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: fetchPolicy, query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 });
|
|
867
|
-
if (
|
|
1056
|
+
if (globalThis.__DEV__ !== false) {
|
|
868
1057
|
validateOptions(watchQueryOptions);
|
|
869
1058
|
}
|
|
870
1059
|
if (options.skip) {
|
|
@@ -874,183 +1063,42 @@ function useWatchQueryOptions(_a) {
|
|
|
874
1063
|
}, [client, options, query]);
|
|
875
1064
|
}
|
|
876
1065
|
|
|
877
|
-
var QUERY_REFERENCE_SYMBOL = Symbol();
|
|
878
|
-
var OBSERVED_CHANGED_OPTIONS = [
|
|
879
|
-
'canonizeResults',
|
|
880
|
-
'context',
|
|
881
|
-
'errorPolicy',
|
|
882
|
-
'fetchPolicy',
|
|
883
|
-
'refetchWritePolicy',
|
|
884
|
-
'returnPartialData',
|
|
885
|
-
];
|
|
886
|
-
((function () {
|
|
887
|
-
function InternalQueryReference(observable, options) {
|
|
888
|
-
var _this = this;
|
|
889
|
-
var _a;
|
|
890
|
-
this.listeners = new Set();
|
|
891
|
-
this.initialized = false;
|
|
892
|
-
this.refetching = false;
|
|
893
|
-
this.listen = this.listen.bind(this);
|
|
894
|
-
this.handleNext = this.handleNext.bind(this);
|
|
895
|
-
this.handleError = this.handleError.bind(this);
|
|
896
|
-
this.dispose = this.dispose.bind(this);
|
|
897
|
-
this.observable = observable;
|
|
898
|
-
this.result = observable.getCurrentResult(false);
|
|
899
|
-
this.key = options.key;
|
|
900
|
-
if (options.onDispose) {
|
|
901
|
-
this.onDispose = options.onDispose;
|
|
902
|
-
}
|
|
903
|
-
if (core.isNetworkRequestSettled(this.result.networkStatus) ||
|
|
904
|
-
(this.result.data &&
|
|
905
|
-
(!this.result.partial || this.observable.options.returnPartialData))) {
|
|
906
|
-
this.promise = utilities.createFulfilledPromise(this.result);
|
|
907
|
-
this.initialized = true;
|
|
908
|
-
this.refetching = false;
|
|
909
|
-
}
|
|
910
|
-
this.subscription = observable.subscribe({
|
|
911
|
-
next: this.handleNext,
|
|
912
|
-
error: this.handleError,
|
|
913
|
-
});
|
|
914
|
-
if (!this.promise) {
|
|
915
|
-
this.promise = new Promise(function (resolve, reject) {
|
|
916
|
-
_this.resolve = resolve;
|
|
917
|
-
_this.reject = reject;
|
|
918
|
-
});
|
|
919
|
-
}
|
|
920
|
-
this.autoDisposeTimeoutId = setTimeout(this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
|
|
921
|
-
}
|
|
922
|
-
Object.defineProperty(InternalQueryReference.prototype, "watchQueryOptions", {
|
|
923
|
-
get: function () {
|
|
924
|
-
return this.observable.options;
|
|
925
|
-
},
|
|
926
|
-
enumerable: false,
|
|
927
|
-
configurable: true
|
|
928
|
-
});
|
|
929
|
-
InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {
|
|
930
|
-
var _this = this;
|
|
931
|
-
return OBSERVED_CHANGED_OPTIONS.some(function (option) {
|
|
932
|
-
return !equality.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
|
|
933
|
-
});
|
|
934
|
-
};
|
|
935
|
-
InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {
|
|
936
|
-
var currentFetchPolicy = this.watchQueryOptions.fetchPolicy;
|
|
937
|
-
if (currentFetchPolicy === 'standby' &&
|
|
938
|
-
currentFetchPolicy !== watchQueryOptions.fetchPolicy) {
|
|
939
|
-
this.promise = this.observable.reobserve(watchQueryOptions);
|
|
940
|
-
}
|
|
941
|
-
else {
|
|
942
|
-
this.observable.silentSetOptions(watchQueryOptions);
|
|
943
|
-
this.result = tslib.__assign(tslib.__assign({}, this.result), this.observable.getCurrentResult());
|
|
944
|
-
this.promise = utilities.createFulfilledPromise(this.result);
|
|
945
|
-
}
|
|
946
|
-
return this.promise;
|
|
947
|
-
};
|
|
948
|
-
InternalQueryReference.prototype.listen = function (listener) {
|
|
949
|
-
var _this = this;
|
|
950
|
-
clearTimeout(this.autoDisposeTimeoutId);
|
|
951
|
-
this.listeners.add(listener);
|
|
952
|
-
return function () {
|
|
953
|
-
_this.listeners.delete(listener);
|
|
954
|
-
};
|
|
955
|
-
};
|
|
956
|
-
InternalQueryReference.prototype.refetch = function (variables) {
|
|
957
|
-
this.refetching = true;
|
|
958
|
-
var promise = this.observable.refetch(variables);
|
|
959
|
-
this.promise = promise;
|
|
960
|
-
return promise;
|
|
961
|
-
};
|
|
962
|
-
InternalQueryReference.prototype.fetchMore = function (options) {
|
|
963
|
-
var promise = this.observable.fetchMore(options);
|
|
964
|
-
this.promise = promise;
|
|
965
|
-
return promise;
|
|
966
|
-
};
|
|
967
|
-
InternalQueryReference.prototype.reobserve = function (watchQueryOptions) {
|
|
968
|
-
var promise = this.observable.reobserve(watchQueryOptions);
|
|
969
|
-
this.promise = promise;
|
|
970
|
-
return promise;
|
|
971
|
-
};
|
|
972
|
-
InternalQueryReference.prototype.dispose = function () {
|
|
973
|
-
this.subscription.unsubscribe();
|
|
974
|
-
this.onDispose();
|
|
975
|
-
};
|
|
976
|
-
InternalQueryReference.prototype.onDispose = function () {
|
|
977
|
-
};
|
|
978
|
-
InternalQueryReference.prototype.handleNext = function (result) {
|
|
979
|
-
if (!this.initialized || this.refetching) {
|
|
980
|
-
if (!core.isNetworkRequestSettled(result.networkStatus)) {
|
|
981
|
-
return;
|
|
982
|
-
}
|
|
983
|
-
if (this.result.data && result.data === void 0) {
|
|
984
|
-
result.data = this.result.data;
|
|
985
|
-
}
|
|
986
|
-
this.initialized = true;
|
|
987
|
-
this.refetching = false;
|
|
988
|
-
this.result = result;
|
|
989
|
-
if (this.resolve) {
|
|
990
|
-
this.resolve(result);
|
|
991
|
-
}
|
|
992
|
-
return;
|
|
993
|
-
}
|
|
994
|
-
if (result.data === this.result.data) {
|
|
995
|
-
return;
|
|
996
|
-
}
|
|
997
|
-
this.result = result;
|
|
998
|
-
this.promise = utilities.createFulfilledPromise(result);
|
|
999
|
-
this.deliver(this.promise);
|
|
1000
|
-
};
|
|
1001
|
-
InternalQueryReference.prototype.handleError = function (error) {
|
|
1002
|
-
var result = tslib.__assign(tslib.__assign({}, this.result), { error: error, networkStatus: core.NetworkStatus.error });
|
|
1003
|
-
this.result = result;
|
|
1004
|
-
if (!this.initialized || this.refetching) {
|
|
1005
|
-
this.initialized = true;
|
|
1006
|
-
this.refetching = false;
|
|
1007
|
-
if (this.reject) {
|
|
1008
|
-
this.reject(error);
|
|
1009
|
-
}
|
|
1010
|
-
return;
|
|
1011
|
-
}
|
|
1012
|
-
this.promise = utilities.createRejectedPromise(error);
|
|
1013
|
-
this.deliver(this.promise);
|
|
1014
|
-
};
|
|
1015
|
-
InternalQueryReference.prototype.deliver = function (promise) {
|
|
1016
|
-
this.listeners.forEach(function (listener) { return listener(promise); });
|
|
1017
|
-
};
|
|
1018
|
-
return InternalQueryReference;
|
|
1019
|
-
})());
|
|
1020
|
-
|
|
1021
1066
|
function useBackgroundQuery(query, options) {
|
|
1022
1067
|
if (options === void 0) { options = Object.create(null); }
|
|
1023
|
-
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
1024
1068
|
var client = useApolloClient(options.client);
|
|
1069
|
+
var suspenseCache = getSuspenseCache(client);
|
|
1025
1070
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
1026
1071
|
var variables = watchQueryOptions.variables;
|
|
1027
1072
|
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
1028
|
-
var cacheKey =
|
|
1073
|
+
var cacheKey = tslib.__spreadArray([
|
|
1074
|
+
query,
|
|
1075
|
+
cache.canonicalStringify(variables)
|
|
1076
|
+
], [].concat(queryKey), true);
|
|
1029
1077
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
1030
1078
|
return client.watchQuery(watchQueryOptions);
|
|
1031
1079
|
});
|
|
1032
|
-
var _b =
|
|
1080
|
+
var _b = React__namespace.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
1033
1081
|
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
1034
1082
|
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
1035
1083
|
promiseCache.set(queryRef.key, promise);
|
|
1036
1084
|
}
|
|
1037
|
-
|
|
1038
|
-
var fetchMore =
|
|
1085
|
+
React__namespace.useEffect(function () { return queryRef.retain(); }, [queryRef]);
|
|
1086
|
+
var fetchMore = React__namespace.useCallback(function (options) {
|
|
1039
1087
|
var promise = queryRef.fetchMore(options);
|
|
1040
1088
|
setPromiseCache(function (promiseCache) {
|
|
1041
|
-
return new Map(promiseCache).set(queryRef.key, promise);
|
|
1089
|
+
return new Map(promiseCache).set(queryRef.key, queryRef.promise);
|
|
1042
1090
|
});
|
|
1043
1091
|
return promise;
|
|
1044
1092
|
}, [queryRef]);
|
|
1045
|
-
var refetch =
|
|
1093
|
+
var refetch = React__namespace.useCallback(function (variables) {
|
|
1046
1094
|
var promise = queryRef.refetch(variables);
|
|
1047
1095
|
setPromiseCache(function (promiseCache) {
|
|
1048
|
-
return new Map(promiseCache).set(queryRef.key, promise);
|
|
1096
|
+
return new Map(promiseCache).set(queryRef.key, queryRef.promise);
|
|
1049
1097
|
});
|
|
1050
1098
|
return promise;
|
|
1051
1099
|
}, [queryRef]);
|
|
1052
1100
|
queryRef.promiseCache = promiseCache;
|
|
1053
|
-
return
|
|
1101
|
+
return React__namespace.useMemo(function () {
|
|
1054
1102
|
var _a;
|
|
1055
1103
|
return [
|
|
1056
1104
|
(_a = {}, _a[QUERY_REFERENCE_SYMBOL] = queryRef, _a),
|
|
@@ -1063,10 +1111,10 @@ function useBackgroundQuery(query, options) {
|
|
|
1063
1111
|
}
|
|
1064
1112
|
|
|
1065
1113
|
function useReadQuery(queryRef) {
|
|
1066
|
-
var _a =
|
|
1114
|
+
var _a = React__namespace.useState(0), forceUpdate = _a[1];
|
|
1067
1115
|
var internalQueryRef = queryRef[QUERY_REFERENCE_SYMBOL];
|
|
1068
1116
|
invariant__default(internalQueryRef.promiseCache, 49);
|
|
1069
|
-
var skipResult =
|
|
1117
|
+
var skipResult = React__namespace.useMemo(function () {
|
|
1070
1118
|
var error = toApolloError(internalQueryRef.result);
|
|
1071
1119
|
return {
|
|
1072
1120
|
loading: false,
|
|
@@ -1080,7 +1128,7 @@ function useReadQuery(queryRef) {
|
|
|
1080
1128
|
promise = internalQueryRef.promise;
|
|
1081
1129
|
internalQueryRef.promiseCache.set(internalQueryRef.key, promise);
|
|
1082
1130
|
}
|
|
1083
|
-
|
|
1131
|
+
React__namespace.useEffect(function () {
|
|
1084
1132
|
return internalQueryRef.listen(function (promise) {
|
|
1085
1133
|
internalQueryRef.promiseCache.set(internalQueryRef.key, promise);
|
|
1086
1134
|
forceUpdate(function (prevState) { return prevState + 1; });
|
|
@@ -1089,7 +1137,7 @@ function useReadQuery(queryRef) {
|
|
|
1089
1137
|
var result = internalQueryRef.watchQueryOptions.fetchPolicy === 'standby'
|
|
1090
1138
|
? skipResult
|
|
1091
1139
|
: __use(promise);
|
|
1092
|
-
return
|
|
1140
|
+
return React__namespace.useMemo(function () {
|
|
1093
1141
|
return {
|
|
1094
1142
|
data: result.data,
|
|
1095
1143
|
networkStatus: result.networkStatus,
|