@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
|
@@ -1 +1 @@
|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CAAC,OAAO,CAAC,kBAAkB,CAAC;wBACrC,MAAM,QAAA;wBACN,gBAAgB,EAAE,MAAM;qBACzB,CAAC,CAAC;iBACJ;YACH,CAAC;YACD,KAAK,YAAC,KAAK;;gBACT,IAAI,CAAC,mBAAmB,EAAE;oBACxB,SAAS,CAAC;wBACR,OAAO,EAAE,KAAK;wBACd,IAAI,EAAE,KAAK,CAAC;wBACZ,KAAK,OAAA;wBACL,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS;qBAC9B,CAAC,CAAC;oBACH,MAAA,MAAA,GAAG,CAAC,OAAO,CAAC,OAAO,0CAAE,OAAO,mDAAG,KAAK,CAAC,CAAC;iBACvC;gBAAA,CAAC;YACJ,CAAC;YACD,QAAQ;;gBACN,IAAI,CAAC,mBAAmB,EAAE;oBACxB,IAAI,MAAA,GAAG,CAAC,OAAO,CAAC,OAAO,0CAAE,UAAU,EAAE;wBACnC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;qBAClC;yBAAM,IAAI,MAAA,GAAG,CAAC,OAAO,CAAC,OAAO,0CAAE,sBAAsB,EAAE;wBACtD,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;qBAC9C;iBACF;YACH,CAAC;SACF,CAAC,CAAC;QAEH,OAAO;YAIL,mBAAmB,GAAG,IAAI,CAAC;YAC3B,UAAU,CAAC;gBACT,YAAY,CAAC,WAAW,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals';\nimport { useState, useRef, useEffect } from 'react';\nimport type { DocumentNode } from 'graphql';\nimport type { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport { equal } from '@wry/equality';\n\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport type {\n NoInfer,\n SubscriptionHookOptions,\n SubscriptionResult\n} from '../types/types';\nimport type { OperationVariables } from '../../core';\nimport { useApolloClient } from './useApolloClient';\n\nexport function useSubscription<TData = any, TVariables extends OperationVariables = OperationVariables>(\n subscription: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SubscriptionHookOptions<NoInfer<TData>, NoInfer<TVariables>>,\n) {\n const hasIssuedDeprecationWarningRef = useRef(false);\n const client = useApolloClient(options?.client);\n verifyDocumentType(subscription, DocumentType.Subscription);\n const [result, setResult] = useState<SubscriptionResult<TData, TVariables>>({\n loading: !options?.skip,\n error: void 0,\n data: void 0,\n variables: options?.variables,\n });\n\n if (!hasIssuedDeprecationWarningRef.current) {\n hasIssuedDeprecationWarningRef.current = true;\n\n if (options?.onSubscriptionData) {\n invariant.warn(\n options.onData\n ? \"'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used.\"\n : \"'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead.\"\n );\n }\n\n if (options?.onSubscriptionComplete) {\n invariant.warn(\n options.onComplete\n ? \"'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used.\"\n : \"'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead.\"\n );\n }\n }\n\n const [observable, setObservable] = useState(() => {\n if (options?.skip) {\n return null;\n }\n\n return client.subscribe({\n query: subscription,\n variables: options?.variables,\n fetchPolicy: options?.fetchPolicy,\n context: options?.context,\n });\n });\n\n const canResetObservableRef = useRef(false);\n useEffect(() => {\n return () => {\n canResetObservableRef.current = true;\n };\n }, []);\n\n const ref = useRef({ client, subscription, options });\n useEffect(() => {\n let shouldResubscribe = options?.shouldResubscribe;\n if (typeof shouldResubscribe === 'function') {\n shouldResubscribe = !!shouldResubscribe(options!);\n }\n\n if (options?.skip) {\n if (!options?.skip !== !ref.current.options?.skip || canResetObservableRef.current) {\n setResult({\n loading: false,\n data: void 0,\n error: void 0,\n variables: options?.variables,\n });\n setObservable(null);\n canResetObservableRef.current = false;\n }\n } else if (\n (shouldResubscribe !== false &&\n (client !== ref.current.client ||\n subscription !== ref.current.subscription ||\n options?.fetchPolicy !== ref.current.options?.fetchPolicy ||\n !options?.skip !== !ref.current.options?.skip ||\n !equal(options?.variables, ref.current.options?.variables))) ||\n canResetObservableRef.current\n ) {\n setResult({\n loading: true,\n data: void 0,\n error: void 0,\n variables: options?.variables,\n });\n setObservable(client.subscribe({\n query: subscription,\n variables: options?.variables,\n fetchPolicy: options?.fetchPolicy,\n context: options?.context,\n }));\n canResetObservableRef.current = false;\n }\n\n Object.assign(ref.current, { client, subscription, options });\n }, [client, subscription, options, canResetObservableRef.current]);\n\n useEffect(() => {\n if (!observable) {\n return;\n }\n\n let subscriptionStopped = false;\n const subscription = observable.subscribe({\n next(fetchResult) {\n if (subscriptionStopped) {\n return;\n }\n\n const result = {\n loading: false,\n // TODO: fetchResult.data can be null but SubscriptionResult.data\n // expects TData | undefined only\n data: fetchResult.data!,\n error: void 0,\n variables: options?.variables,\n };\n setResult(result);\n\n if (ref.current.options?.onData) {\n ref.current.options.onData({\n client,\n data: result\n });\n } else if (ref.current.options?.onSubscriptionData) {\n ref.current.options.onSubscriptionData({\n client,\n subscriptionData: result\n });\n }\n },\n error(error) {\n if (!subscriptionStopped) {\n setResult({\n loading: false,\n data: void 0,\n error,\n variables: options?.variables,\n });\n ref.current.options?.onError?.(error);\n };\n },\n complete() {\n if (!subscriptionStopped) {\n if (ref.current.options?.onComplete) {\n ref.current.options.onComplete();\n } else if (ref.current.options?.onSubscriptionComplete) {\n ref.current.options.onSubscriptionComplete();\n }\n }\n },\n });\n\n return () => {\n // immediately stop receiving subscription values, but do not unsubscribe\n // until after a short delay in case another useSubscription hook is\n // reusing the same underlying observable and is about to subscribe\n subscriptionStopped = true;\n setTimeout(() => {\n subscription.unsubscribe();\n });\n };\n }, [observable]);\n\n return result;\n}\n"]}
|
|
1
|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AAC,OAAO,0CAAE,kBAAkB,EAAE;oBAClD,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;wBACrC,MAAM,QAAA;wBACN,gBAAgB,EAAE,MAAM;qBACzB,CAAC,CAAC;iBACJ;YACH,CAAC;YACD,KAAK,YAAC,KAAK;;gBACT,IAAI,CAAC,mBAAmB,EAAE;oBACxB,SAAS,CAAC;wBACR,OAAO,EAAE,KAAK;wBACd,IAAI,EAAE,KAAK,CAAC;wBACZ,KAAK,OAAA;wBACL,SAAS,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS;qBAC9B,CAAC,CAAC;oBACH,MAAA,MAAA,GAAG,CAAC,OAAO,CAAC,OAAO,0CAAE,OAAO,mDAAG,KAAK,CAAC,CAAC;iBACvC;gBAAA,CAAC;YACJ,CAAC;YACD,QAAQ;;gBACN,IAAI,CAAC,mBAAmB,EAAE;oBACxB,IAAI,MAAA,GAAG,CAAC,OAAO,CAAC,OAAO,0CAAE,UAAU,EAAE;wBACnC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;qBAClC;yBAAM,IAAI,MAAA,GAAG,CAAC,OAAO,CAAC,OAAO,0CAAE,sBAAsB,EAAE;wBACtD,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;qBAC9C;iBACF;YACH,CAAC;SACF,CAAC,CAAC;QAEH,OAAO;YAIL,mBAAmB,GAAG,IAAI,CAAC;YAC3B,UAAU,CAAC;gBACT,YAAY,CAAC,WAAW,EAAE,CAAC;YAC7B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals/index.js';\nimport * as React from 'react';\nimport type { DocumentNode } from 'graphql';\nimport type { TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport { equal } from '@wry/equality';\n\nimport { DocumentType, verifyDocumentType } from '../parser/index.js';\nimport type {\n NoInfer,\n SubscriptionHookOptions,\n SubscriptionResult\n} from '../types/types.js';\nimport type { OperationVariables } from '../../core/index.js';\nimport { useApolloClient } from './useApolloClient.js';\n\nexport function useSubscription<TData = any, TVariables extends OperationVariables = OperationVariables>(\n subscription: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SubscriptionHookOptions<NoInfer<TData>, NoInfer<TVariables>>,\n) {\n const hasIssuedDeprecationWarningRef = React.useRef(false);\n const client = useApolloClient(options?.client);\n verifyDocumentType(subscription, DocumentType.Subscription);\n const [result, setResult] = React.useState<SubscriptionResult<TData, TVariables>>({\n loading: !options?.skip,\n error: void 0,\n data: void 0,\n variables: options?.variables,\n });\n\n if (!hasIssuedDeprecationWarningRef.current) {\n hasIssuedDeprecationWarningRef.current = true;\n\n if (options?.onSubscriptionData) {\n invariant.warn(\n options.onData\n ? \"'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used.\"\n : \"'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead.\"\n );\n }\n\n if (options?.onSubscriptionComplete) {\n invariant.warn(\n options.onComplete\n ? \"'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used.\"\n : \"'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead.\"\n );\n }\n }\n\n const [observable, setObservable] = React.useState(() => {\n if (options?.skip) {\n return null;\n }\n\n return client.subscribe({\n query: subscription,\n variables: options?.variables,\n fetchPolicy: options?.fetchPolicy,\n context: options?.context,\n });\n });\n\n const canResetObservableRef = React.useRef(false);\n React.useEffect(() => {\n return () => {\n canResetObservableRef.current = true;\n };\n }, []);\n\n const ref = React.useRef({ client, subscription, options });\n React.useEffect(() => {\n let shouldResubscribe = options?.shouldResubscribe;\n if (typeof shouldResubscribe === 'function') {\n shouldResubscribe = !!shouldResubscribe(options!);\n }\n\n if (options?.skip) {\n if (!options?.skip !== !ref.current.options?.skip || canResetObservableRef.current) {\n setResult({\n loading: false,\n data: void 0,\n error: void 0,\n variables: options?.variables,\n });\n setObservable(null);\n canResetObservableRef.current = false;\n }\n } else if (\n (shouldResubscribe !== false &&\n (client !== ref.current.client ||\n subscription !== ref.current.subscription ||\n options?.fetchPolicy !== ref.current.options?.fetchPolicy ||\n !options?.skip !== !ref.current.options?.skip ||\n !equal(options?.variables, ref.current.options?.variables))) ||\n canResetObservableRef.current\n ) {\n setResult({\n loading: true,\n data: void 0,\n error: void 0,\n variables: options?.variables,\n });\n setObservable(client.subscribe({\n query: subscription,\n variables: options?.variables,\n fetchPolicy: options?.fetchPolicy,\n context: options?.context,\n }));\n canResetObservableRef.current = false;\n }\n\n Object.assign(ref.current, { client, subscription, options });\n }, [client, subscription, options, canResetObservableRef.current]);\n\n React.useEffect(() => {\n if (!observable) {\n return;\n }\n\n let subscriptionStopped = false;\n const subscription = observable.subscribe({\n next(fetchResult) {\n if (subscriptionStopped) {\n return;\n }\n\n const result = {\n loading: false,\n // TODO: fetchResult.data can be null but SubscriptionResult.data\n // expects TData | undefined only\n data: fetchResult.data!,\n error: void 0,\n variables: options?.variables,\n };\n setResult(result);\n\n if (ref.current.options?.onData) {\n ref.current.options.onData({\n client,\n data: result\n });\n } else if (ref.current.options?.onSubscriptionData) {\n ref.current.options.onSubscriptionData({\n client,\n subscriptionData: result\n });\n }\n },\n error(error) {\n if (!subscriptionStopped) {\n setResult({\n loading: false,\n data: void 0,\n error,\n variables: options?.variables,\n });\n ref.current.options?.onError?.(error);\n };\n },\n complete() {\n if (!subscriptionStopped) {\n if (ref.current.options?.onComplete) {\n ref.current.options.onComplete();\n } else if (ref.current.options?.onSubscriptionComplete) {\n ref.current.options.onSubscriptionComplete();\n }\n }\n },\n });\n\n return () => {\n // immediately stop receiving subscription values, but do not unsubscribe\n // until after a short delay in case another useSubscription hook is\n // reusing the same underlying observable and is about to subscribe\n subscriptionStopped = true;\n setTimeout(() => {\n subscription.unsubscribe();\n });\n };\n }, [observable]);\n\n return result;\n}\n"]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type { ApolloClient, ApolloQueryResult, DocumentNode, OperationVariables, TypedDocumentNode, WatchQueryOptions, FetchMoreQueryOptions } from '../../core';
|
|
2
|
-
import { ApolloError, NetworkStatus } from '../../core';
|
|
3
|
-
import type { DeepPartial } from '../../utilities';
|
|
4
|
-
import type { SuspenseQueryHookOptions, ObservableQueryFields, NoInfer } from '../types/types';
|
|
5
|
-
import type { InternalQueryReference } from '../cache/QueryReference';
|
|
1
|
+
import type { ApolloClient, ApolloQueryResult, DocumentNode, OperationVariables, TypedDocumentNode, WatchQueryOptions, FetchMoreQueryOptions } from '../../core/index.js';
|
|
2
|
+
import { ApolloError, NetworkStatus } from '../../core/index.js';
|
|
3
|
+
import type { DeepPartial } from '../../utilities/index.js';
|
|
4
|
+
import type { SuspenseQueryHookOptions, ObservableQueryFields, NoInfer } from '../types/types.js';
|
|
6
5
|
export interface UseSuspenseQueryResult<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
|
|
7
6
|
client: ApolloClient<any>;
|
|
8
7
|
data: TData;
|
|
@@ -40,7 +39,6 @@ export declare function useSuspenseQuery<TData = unknown, TVariables extends Ope
|
|
|
40
39
|
}): UseSuspenseQueryResult<TData | undefined, TVariables>;
|
|
41
40
|
export declare function useSuspenseQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): UseSuspenseQueryResult<TData, TVariables>;
|
|
42
41
|
export declare function toApolloError(result: ApolloQueryResult<any>): ApolloError | undefined;
|
|
43
|
-
export declare function useTrackedQueryRefs(queryRef: InternalQueryReference): void;
|
|
44
42
|
interface UseWatchQueryOptionsHookOptions<TData, TVariables extends OperationVariables> {
|
|
45
43
|
client: ApolloClient<unknown>;
|
|
46
44
|
query: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAEjB,qBAAqB,EACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAEjB,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D,OAAO,KAAK,EACV,wBAAwB,EACxB,qBAAqB,EACrB,OAAO,EACR,MAAM,mBAAmB,CAAC;AAM3B,MAAM,WAAW,sBAAsB,CACrC,KAAK,GAAG,OAAO,EACf,UAAU,SAAS,kBAAkB,GAAG,kBAAkB;IAE1D,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAChD,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC5C,eAAe,EAAE,uBAAuB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;CAC7D;AAED,MAAM,MAAM,iBAAiB,CAAC,KAAK,EAAE,UAAU,SAAS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,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9B,KAAK,EAAE,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC3D,OAAO,EAAE,wBAAwB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;CACtD;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EACL,UAAU,SAAS,kBAAkB,EACrC,EACA,MAAM,EACN,KAAK,EACL,OAAO,GACR,EAAE,+BAA+B,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,iBAAiB,CACvE,UAAU,EACV,KAAK,CACN,CA2BA"}
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
|
-
import { invariant
|
|
3
|
-
import
|
|
4
|
-
import { ApolloError, NetworkStatus } from
|
|
5
|
-
import { isNonEmptyArray } from
|
|
6
|
-
import { useApolloClient } from
|
|
7
|
-
import { DocumentType, verifyDocumentType } from
|
|
8
|
-
import { useDeepMemo,
|
|
9
|
-
import {
|
|
10
|
-
import { canonicalStringify } from
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
2
|
+
import { invariant } from '../../utilities/globals/index.js';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ApolloError, NetworkStatus } from '../../core/index.js';
|
|
5
|
+
import { isNonEmptyArray } from '../../utilities/index.js';
|
|
6
|
+
import { useApolloClient } from './useApolloClient.js';
|
|
7
|
+
import { DocumentType, verifyDocumentType } from '../parser/index.js';
|
|
8
|
+
import { useDeepMemo, __use } from './internal/index.js';
|
|
9
|
+
import { getSuspenseCache } from '../cache/index.js';
|
|
10
|
+
import { canonicalStringify } from '../../cache/index.js';
|
|
11
11
|
export function useSuspenseQuery(query, options) {
|
|
12
12
|
if (options === void 0) { options = Object.create(null); }
|
|
13
13
|
var client = useApolloClient(options.client);
|
|
14
|
-
var suspenseCache =
|
|
14
|
+
var suspenseCache = getSuspenseCache(client);
|
|
15
15
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
16
16
|
var fetchPolicy = watchQueryOptions.fetchPolicy, variables = watchQueryOptions.variables;
|
|
17
17
|
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
18
|
-
var cacheKey = [
|
|
18
|
+
var cacheKey = __spreadArray([
|
|
19
|
+
query,
|
|
20
|
+
canonicalStringify(variables)
|
|
21
|
+
], [].concat(queryKey), true);
|
|
19
22
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
20
23
|
return client.watchQuery(watchQueryOptions);
|
|
21
24
|
});
|
|
22
|
-
var _b = useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
25
|
+
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
23
26
|
var promise = promiseCache.get(queryRef.key);
|
|
24
27
|
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
25
28
|
promise = queryRef.applyOptions(watchQueryOptions);
|
|
@@ -29,15 +32,19 @@ export function useSuspenseQuery(query, options) {
|
|
|
29
32
|
promise = queryRef.promise;
|
|
30
33
|
promiseCache.set(queryRef.key, promise);
|
|
31
34
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
React.useEffect(function () {
|
|
36
|
+
var dispose = queryRef.retain();
|
|
37
|
+
var removeListener = queryRef.listen(function (promise) {
|
|
35
38
|
setPromiseCache(function (promiseCache) {
|
|
36
39
|
return new Map(promiseCache).set(queryRef.key, promise);
|
|
37
40
|
});
|
|
38
41
|
});
|
|
42
|
+
return function () {
|
|
43
|
+
removeListener();
|
|
44
|
+
dispose();
|
|
45
|
+
};
|
|
39
46
|
}, [queryRef]);
|
|
40
|
-
var skipResult = useMemo(function () {
|
|
47
|
+
var skipResult = React.useMemo(function () {
|
|
41
48
|
var error = toApolloError(queryRef.result);
|
|
42
49
|
return {
|
|
43
50
|
loading: false,
|
|
@@ -47,22 +54,22 @@ export function useSuspenseQuery(query, options) {
|
|
|
47
54
|
};
|
|
48
55
|
}, [queryRef.result]);
|
|
49
56
|
var result = fetchPolicy === 'standby' ? skipResult : __use(promise);
|
|
50
|
-
var fetchMore = useCallback(function (options) {
|
|
57
|
+
var fetchMore = React.useCallback(function (options) {
|
|
51
58
|
var promise = queryRef.fetchMore(options);
|
|
52
59
|
setPromiseCache(function (previousPromiseCache) {
|
|
53
|
-
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
60
|
+
return new Map(previousPromiseCache).set(queryRef.key, queryRef.promise);
|
|
54
61
|
});
|
|
55
62
|
return promise;
|
|
56
63
|
}, [queryRef]);
|
|
57
|
-
var refetch = useCallback(function (variables) {
|
|
64
|
+
var refetch = React.useCallback(function (variables) {
|
|
58
65
|
var promise = queryRef.refetch(variables);
|
|
59
66
|
setPromiseCache(function (previousPromiseCache) {
|
|
60
|
-
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
67
|
+
return new Map(previousPromiseCache).set(queryRef.key, queryRef.promise);
|
|
61
68
|
});
|
|
62
69
|
return promise;
|
|
63
70
|
}, [queryRef]);
|
|
64
|
-
var subscribeToMore = useCallback(function (options) { return queryRef.observable.subscribeToMore(options); }, [queryRef]);
|
|
65
|
-
return useMemo(function () {
|
|
71
|
+
var subscribeToMore = React.useCallback(function (options) { return queryRef.observable.subscribeToMore(options); }, [queryRef]);
|
|
72
|
+
return React.useMemo(function () {
|
|
66
73
|
return {
|
|
67
74
|
client: client,
|
|
68
75
|
data: result.data,
|
|
@@ -88,11 +95,11 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
88
95
|
'no-cache',
|
|
89
96
|
'cache-and-network',
|
|
90
97
|
];
|
|
91
|
-
invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
98
|
+
invariant(supportedFetchPolicies.includes(fetchPolicy), 54, fetchPolicy);
|
|
92
99
|
}
|
|
93
100
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
94
101
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
95
|
-
__DEV__ && invariant.warn(
|
|
102
|
+
globalThis.__DEV__ !== false && invariant.warn(55);
|
|
96
103
|
}
|
|
97
104
|
}
|
|
98
105
|
export function toApolloError(result) {
|
|
@@ -100,13 +107,6 @@ export function toApolloError(result) {
|
|
|
100
107
|
? new ApolloError({ graphQLErrors: result.errors })
|
|
101
108
|
: result.error;
|
|
102
109
|
}
|
|
103
|
-
export function useTrackedQueryRefs(queryRef) {
|
|
104
|
-
var trackedQueryRefs = useRef(new Set());
|
|
105
|
-
trackedQueryRefs.current.add(queryRef);
|
|
106
|
-
useStrictModeSafeCleanupEffect(function () {
|
|
107
|
-
trackedQueryRefs.current.forEach(function (sub) { return sub.dispose(); });
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
110
|
export function useWatchQueryOptions(_a) {
|
|
111
111
|
var client = _a.client, query = _a.query, options = _a.options;
|
|
112
112
|
return useDeepMemo(function () {
|
|
@@ -115,7 +115,7 @@ export function useWatchQueryOptions(_a) {
|
|
|
115
115
|
((_a = client.defaultOptions.watchQuery) === null || _a === void 0 ? void 0 : _a.fetchPolicy) ||
|
|
116
116
|
'cache-first';
|
|
117
117
|
var watchQueryOptions = __assign(__assign({}, options), { fetchPolicy: fetchPolicy, query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 });
|
|
118
|
-
if (__DEV__) {
|
|
118
|
+
if (globalThis.__DEV__ !== false) {
|
|
119
119
|
validateOptions(watchQueryOptions);
|
|
120
120
|
}
|
|
121
121
|
if (options.skip) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSuspenseQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAA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G,MAAM,CAAC,IAAI,GAAG,EAA0B,CAAC,CAAC;IAEnE,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEvC,8BAA8B,CAAC;QAC7B,gBAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,UAAC,GAAG,IAAK,OAAA,GAAG,CAAC,OAAO,EAAE,EAAb,CAAa,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC;AAWD,MAAM,UAAU,oBAAoB,CAGlC,EAImD;QAHnD,MAAM,YAAA,EACN,KAAK,WAAA,EACL,OAAO,aAAA;IAKP,OAAO,WAAW,CAAuC;;QACvD,IAAM,WAAW,GACf,OAAO,CAAC,WAAW;aACnB,MAAA,MAAM,CAAC,cAAc,CAAC,UAAU,0CAAE,WAAW,CAAA;YAC7C,aAAa,CAAC;QAEhB,IAAM,iBAAiB,yBAClB,OAAO,KACV,WAAW,aAAA,EACX,KAAK,OAAA,EACL,2BAA2B,EAAE,KAAK,EAClC,eAAe,EAAE,KAAK,CAAC,GACxB,CAAC;QAEF,IAAI,OAAO,EAAE;YACX,eAAe,CAAC,iBAAiB,CAAC,CAAC;SACpC;QAID,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,iBAAiB,CAAC,WAAW,GAAG,SAAS,CAAC;SAC3C;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { invariant, __DEV__ } from '../../utilities/globals';\nimport { useRef, useCallback, useMemo, useEffect, useState } from 'react';\nimport type {\n ApolloClient,\n ApolloQueryResult,\n DocumentNode,\n OperationVariables,\n TypedDocumentNode,\n WatchQueryOptions,\n WatchQueryFetchPolicy,\n FetchMoreQueryOptions,\n} from '../../core';\nimport { ApolloError, NetworkStatus } from '../../core';\nimport type { DeepPartial } from '../../utilities';\nimport { isNonEmptyArray } from '../../utilities';\nimport { useApolloClient } from './useApolloClient';\nimport { DocumentType, verifyDocumentType } from '../parser';\nimport type {\n SuspenseQueryHookOptions,\n ObservableQueryFields,\n NoInfer,\n} from '../types/types';\nimport { useDeepMemo, useStrictModeSafeCleanupEffect, __use } from './internal';\nimport { useSuspenseCache } from './useSuspenseCache';\nimport type { InternalQueryReference } from '../cache/QueryReference';\nimport { canonicalStringify } from '../../cache';\n\nexport interface UseSuspenseQueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n> {\n client: ApolloClient<any>;\n data: TData;\n error: ApolloError | undefined;\n fetchMore: FetchMoreFunction<TData, TVariables>;\n networkStatus: NetworkStatus;\n refetch: RefetchFunction<TData, TVariables>;\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n}\n\nexport type FetchMoreFunction<TData, TVariables extends OperationVariables> = (\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, TData> & {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult: TData;\n variables: TVariables;\n }\n ) => TData;\n }\n) => Promise<ApolloQueryResult<TData>>;\n\nexport type RefetchFunction<\n TData,\n TVariables extends OperationVariables\n> = ObservableQueryFields<TData, TVariables>['refetch'];\n\nexport type SubscribeToMoreFunction<\n TData,\n TVariables extends OperationVariables\n> = ObservableQueryFields<TData, TVariables>['subscribeToMore'];\n\nexport function useSuspenseQuery<\n TData,\n TVariables extends OperationVariables,\n TOptions extends Omit<SuspenseQueryHookOptions<TData>, 'variables'>\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> &\n TOptions\n): UseSuspenseQueryResult<\n TOptions['errorPolicy'] extends 'ignore' | 'all'\n ? TOptions['returnPartialData'] extends true\n ? DeepPartial<TData> | undefined\n : TData | undefined\n : TOptions['returnPartialData'] extends true\n ? TOptions['skip'] extends boolean\n ? DeepPartial<TData> | undefined\n : DeepPartial<TData>\n : TOptions['skip'] extends boolean\n ? TData | undefined\n : TData,\n TVariables\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n returnPartialData: true;\n errorPolicy: 'ignore' | 'all';\n }\n): UseSuspenseQueryResult<DeepPartial<TData> | undefined, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n errorPolicy: 'ignore' | 'all';\n }\n): UseSuspenseQueryResult<TData | undefined, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: true;\n }\n): UseSuspenseQueryResult<DeepPartial<TData> | undefined, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n returnPartialData: true;\n }\n): UseSuspenseQueryResult<DeepPartial<TData>, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n skip: boolean;\n }\n): UseSuspenseQueryResult<TData | undefined, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>\n): UseSuspenseQueryResult<TData, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<\n NoInfer<TData>,\n NoInfer<TVariables>\n > = Object.create(null)\n): UseSuspenseQueryResult<TData | undefined, TVariables> {\n const client = useApolloClient(options.client);\n const suspenseCache = useSuspenseCache(options.suspenseCache);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { fetchPolicy, 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 let promise = promiseCache.get(queryRef.key);\n\n if (queryRef.didChangeOptions(watchQueryOptions)) {\n promise = queryRef.applyOptions(watchQueryOptions);\n promiseCache.set(queryRef.key, promise);\n }\n\n if (!promise) {\n promise = queryRef.promise;\n promiseCache.set(queryRef.key, promise);\n }\n\n useTrackedQueryRefs(queryRef);\n\n useEffect(() => {\n return queryRef.listen((promise) => {\n setPromiseCache((promiseCache) =>\n new Map(promiseCache).set(queryRef.key, promise)\n );\n });\n }, [queryRef]);\n\n const skipResult = useMemo(() => {\n const error = toApolloError(queryRef.result);\n\n return {\n loading: false,\n data: queryRef.result.data,\n networkStatus: error ? NetworkStatus.error : NetworkStatus.ready,\n error,\n };\n }, [queryRef.result]);\n\n const result = fetchPolicy === 'standby' ? skipResult : __use(promise);\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = useCallback(\n (options) => {\n const promise = queryRef.fetchMore(options);\n\n setPromiseCache((previousPromiseCache) =>\n new Map(previousPromiseCache).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((previousPromiseCache) =>\n new Map(previousPromiseCache).set(queryRef.key, promise)\n );\n\n return promise;\n },\n [queryRef]\n );\n\n const subscribeToMore: SubscribeToMoreFunction<TData, TVariables> =\n useCallback(\n (options) => queryRef.observable.subscribeToMore(options),\n [queryRef]\n );\n\n return useMemo(() => {\n return {\n client,\n data: result.data,\n error: toApolloError(result),\n networkStatus: result.networkStatus,\n fetchMore,\n refetch,\n subscribeToMore,\n };\n }, [client, fetchMore, refetch, result, subscribeToMore]);\n}\n\nfunction validateOptions(options: WatchQueryOptions) {\n const { query, fetchPolicy, returnPartialData } = options;\n\n verifyDocumentType(query, DocumentType.Query);\n validateFetchPolicy(fetchPolicy);\n validatePartialDataReturn(fetchPolicy, returnPartialData);\n}\n\nfunction validateFetchPolicy(\n fetchPolicy: WatchQueryFetchPolicy = 'cache-first'\n) {\n const supportedFetchPolicies: WatchQueryFetchPolicy[] = [\n 'cache-first',\n 'network-only',\n 'no-cache',\n 'cache-and-network',\n ];\n\n invariant(\n supportedFetchPolicies.includes(fetchPolicy),\n `The fetch policy \\`%s\\` is not supported with suspense.`,\n fetchPolicy\n );\n}\n\nfunction validatePartialDataReturn(\n fetchPolicy: WatchQueryFetchPolicy | undefined,\n returnPartialData: boolean | undefined\n) {\n if (fetchPolicy === 'no-cache' && returnPartialData) {\n invariant.warn(\n 'Using `returnPartialData` with a `no-cache` fetch policy has no effect. To read partial data from the cache, consider using an alternate fetch policy.'\n );\n }\n}\n\nexport function toApolloError(result: ApolloQueryResult<any>) {\n return isNonEmptyArray(result.errors)\n ? new ApolloError({ graphQLErrors: result.errors })\n : result.error;\n}\n\nexport function useTrackedQueryRefs(queryRef: InternalQueryReference) {\n const trackedQueryRefs = useRef(new Set<InternalQueryReference>());\n\n trackedQueryRefs.current.add(queryRef);\n\n useStrictModeSafeCleanupEffect(() => {\n trackedQueryRefs.current.forEach((sub) => sub.dispose());\n });\n}\n\ninterface UseWatchQueryOptionsHookOptions<\n TData,\n TVariables extends OperationVariables\n> {\n client: ApolloClient<unknown>;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: SuspenseQueryHookOptions<TData, TVariables>;\n}\n\nexport function useWatchQueryOptions<\n TData,\n TVariables extends OperationVariables\n>({\n client,\n query,\n options,\n}: UseWatchQueryOptionsHookOptions<TData, TVariables>): WatchQueryOptions<\n TVariables,\n TData\n> {\n return useDeepMemo<WatchQueryOptions<TVariables, TData>>(() => {\n const fetchPolicy =\n options.fetchPolicy ||\n client.defaultOptions.watchQuery?.fetchPolicy ||\n 'cache-first';\n\n const watchQueryOptions = {\n ...options,\n fetchPolicy,\n query,\n notifyOnNetworkStatusChange: false,\n nextFetchPolicy: void 0,\n };\n\n if (__DEV__) {\n validateOptions(watchQueryOptions);\n }\n\n // Assign the updated fetch policy after our validation since `standby` is\n // not a supported fetch policy on its own without the use of `skip`.\n if (options.skip) {\n watchQueryOptions.fetchPolicy = 'standby';\n }\n\n return watchQueryOptions;\n }, [client, options, query]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useSuspenseQuery.js","sourceRoot":"","sources":["../../../src/react/hooks/useSuspenseQuery.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAMtE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,M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K,OAAA,EACL,2BAA2B,EAAE,KAAK,EAClC,eAAe,EAAE,KAAK,CAAC,GACxB,CAAC;QAEF,IAAI,OAAO,EAAE;YACX,eAAe,CAAC,iBAAiB,CAAC,CAAC;SACpC;QAID,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,iBAAiB,CAAC,WAAW,GAAG,SAAS,CAAC;SAC3C;QAED,OAAO,iBAAiB,CAAC;IAC3B,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals/index.js';\nimport * as React from 'react';\nimport type {\n ApolloClient,\n ApolloQueryResult,\n DocumentNode,\n OperationVariables,\n TypedDocumentNode,\n WatchQueryOptions,\n WatchQueryFetchPolicy,\n FetchMoreQueryOptions,\n} from '../../core/index.js';\nimport { ApolloError, NetworkStatus } from '../../core/index.js';\nimport type { DeepPartial } from '../../utilities/index.js';\nimport { isNonEmptyArray } from '../../utilities/index.js';\nimport { useApolloClient } from './useApolloClient.js';\nimport { DocumentType, verifyDocumentType } from '../parser/index.js';\nimport type {\n SuspenseQueryHookOptions,\n ObservableQueryFields,\n NoInfer,\n} from '../types/types.js';\nimport { useDeepMemo, __use } from './internal/index.js';\nimport { getSuspenseCache } from '../cache/index.js';\nimport { canonicalStringify } from '../../cache/index.js';\nimport type { CacheKey } from '../cache/types.js';\n\nexport interface UseSuspenseQueryResult<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n> {\n client: ApolloClient<any>;\n data: TData;\n error: ApolloError | undefined;\n fetchMore: FetchMoreFunction<TData, TVariables>;\n networkStatus: NetworkStatus;\n refetch: RefetchFunction<TData, TVariables>;\n subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;\n}\n\nexport type FetchMoreFunction<TData, TVariables extends OperationVariables> = (\n fetchMoreOptions: FetchMoreQueryOptions<TVariables, TData> & {\n updateQuery?: (\n previousQueryResult: TData,\n options: {\n fetchMoreResult: TData;\n variables: TVariables;\n }\n ) => TData;\n }\n) => Promise<ApolloQueryResult<TData>>;\n\nexport type RefetchFunction<\n TData,\n TVariables extends OperationVariables\n> = ObservableQueryFields<TData, TVariables>['refetch'];\n\nexport type SubscribeToMoreFunction<\n TData,\n TVariables extends OperationVariables\n> = ObservableQueryFields<TData, TVariables>['subscribeToMore'];\n\nexport function useSuspenseQuery<\n TData,\n TVariables extends OperationVariables,\n TOptions extends Omit<SuspenseQueryHookOptions<TData>, 'variables'>\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> &\n TOptions\n): UseSuspenseQueryResult<\n TOptions['errorPolicy'] extends 'ignore' | 'all'\n ? TOptions['returnPartialData'] extends true\n ? DeepPartial<TData> | undefined\n : TData | undefined\n : TOptions['returnPartialData'] extends true\n ? TOptions['skip'] extends boolean\n ? DeepPartial<TData> | undefined\n : DeepPartial<TData>\n : TOptions['skip'] extends boolean\n ? TData | undefined\n : TData,\n TVariables\n>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n returnPartialData: true;\n errorPolicy: 'ignore' | 'all';\n }\n): UseSuspenseQueryResult<DeepPartial<TData> | undefined, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n errorPolicy: 'ignore' | 'all';\n }\n): UseSuspenseQueryResult<TData | undefined, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n skip: boolean;\n returnPartialData: true;\n }\n): UseSuspenseQueryResult<DeepPartial<TData> | undefined, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n returnPartialData: true;\n }\n): UseSuspenseQueryResult<DeepPartial<TData>, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>> & {\n skip: boolean;\n }\n): UseSuspenseQueryResult<TData | undefined, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options?: SuspenseQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>\n): UseSuspenseQueryResult<TData, TVariables>;\n\nexport function useSuspenseQuery<\n TData = unknown,\n TVariables extends OperationVariables = OperationVariables\n>(\n query: DocumentNode | TypedDocumentNode<TData, TVariables>,\n options: SuspenseQueryHookOptions<\n NoInfer<TData>,\n NoInfer<TVariables>\n > = Object.create(null)\n): UseSuspenseQueryResult<TData | undefined, TVariables> {\n const client = useApolloClient(options.client);\n const suspenseCache = getSuspenseCache(client);\n const watchQueryOptions = useWatchQueryOptions({ client, query, options });\n const { fetchPolicy, variables } = watchQueryOptions;\n const { queryKey = [] } = options;\n\n const cacheKey: CacheKey = [\n query,\n canonicalStringify(variables),\n ...([] as any[]).concat(queryKey),\n ];\n\n const queryRef = suspenseCache.getQueryRef(cacheKey, () =>\n client.watchQuery(watchQueryOptions)\n );\n\n const [promiseCache, setPromiseCache] = React.useState(\n () => new Map([[queryRef.key, queryRef.promise]])\n );\n\n let promise = promiseCache.get(queryRef.key);\n\n if (queryRef.didChangeOptions(watchQueryOptions)) {\n promise = queryRef.applyOptions(watchQueryOptions);\n promiseCache.set(queryRef.key, promise);\n }\n\n if (!promise) {\n promise = queryRef.promise;\n promiseCache.set(queryRef.key, promise);\n }\n\n React.useEffect(() => {\n const dispose = queryRef.retain();\n\n const removeListener = queryRef.listen((promise) => {\n setPromiseCache((promiseCache) =>\n new Map(promiseCache).set(queryRef.key, promise)\n );\n });\n\n return () => {\n removeListener();\n dispose();\n };\n }, [queryRef]);\n\n const skipResult = React.useMemo(() => {\n const error = toApolloError(queryRef.result);\n\n return {\n loading: false,\n data: queryRef.result.data,\n networkStatus: error ? NetworkStatus.error : NetworkStatus.ready,\n error,\n };\n }, [queryRef.result]);\n\n const result = fetchPolicy === 'standby' ? skipResult : __use(promise);\n\n const fetchMore: FetchMoreFunction<TData, TVariables> = React.useCallback(\n (options) => {\n const promise = queryRef.fetchMore(options);\n\n setPromiseCache((previousPromiseCache) =>\n new Map(previousPromiseCache).set(queryRef.key, queryRef.promise)\n );\n\n return promise;\n },\n [queryRef]\n );\n\n const refetch: RefetchFunction<TData, TVariables> = React.useCallback(\n (variables) => {\n const promise = queryRef.refetch(variables);\n\n setPromiseCache((previousPromiseCache) =>\n new Map(previousPromiseCache).set(queryRef.key, queryRef.promise)\n );\n\n return promise;\n },\n [queryRef]\n );\n\n const subscribeToMore: SubscribeToMoreFunction<TData, TVariables> =\n React.useCallback(\n (options) => queryRef.observable.subscribeToMore(options),\n [queryRef]\n );\n\n return React.useMemo(() => {\n return {\n client,\n data: result.data,\n error: toApolloError(result),\n networkStatus: result.networkStatus,\n fetchMore,\n refetch,\n subscribeToMore,\n };\n }, [client, fetchMore, refetch, result, subscribeToMore]);\n}\n\nfunction validateOptions(options: WatchQueryOptions) {\n const { query, fetchPolicy, returnPartialData } = options;\n\n verifyDocumentType(query, DocumentType.Query);\n validateFetchPolicy(fetchPolicy);\n validatePartialDataReturn(fetchPolicy, returnPartialData);\n}\n\nfunction validateFetchPolicy(\n fetchPolicy: WatchQueryFetchPolicy = 'cache-first'\n) {\n const supportedFetchPolicies: WatchQueryFetchPolicy[] = [\n 'cache-first',\n 'network-only',\n 'no-cache',\n 'cache-and-network',\n ];\n\n invariant(\n supportedFetchPolicies.includes(fetchPolicy),\n `The fetch policy \\`%s\\` is not supported with suspense.`,\n fetchPolicy\n );\n}\n\nfunction validatePartialDataReturn(\n fetchPolicy: WatchQueryFetchPolicy | undefined,\n returnPartialData: boolean | undefined\n) {\n if (fetchPolicy === 'no-cache' && returnPartialData) {\n invariant.warn(\n 'Using `returnPartialData` with a `no-cache` fetch policy has no effect. To read partial data from the cache, consider using an alternate fetch policy.'\n );\n }\n}\n\nexport function toApolloError(result: ApolloQueryResult<any>) {\n return isNonEmptyArray(result.errors)\n ? new ApolloError({ graphQLErrors: result.errors })\n : result.error;\n}\n\ninterface UseWatchQueryOptionsHookOptions<\n TData,\n TVariables extends OperationVariables\n> {\n client: ApolloClient<unknown>;\n query: DocumentNode | TypedDocumentNode<TData, TVariables>;\n options: SuspenseQueryHookOptions<TData, TVariables>;\n}\n\nexport function useWatchQueryOptions<\n TData,\n TVariables extends OperationVariables\n>({\n client,\n query,\n options,\n}: UseWatchQueryOptionsHookOptions<TData, TVariables>): WatchQueryOptions<\n TVariables,\n TData\n> {\n return useDeepMemo<WatchQueryOptions<TVariables, TData>>(() => {\n const fetchPolicy =\n options.fetchPolicy ||\n client.defaultOptions.watchQuery?.fetchPolicy ||\n 'cache-first';\n\n const watchQueryOptions = {\n ...options,\n fetchPolicy,\n query,\n notifyOnNetworkStatusChange: false,\n nextFetchPolicy: void 0,\n };\n\n if (__DEV__) {\n validateOptions(watchQueryOptions);\n }\n\n // Assign the updated fetch policy after our validation since `standby` is\n // not a supported fetch policy on its own without the use of `skip`.\n if (options.skip) {\n watchQueryOptions.fetchPolicy = 'standby';\n }\n\n return watchQueryOptions;\n }, [client, options, query]);\n}\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { invariant
|
|
1
|
+
import { invariant } from '../../utilities/globals/index.js';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { canUseLayoutEffect } from
|
|
3
|
+
import { canUseLayoutEffect } from '../../utilities/index.js';
|
|
4
4
|
var didWarnUncachedGetSnapshot = false;
|
|
5
5
|
var uSESKey = "useSyncExternalStore";
|
|
6
6
|
var realHook = React[uSESKey];
|
|
7
7
|
export var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
8
8
|
var value = getSnapshot();
|
|
9
|
-
if (__DEV__ &&
|
|
9
|
+
if (globalThis.__DEV__ !== false &&
|
|
10
10
|
!didWarnUncachedGetSnapshot &&
|
|
11
11
|
value !== getSnapshot()) {
|
|
12
12
|
didWarnUncachedGetSnapshot = true;
|
|
13
|
-
__DEV__ && invariant.error(
|
|
13
|
+
globalThis.__DEV__ !== false && invariant.error(56);
|
|
14
14
|
}
|
|
15
15
|
var _a = React.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
|
|
16
16
|
if (canUseLayoutEffect) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSyncExternalStore.js","sourceRoot":"","sources":["../../../src/react/hooks/useSyncExternalStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"useSyncExternalStore.js","sourceRoot":"","sources":["../../../src/react/hooks/useSyncExternalStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,IAAI,0BAA0B,GAAG,KAAK,CAAC;AAYvC,IAAM,OAAO,GAAG,sBAA4C,CAAC;AAC7D,IAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAmC,CAAC;AAMlE,MAAM,CAAC,IAAM,oBAAoB,G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hB,OAAO,KAAK,CAAC;AACf,CAAC,CAAC,CAAC;AAEH,SAAS,sBAAsB,CAAW,EAMzC;QALC,KAAK,WAAA,EACL,WAAW,iBAAA;IAKX,IAAI;QACF,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;KAChC;IAAC,WAAM;QACN,OAAO,IAAI,CAAC;KACb;AACH,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals/index.js';\nimport * as React from 'react';\n\nimport { canUseLayoutEffect } from '../../utilities/index.js';\n\nlet didWarnUncachedGetSnapshot = false;\n\ntype RealUseSESHookType =\n // This import depends only on the @types/use-sync-external-store package, not\n // the actual use-sync-external-store package, which is not installed. It\n // might be nice to get this type from React 18, but it still needs to work\n // when only React 17 or earlier is installed.\n typeof import(\"use-sync-external-store\").useSyncExternalStore;\n\n// Prevent webpack from complaining about our feature detection of the\n// useSyncExternalStore property of the React namespace, which is expected not\n// to exist when using React 17 and earlier, and that's fine.\nconst uSESKey = \"useSyncExternalStore\" as keyof typeof React;\nconst realHook = React[uSESKey] as RealUseSESHookType | undefined;\n\n// Adapted from https://www.npmjs.com/package/use-sync-external-store, with\n// Apollo Client deviations called out by \"// DEVIATION ...\" comments.\n\n// When/if React.useSyncExternalStore is defined, delegate fully to it.\nexport const useSyncExternalStore: RealUseSESHookType = realHook || ((\n subscribe,\n getSnapshot,\n getServerSnapshot,\n) => {\n // Read the current snapshot from the store on every render. Again, this\n // breaks the rules of React, and only works here because of specific\n // implementation details, most importantly that updates are\n // always synchronous.\n const value = getSnapshot();\n if (\n // DEVIATION: Using __DEV__\n __DEV__ &&\n !didWarnUncachedGetSnapshot &&\n // DEVIATION: Not using Object.is because we know our snapshots will never\n // be exotic primitive values like NaN, which is !== itself.\n value !== getSnapshot()\n ) {\n didWarnUncachedGetSnapshot = true;\n // DEVIATION: Using invariant.error instead of console.error directly.\n invariant.error(\n 'The result of getSnapshot should be cached to avoid an infinite loop',\n );\n }\n\n // Because updates are synchronous, we don't queue them. Instead we force a\n // re-render whenever the subscribed state changes by updating an some\n // arbitrary useState hook. Then, during render, we call getSnapshot to read\n // the current value.\n //\n // Because we don't actually use the state returned by the useState hook, we\n // can save a bit of memory by storing other stuff in that slot.\n //\n // To implement the early bailout, we need to track some things on a mutable\n // object. Usually, we would put that in a useRef hook, but we can stash it in\n // our useState hook instead.\n //\n // To force a re-render, we call forceUpdate({inst}). That works because the\n // new object always fails an equality check.\n const [{inst}, forceUpdate] = React.useState({inst: {value, getSnapshot}});\n\n // Track the latest getSnapshot function with a ref. This needs to be updated\n // in the layout phase so we can access it during the tearing check that\n // happens on subscribe.\n if (canUseLayoutEffect) {\n // DEVIATION: We avoid calling useLayoutEffect when !canUseLayoutEffect,\n // which may seem like a conditional hook, but this code ends up behaving\n // unconditionally (one way or the other) because canUseLayoutEffect is\n // constant.\n React.useLayoutEffect(() => {\n Object.assign(inst, { value, getSnapshot });\n // Whenever getSnapshot or subscribe changes, we need to check in the\n // commit phase if there was an interleaved mutation. In concurrent mode\n // this can happen all the time, but even in synchronous mode, an earlier\n // effect may have mutated the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({inst});\n }\n }, [subscribe, value, getSnapshot]);\n } else {\n Object.assign(inst, { value, getSnapshot });\n }\n\n React.useEffect(() => {\n // Check for changes right before subscribing. Subsequent changes will be\n // detected in the subscription handler.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({inst});\n }\n\n // Subscribe to the store and return a clean-up function.\n return subscribe(function handleStoreChange() {\n // TODO: Because there is no cross-renderer API for batching updates, it's\n // up to the consumer of this library to wrap their subscription event\n // with unstable_batchedUpdates. Should we try to detect when this isn't\n // the case and print a warning in development?\n\n // The store changed. Check if the snapshot changed since the last time we\n // read from the store.\n if (checkIfSnapshotChanged(inst)) {\n // Force a re-render.\n forceUpdate({inst});\n }\n });\n }, [subscribe]);\n\n return value;\n});\n\nfunction checkIfSnapshotChanged<Snapshot>({\n value,\n getSnapshot,\n}: {\n value: Snapshot;\n getSnapshot: () => Snapshot;\n}): boolean {\n try {\n return value !== getSnapshot();\n } catch {\n return true;\n }\n}\n"]}
|
package/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import '../utilities/globals';
|
|
2
|
-
export { ApolloProvider, ApolloConsumer, getApolloContext, resetApolloContext, ApolloContextValue } from './context';
|
|
3
|
-
export * from './hooks';
|
|
4
|
-
export { SuspenseCache } from './cache';
|
|
5
|
-
export { DocumentType, IDocumentDefinition, operationName, parser } from './parser';
|
|
6
|
-
export * from './types/types';
|
|
1
|
+
import '../utilities/globals/index.js';
|
|
2
|
+
export { ApolloProvider, ApolloConsumer, getApolloContext, resetApolloContext, ApolloContextValue } from './context/index.js';
|
|
3
|
+
export * from './hooks/index.js';
|
|
4
|
+
export { SuspenseCache } from './cache/index.js';
|
|
5
|
+
export { DocumentType, IDocumentDefinition, operationName, parser } from './parser/index.js';
|
|
6
|
+
export * from './types/types.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/react/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,MAAM,EACP,MAAM,mBAAmB,CAAC;AAE3B,cAAc,kBAAkB,CAAC"}
|
package/react/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { ApolloProvider, ApolloConsumer, getApolloContext, resetApolloContext } from
|
|
3
|
-
export * from
|
|
4
|
-
export { SuspenseCache } from
|
|
5
|
-
export { DocumentType, operationName, parser } from
|
|
6
|
-
export * from
|
|
1
|
+
import '../utilities/globals/index.js';
|
|
2
|
+
export { ApolloProvider, ApolloConsumer, getApolloContext, resetApolloContext } from './context/index.js';
|
|
3
|
+
export * from './hooks/index.js';
|
|
4
|
+
export { SuspenseCache } from './cache/index.js';
|
|
5
|
+
export { DocumentType, operationName, parser } from './parser/index.js';
|
|
6
|
+
export * from './types/types.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EACL,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAEnB,MAAM,oBAAoB,CAAC;AAE5B,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACL,YAAY,EAEZ,aAAa,EACb,MAAM,EACP,MAAM,mBAAmB,CAAC;AAE3B,cAAc,kBAAkB,CAAC","sourcesContent":["import '../utilities/globals/index.js';\n\nexport {\n ApolloProvider,\n ApolloConsumer,\n getApolloContext,\n resetApolloContext,\n ApolloContextValue\n} from './context/index.js';\n\nexport * from './hooks/index.js';\n// TODO: remove export with release 3.8\nexport { SuspenseCache } from './cache/index.js';\n\nexport {\n DocumentType,\n IDocumentDefinition,\n operationName,\n parser\n} from './parser/index.js';\n\nexport * from './types/types.js';\n"]}
|
package/react/parser/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { invariant } from
|
|
1
|
+
import { invariant } from '../../utilities/globals/index.js';
|
|
2
2
|
export var DocumentType;
|
|
3
3
|
(function (DocumentType) {
|
|
4
4
|
DocumentType[DocumentType["Query"] = 0] = "Query";
|
|
@@ -26,7 +26,7 @@ export function parser(document) {
|
|
|
26
26
|
if (cached)
|
|
27
27
|
return cached;
|
|
28
28
|
var variables, type, name;
|
|
29
|
-
invariant(!!document && !!document.kind,
|
|
29
|
+
invariant(!!document && !!document.kind, 57, document);
|
|
30
30
|
var fragments = [];
|
|
31
31
|
var queries = [];
|
|
32
32
|
var mutations = [];
|
|
@@ -52,10 +52,10 @@ export function parser(document) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
invariant(!fragments.length ||
|
|
55
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
55
|
+
(queries.length || mutations.length || subscriptions.length), 58);
|
|
56
56
|
invariant(
|
|
57
57
|
queries.length + mutations.length + subscriptions.length <= 1,
|
|
58
|
-
|
|
58
|
+
59,
|
|
59
59
|
document,
|
|
60
60
|
queries.length,
|
|
61
61
|
subscriptions.length,
|
|
@@ -69,7 +69,7 @@ export function parser(document) {
|
|
|
69
69
|
: mutations.length
|
|
70
70
|
? mutations
|
|
71
71
|
: subscriptions;
|
|
72
|
-
invariant(definitions.length === 1,
|
|
72
|
+
invariant(definitions.length === 1, 60, document, definitions.length);
|
|
73
73
|
var definition = definitions[0];
|
|
74
74
|
variables = definition.variableDefinitions || [];
|
|
75
75
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -88,7 +88,7 @@ export function verifyDocumentType(document, type) {
|
|
|
88
88
|
var usedOperationName = operationName(operation.type);
|
|
89
89
|
invariant(
|
|
90
90
|
operation.type === type,
|
|
91
|
-
|
|
91
|
+
61,
|
|
92
92
|
requiredOperationName,
|
|
93
93
|
requiredOperationName,
|
|
94
94
|
usedOperationName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/parser/index.ts"],"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AAC,CAAC,OAAO;QACT,CAAC,CAAC,SAAS,CAAC,MAAM;YAClB,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,aAAa,CAAC;IAElB,SAAS,CACP,WAAW,CAAC,MAAM,KAAK,CAAC,EACxB,4DAA4D;QAC1D,kBAAkB;QAClB,uEAAuE,EACvE,QAAQ,EACR,WAAW,CAAC,MAAM,CACrB,CAAC;IAEF,IAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAA4B,CAAC;IAC7D,SAAS,GAAG,UAAU,CAAC,mBAAmB,IAAI,EAAE,CAAC;IAEjD,IAAI,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE;QACtD,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;KAC9B;SAAM;QACL,IAAI,GAAG,MAAM,CAAC;KACf;IAED,IAAM,OAAO,GAAG,EAAE,IAAI,MAAA,EAAE,IAAI,MAAA,EAAE,SAAS,WAAA,EAAE,CAAC;IAC1C,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAsB,EAAE,IAAkB;IAC3E,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAM,qBAAqB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAClD,IAAM,iBAAiB,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CACP,SAAS,CAAC,IAAI,KAAK,IAAI,EACvB,kCAAkC;QAChC,gCAAgC,EAChC,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,CACpB,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from '../../utilities/globals/index.js';\n\nimport type {\n DocumentNode,\n DefinitionNode,\n VariableDefinitionNode,\n OperationDefinitionNode\n} from 'graphql';\n\nexport enum DocumentType {\n Query,\n Mutation,\n Subscription\n}\n\nexport interface IDocumentDefinition {\n type: DocumentType;\n name: string;\n variables: ReadonlyArray<VariableDefinitionNode>;\n}\n\nconst cache = new Map();\n\nexport function operationName(type: DocumentType) {\n let name;\n switch (type) {\n case DocumentType.Query:\n name = 'Query';\n break;\n case DocumentType.Mutation:\n name = 'Mutation';\n break;\n case DocumentType.Subscription:\n name = 'Subscription';\n break;\n }\n return name;\n}\n\n// This parser is mostly used to safety check incoming documents.\nexport function parser(document: DocumentNode): IDocumentDefinition {\n const cached = cache.get(document);\n if (cached) return cached;\n\n let variables, type, name;\n\n invariant(\n !!document && !!document.kind,\n `Argument of %s passed to parser was not a valid GraphQL ` +\n `DocumentNode. You may need to use 'graphql-tag' or another method ` +\n `to convert your operation into a document`,\n document\n );\n\n const fragments: DefinitionNode[] = []\n const queries: DefinitionNode[] = []\n const mutations: DefinitionNode[] = []\n const subscriptions: DefinitionNode[] = []\n\n for (const x of document.definitions) {\n if (x.kind === 'FragmentDefinition') {\n fragments.push(x);\n continue\n }\n\n if (x.kind === 'OperationDefinition') {\n switch (x.operation) {\n case 'query':\n queries.push(x);\n break;\n case 'mutation':\n mutations.push(x);\n break;\n case 'subscription':\n subscriptions.push(x);\n break;\n }\n }\n }\n\n invariant(\n !fragments.length ||\n (queries.length || mutations.length || subscriptions.length),\n `Passing only a fragment to 'graphql' is not yet supported. ` +\n `You must include a query, subscription or mutation as well`\n );\n\n invariant(\n queries.length + mutations.length + subscriptions.length <= 1,\n `react-apollo only supports a query, subscription, or a mutation per HOC. ` +\n `%s had %s queries, %s ` +\n `subscriptions and %s mutations. ` +\n `You can use 'compose' to join multiple operation types to a component`,\n document,\n queries.length,\n subscriptions.length,\n mutations.length\n );\n\n type = queries.length ? DocumentType.Query : DocumentType.Mutation;\n if (!queries.length && !mutations.length) type = DocumentType.Subscription;\n\n const definitions = queries.length\n ? queries\n : mutations.length\n ? mutations\n : subscriptions;\n\n invariant(\n definitions.length === 1,\n `react-apollo only supports one definition per HOC. %s had ` +\n `%s definitions. ` +\n `You can use 'compose' to join multiple operation types to a component`,\n document,\n definitions.length\n );\n\n const definition = definitions[0] as OperationDefinitionNode;\n variables = definition.variableDefinitions || [];\n\n if (definition.name && definition.name.kind === 'Name') {\n name = definition.name.value;\n } else {\n name = 'data'; // fallback to using data if no name\n }\n\n const payload = { name, type, variables };\n cache.set(document, payload);\n return payload;\n}\n\nexport function verifyDocumentType(document: DocumentNode, type: DocumentType) {\n const operation = parser(document);\n const requiredOperationName = operationName(type);\n const usedOperationName = operationName(operation.type);\n invariant(\n operation.type === type,\n `Running a %s requires a graphql ` +\n `%s, but a %s was used instead.`,\n requiredOperationName,\n requiredOperationName,\n usedOperationName\n );\n}\n\n"]}
|
package/react/parser/parser.cjs
CHANGED
|
@@ -31,7 +31,7 @@ function parser(document) {
|
|
|
31
31
|
if (cached)
|
|
32
32
|
return cached;
|
|
33
33
|
var variables, type, name;
|
|
34
|
-
globals.invariant(!!document && !!document.kind,
|
|
34
|
+
globals.invariant(!!document && !!document.kind, 57, document);
|
|
35
35
|
var fragments = [];
|
|
36
36
|
var queries = [];
|
|
37
37
|
var mutations = [];
|
|
@@ -57,10 +57,10 @@ function parser(document) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
globals.invariant(!fragments.length ||
|
|
60
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
60
|
+
(queries.length || mutations.length || subscriptions.length), 58);
|
|
61
61
|
globals.invariant(
|
|
62
62
|
queries.length + mutations.length + subscriptions.length <= 1,
|
|
63
|
-
|
|
63
|
+
59,
|
|
64
64
|
document,
|
|
65
65
|
queries.length,
|
|
66
66
|
subscriptions.length,
|
|
@@ -74,7 +74,7 @@ function parser(document) {
|
|
|
74
74
|
: mutations.length
|
|
75
75
|
? mutations
|
|
76
76
|
: subscriptions;
|
|
77
|
-
globals.invariant(definitions.length === 1,
|
|
77
|
+
globals.invariant(definitions.length === 1, 60, document, definitions.length);
|
|
78
78
|
var definition = definitions[0];
|
|
79
79
|
variables = definition.variableDefinitions || [];
|
|
80
80
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -93,7 +93,7 @@ function verifyDocumentType(document, type) {
|
|
|
93
93
|
var usedOperationName = operationName(operation.type);
|
|
94
94
|
globals.invariant(
|
|
95
95
|
operation.type === type,
|
|
96
|
-
|
|
96
|
+
61,
|
|
97
97
|
requiredOperationName,
|
|
98
98
|
requiredOperationName,
|
|
99
99
|
usedOperationName
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.cjs","sources":["index.js"],"sourcesContent":["import { invariant } from '../../utilities/globals';\nexport var DocumentType;\n(function (DocumentType) {\n DocumentType[DocumentType[\"Query\"] = 0] = \"Query\";\n DocumentType[DocumentType[\"Mutation\"] = 1] = \"Mutation\";\n DocumentType[DocumentType[\"Subscription\"] = 2] = \"Subscription\";\n})(DocumentType || (DocumentType = {}));\nvar cache = new Map();\nexport function operationName(type) {\n var name;\n switch (type) {\n case DocumentType.Query:\n name = 'Query';\n break;\n case DocumentType.Mutation:\n name = 'Mutation';\n break;\n case DocumentType.Subscription:\n name = 'Subscription';\n break;\n }\n return name;\n}\nexport function parser(document) {\n var cached = cache.get(document);\n if (cached)\n return cached;\n var variables, type, name;\n invariant(!!document && !!document.kind,
|
|
1
|
+
{"version":3,"file":"parser.cjs","sources":["index.js"],"sourcesContent":["import { invariant } from '../../utilities/globals/index.js';\nexport var DocumentType;\n(function (DocumentType) {\n DocumentType[DocumentType[\"Query\"] = 0] = \"Query\";\n DocumentType[DocumentType[\"Mutation\"] = 1] = \"Mutation\";\n DocumentType[DocumentType[\"Subscription\"] = 2] = \"Subscription\";\n})(DocumentType || (DocumentType = {}));\nvar cache = new Map();\nexport function operationName(type) {\n var name;\n switch (type) {\n case DocumentType.Query:\n name = 'Query';\n break;\n case DocumentType.Mutation:\n name = 'Mutation';\n break;\n case DocumentType.Subscription:\n name = 'Subscription';\n break;\n }\n return name;\n}\nexport function parser(document) {\n var cached = cache.get(document);\n if (cached)\n return cached;\n var variables, type, name;\n invariant(!!document && !!document.kind, 57, document);\n var fragments = [];\n var queries = [];\n var mutations = [];\n var subscriptions = [];\n for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {\n var x = _a[_i];\n if (x.kind === 'FragmentDefinition') {\n fragments.push(x);\n continue;\n }\n if (x.kind === 'OperationDefinition') {\n switch (x.operation) {\n case 'query':\n queries.push(x);\n break;\n case 'mutation':\n mutations.push(x);\n break;\n case 'subscription':\n subscriptions.push(x);\n break;\n }\n }\n }\n invariant(!fragments.length ||\n (queries.length || mutations.length || subscriptions.length), 58);\n invariant(\n queries.length + mutations.length + subscriptions.length <= 1,\n 59,\n document,\n queries.length,\n subscriptions.length,\n mutations.length\n );\n type = queries.length ? DocumentType.Query : DocumentType.Mutation;\n if (!queries.length && !mutations.length)\n type = DocumentType.Subscription;\n var definitions = queries.length\n ? queries\n : mutations.length\n ? mutations\n : subscriptions;\n invariant(definitions.length === 1, 60, document, definitions.length);\n var definition = definitions[0];\n variables = definition.variableDefinitions || [];\n if (definition.name && definition.name.kind === 'Name') {\n name = definition.name.value;\n }\n else {\n name = 'data';\n }\n var payload = { name: name, type: type, variables: variables };\n cache.set(document, payload);\n return payload;\n}\nexport function verifyDocumentType(document, type) {\n var operation = parser(document);\n var requiredOperationName = operationName(type);\n var usedOperationName = operationName(operation.type);\n invariant(\n operation.type === type,\n 61,\n requiredOperationName,\n requiredOperationName,\n usedOperationName\n );\n}\n//# sourceMappingURL=index.js.map"],"names":["DocumentType","invariant"],"mappings":";;;;;;AACWA,8BAAa;AACxB,CAAC,UAAU,YAAY,EAAE;AACzB,IAAI,YAAY,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC;AACtD,IAAI,YAAY,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC;AAC5D,IAAI,YAAY,CAAC,YAAY,CAAC,cAAc,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