@apollo/client 3.8.0-alpha.9 → 3.8.0-beta.1
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 +1043 -686
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +34 -31
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +34 -31
- package/cache/core/cache.d.ts +5 -4
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js +1 -0
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +2 -2
- package/cache/core/types/Cache.d.ts.map +1 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +4 -4
- package/cache/core/types/DataProxy.d.ts.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +3 -3
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +5 -5
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +2 -2
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.d.ts +1 -1
- package/cache/inmemory/fragmentRegistry.d.ts.map +1 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +6 -5
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -7
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +14 -16
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.d.ts +1 -1
- package/cache/inmemory/key-extractor.d.ts.map +1 -1
- package/cache/inmemory/key-extractor.js +2 -2
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/policies.d.ts +7 -6
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +6 -6
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.d.ts.map +1 -1
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +6 -6
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +10 -5
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +6 -6
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +6 -6
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +7 -8
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/setup.d.ts +1 -0
- package/config/jest/setup.d.ts.map +1 -1
- package/config/jest/setup.js +3 -0
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +12 -10
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +18 -16
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +7 -9
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +6 -10
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +11 -8
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +48 -28
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +9 -9
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +14 -11
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +114 -108
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +267 -172
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +267 -172
- package/core/equalByQuery.d.ts +4 -0
- package/core/equalByQuery.d.ts.map +1 -0
- package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
- package/core/equalByQuery.js.map +1 -0
- package/core/index.d.ts +2 -2
- package/core/index.d.ts.map +1 -1
- package/core/index.js +2 -2
- package/core/index.js.map +1 -1
- package/core/networkStatus.d.ts +1 -0
- package/core/networkStatus.d.ts.map +1 -1
- package/core/networkStatus.js +3 -0
- package/core/networkStatus.js.map +1 -1
- package/core/types.d.ts +14 -14
- package/core/types.d.ts.map +1 -1
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +6 -7
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +642 -0
- package/dev/dev.cjs.map +1 -0
- package/dev/dev.cjs.native.js +642 -0
- package/dev/index.d.ts +4 -0
- package/dev/index.d.ts.map +1 -0
- package/dev/index.js +4 -0
- package/dev/index.js.map +1 -0
- package/dev/loadDevMessages.d.ts +2 -0
- package/dev/loadDevMessages.d.ts.map +1 -0
- package/dev/loadDevMessages.js +6 -0
- package/dev/loadDevMessages.js.map +1 -0
- package/dev/loadErrorMessageHandler.d.ts +3 -0
- package/dev/loadErrorMessageHandler.d.ts.map +1 -0
- package/dev/loadErrorMessageHandler.js +26 -0
- package/dev/loadErrorMessageHandler.js.map +1 -0
- package/dev/loadErrorMessages.d.ts +2 -0
- package/dev/loadErrorMessages.d.ts.map +1 -0
- package/dev/loadErrorMessages.js +6 -0
- package/dev/loadErrorMessages.js.map +1 -0
- package/dev/package.json +8 -0
- package/errors/errors.cjs +17 -17
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +17 -17
- package/errors/index.d.ts +26 -10
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +17 -19
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.d.ts +13 -0
- package/invariantErrorCodes.d.ts.map +1 -0
- package/invariantErrorCodes.js +331 -144
- package/invariantErrorCodes.js.map +1 -0
- package/link/batch/batchLink.d.ts +4 -3
- package/link/batch/batchLink.d.ts.map +1 -1
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.d.ts +1 -1
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +23 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +23 -2
- package/link/batch-http/batchHttpLink.d.ts +3 -2
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +7 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/index.d.ts +3 -2
- package/link/context/index.d.ts.map +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +3 -2
- package/link/core/ApolloLink.d.ts.map +1 -1
- package/link/core/ApolloLink.js +3 -13
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +2 -12
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -12
- package/link/core/types.d.ts +8 -3
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/error/index.d.ts +4 -3
- package/link/error/index.d.ts.map +1 -1
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +3 -2
- package/link/http/HttpLink.d.ts.map +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +2 -2
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.d.ts +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +21 -20
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +73 -43
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +73 -43
- package/link/http/iterators/nodeStream.d.ts +1 -1
- package/link/http/iterators/nodeStream.d.ts.map +1 -1
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +47 -26
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts +1 -1
- package/link/http/responseIterator.d.ts.map +1 -1
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +1 -1
- package/link/http/rewriteURIForGET.d.ts.map +1 -1
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +3 -2
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.d.ts +1 -1
- package/link/http/selectURI.d.ts.map +1 -1
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.d.ts +1 -1
- package/link/http/serializeFetchParameter.d.ts.map +1 -1
- package/link/http/serializeFetchParameter.js +2 -2
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts +4 -3
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +16 -20
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +15 -19
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +15 -19
- package/link/remove-typename/index.d.ts +2 -0
- package/link/remove-typename/index.d.ts.map +1 -0
- package/link/remove-typename/index.js +2 -0
- package/link/remove-typename/index.js.map +1 -0
- package/link/remove-typename/package.json +8 -0
- package/link/remove-typename/remove-typename.cjs +81 -0
- package/link/remove-typename/remove-typename.cjs.map +1 -0
- package/link/remove-typename/remove-typename.cjs.native.js +81 -0
- package/link/remove-typename/removeTypenameFromVariables.d.ts +11 -0
- package/link/remove-typename/removeTypenameFromVariables.d.ts.map +1 -0
- package/link/remove-typename/removeTypenameFromVariables.js +73 -0
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -0
- package/link/retry/delayFunction.d.ts +1 -1
- package/link/retry/delayFunction.d.ts.map +1 -1
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retryFunction.d.ts +1 -1
- package/link/retry/retryFunction.d.ts.map +1 -1
- package/link/retry/retryFunction.js.map +1 -1
- package/link/retry/retryLink.d.ts +4 -3
- package/link/retry/retryLink.d.ts.map +1 -1
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +3 -2
- package/link/schema/index.d.ts.map +1 -1
- package/link/schema/index.js.map +1 -1
- package/link/subscriptions/index.d.ts +2 -1
- package/link/subscriptions/index.d.ts.map +1 -1
- package/link/subscriptions/index.js +8 -3
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +8 -3
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +8 -3
- package/link/utils/createOperation.d.ts +1 -1
- package/link/utils/createOperation.d.ts.map +1 -1
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/filterOperationVariables.d.ts +5 -0
- package/link/utils/filterOperationVariables.d.ts.map +1 -0
- package/link/utils/filterOperationVariables.js +18 -0
- package/link/utils/filterOperationVariables.js.map +1 -0
- package/link/utils/index.d.ts +1 -0
- package/link/utils/index.d.ts.map +1 -1
- package/link/utils/index.js +1 -0
- package/link/utils/index.js.map +1 -1
- package/link/utils/throwServerError.d.ts +1 -1
- package/link/utils/throwServerError.d.ts.map +1 -1
- package/link/utils/throwServerError.js.map +1 -1
- package/link/utils/toPromise.d.ts +1 -1
- package/link/utils/toPromise.d.ts.map +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/transformOperation.d.ts +1 -1
- package/link/utils/transformOperation.d.ts.map +1 -1
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +20 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +20 -2
- package/link/utils/validateOperation.d.ts +1 -1
- package/link/utils/validateOperation.d.ts.map +1 -1
- package/link/utils/validateOperation.js +2 -2
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +5 -3
- package/link/ws/index.d.ts.map +1 -1
- package/link/ws/index.js.map +1 -1
- package/package.json +36 -32
- package/react/cache/QueryReference.d.ts +34 -0
- package/react/cache/QueryReference.d.ts.map +1 -0
- package/react/cache/QueryReference.js +107 -0
- package/react/cache/QueryReference.js.map +1 -0
- package/react/cache/SuspenseCache.d.ts +10 -13
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js +18 -41
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/cache/types.d.ts +2 -0
- package/react/cache/types.d.ts.map +1 -0
- package/react/cache/types.js +2 -0
- package/react/cache/types.js.map +1 -0
- package/react/components/Mutation.d.ts +2 -2
- package/react/components/Mutation.d.ts.map +1 -1
- package/react/components/Mutation.js.map +1 -1
- package/react/components/Query.d.ts +2 -2
- package/react/components/Query.d.ts.map +1 -1
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.d.ts +2 -2
- package/react/components/Subscription.d.ts.map +1 -1
- package/react/components/Subscription.js.map +1 -1
- package/react/components/types.d.ts +4 -4
- package/react/components/types.d.ts.map +1 -1
- package/react/components/types.js.map +1 -1
- package/react/context/ApolloConsumer.d.ts +1 -1
- package/react/context/ApolloConsumer.d.ts.map +1 -1
- package/react/context/ApolloConsumer.js +2 -3
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +10 -3
- package/react/context/ApolloContext.d.ts.map +1 -1
- package/react/context/ApolloContext.js +10 -8
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +2 -2
- package/react/context/ApolloProvider.d.ts.map +1 -1
- package/react/context/ApolloProvider.js +8 -13
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/context/context.cjs +18 -22
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +18 -22
- package/react/context/index.d.ts +1 -1
- package/react/context/index.d.ts.map +1 -1
- package/react/context/index.js +1 -1
- package/react/context/index.js.map +1 -1
- package/react/hoc/graphql.d.ts +3 -3
- package/react/hoc/graphql.d.ts.map +1 -1
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts +2 -2
- package/react/hoc/hoc-utils.d.ts.map +1 -1
- package/react/hoc/hoc-utils.js +2 -3
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs +2 -4
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -4
- package/react/hoc/mutation-hoc.d.ts +4 -4
- package/react/hoc/mutation-hoc.d.ts.map +1 -1
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +2 -2
- package/react/hoc/query-hoc.d.ts.map +1 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +2 -2
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/types.d.ts +4 -4
- package/react/hoc/types.d.ts.map +1 -1
- package/react/hoc/types.js.map +1 -1
- package/react/hoc/withApollo.d.ts +1 -1
- package/react/hoc/withApollo.d.ts.map +1 -1
- package/react/hoc/withApollo.js +2 -3
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +223 -219
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +223 -219
- package/react/hooks/index.d.ts +2 -1
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +2 -1
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/internal/__use.d.ts +4 -0
- package/react/hooks/internal/__use.d.ts.map +1 -0
- package/react/hooks/internal/__use.js +17 -0
- package/react/hooks/internal/__use.js.map +1 -0
- package/react/hooks/internal/index.d.ts +2 -0
- package/react/hooks/internal/index.d.ts.map +1 -1
- package/react/hooks/internal/index.js +2 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useDeepMemo.d.ts +1 -1
- package/react/hooks/internal/useDeepMemo.d.ts.map +1 -1
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +2 -2
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts +2 -0
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.d.ts.map +1 -0
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.js +11 -0
- package/react/hooks/internal/useStrictModeSafeCleanupEffect.js.map +1 -0
- package/react/hooks/useApolloClient.d.ts +1 -1
- package/react/hooks/useApolloClient.d.ts.map +1 -1
- package/react/hooks/useApolloClient.js +2 -4
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +18 -0
- package/react/hooks/useBackgroundQuery.d.ts.map +1 -0
- package/react/hooks/useBackgroundQuery.js +69 -0
- package/react/hooks/useBackgroundQuery.js.map +1 -0
- package/react/hooks/useFragment.d.ts +14 -9
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js +2 -2
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +4 -4
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +13 -22
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +4 -4
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +1 -1
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +6 -6
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +29 -28
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +1 -1
- package/react/hooks/useReactiveVar.d.ts.map +1 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +4 -4
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +27 -19
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseCache.d.ts +1 -1
- package/react/hooks/useSuspenseCache.d.ts.map +1 -1
- package/react/hooks/useSuspenseCache.js +2 -4
- package/react/hooks/useSuspenseCache.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +39 -7
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +68 -149
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -1
- package/react/index.js.map +1 -1
- package/react/parser/index.d.ts +1 -1
- package/react/parser/index.d.ts.map +1 -1
- package/react/parser/index.js +20 -17
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +19 -16
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +19 -16
- package/react/react.cjs +116 -35
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +116 -35
- package/react/ssr/RenderPromises.d.ts +2 -2
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/renderToStringWithData.d.ts +1 -1
- package/react/ssr/renderToStringWithData.d.ts.map +1 -1
- package/react/ssr/renderToStringWithData.js.map +1 -1
- package/react/types/types.d.ts +10 -13
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +1 -1
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +1 -1
- package/testing/core/mocking/mockClient.d.ts +2 -2
- package/testing/core/mocking/mockClient.d.ts.map +1 -1
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +2 -1
- package/testing/core/mocking/mockLink.d.ts.map +1 -1
- package/testing/core/mocking/mockLink.js +3 -3
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +3 -2
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts +2 -2
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -1
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +2 -2
- package/testing/core/observableToPromise.d.ts.map +1 -1
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/subscribeAndCount.d.ts +1 -1
- package/testing/core/subscribeAndCount.d.ts.map +1 -1
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/matchers/index.d.ts +2 -0
- package/testing/matchers/index.d.ts.map +1 -0
- package/testing/matchers/index.js +6 -0
- package/testing/matchers/index.js.map +1 -0
- package/testing/matchers/toMatchDocument.d.ts +4 -0
- package/testing/matchers/toMatchDocument.d.ts.map +1 -0
- package/testing/matchers/toMatchDocument.js +34 -0
- package/testing/matchers/toMatchDocument.js.map +1 -0
- package/testing/react/MockedProvider.d.ts +8 -7
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +7 -6
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +7 -51
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +7 -51
- package/utilities/common/compact.d.ts +1 -1
- package/utilities/common/compact.d.ts.map +1 -1
- package/utilities/common/compact.js.map +1 -1
- package/utilities/common/errorHandling.d.ts +1 -1
- package/utilities/common/errorHandling.d.ts.map +1 -1
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +2 -1
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js +4 -0
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/objects.d.ts +1 -0
- package/utilities/common/objects.d.ts.map +1 -1
- package/utilities/common/objects.js +6 -0
- package/utilities/common/objects.js.map +1 -1
- package/utilities/common/omitDeep.d.ts +3 -0
- package/utilities/common/omitDeep.d.ts.map +1 -0
- package/utilities/common/omitDeep.js +41 -0
- package/utilities/common/omitDeep.js.map +1 -0
- package/utilities/common/responseIterator.d.ts +2 -2
- package/utilities/common/responseIterator.d.ts.map +1 -1
- package/utilities/common/responseIterator.js.map +1 -1
- package/utilities/common/stringifyForDisplay.d.ts +1 -1
- package/utilities/common/stringifyForDisplay.d.ts.map +1 -1
- package/utilities/common/stringifyForDisplay.js +3 -2
- package/utilities/common/stringifyForDisplay.js.map +1 -1
- package/utilities/common/stripTypename.d.ts +2 -0
- package/utilities/common/stripTypename.d.ts.map +1 -0
- package/utilities/common/stripTypename.js +5 -0
- package/utilities/common/stripTypename.js.map +1 -0
- package/utilities/globals/global.d.ts +6 -3
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +67 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +67 -1
- package/utilities/globals/index.d.ts +2 -2
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +2 -2
- package/utilities/globals/index.js.map +1 -1
- package/utilities/globals/invariantWrappers.d.ts +24 -0
- package/utilities/globals/invariantWrappers.d.ts.map +1 -0
- package/utilities/globals/invariantWrappers.js +53 -0
- package/utilities/globals/invariantWrappers.js.map +1 -0
- package/utilities/graphql/DocumentTransform.d.ts +24 -0
- package/utilities/graphql/DocumentTransform.d.ts.map +1 -0
- package/utilities/graphql/DocumentTransform.js +69 -0
- package/utilities/graphql/DocumentTransform.js.map +1 -0
- package/utilities/graphql/directives.d.ts +1 -1
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +6 -7
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +8 -5
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +1 -1
- package/utilities/graphql/getFromAST.d.ts.map +1 -1
- package/utilities/graphql/getFromAST.js +9 -9
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/operations.d.ts +5 -0
- package/utilities/graphql/operations.d.ts.map +1 -0
- package/utilities/graphql/operations.js +16 -0
- package/utilities/graphql/operations.js.map +1 -0
- package/utilities/graphql/storeUtils.d.ts +2 -2
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +16 -7
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +30 -21
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +7 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +5 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +2 -1
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/Observable.d.ts +2 -1
- package/utilities/observables/Observable.d.ts.map +1 -1
- package/utilities/observables/Observable.js +1 -1
- package/utilities/observables/Observable.js.map +1 -1
- package/utilities/observables/asyncMap.d.ts.map +1 -1
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/observables/iteration.d.ts +1 -1
- package/utilities/observables/iteration.d.ts.map +1 -1
- package/utilities/observables/iteration.js.map +1 -1
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/promises/decoration.d.ts +17 -0
- package/utilities/promises/decoration.d.ts.map +1 -0
- package/utilities/promises/decoration.js +37 -0
- package/utilities/promises/decoration.js.map +1 -0
- package/utilities/types/DeepOmit.d.ts +10 -0
- package/utilities/types/DeepOmit.d.ts.map +1 -0
- package/utilities/types/DeepOmit.js +2 -0
- package/utilities/types/DeepOmit.js.map +1 -0
- package/utilities/types/DeepPartial.d.ts +12 -0
- package/utilities/types/DeepPartial.d.ts.map +1 -0
- package/utilities/types/DeepPartial.js +2 -0
- package/utilities/types/DeepPartial.js.map +1 -0
- package/utilities/types/Primitive.d.ts +2 -0
- package/utilities/types/Primitive.d.ts.map +1 -0
- package/utilities/types/Primitive.js +2 -0
- package/utilities/types/Primitive.js.map +1 -0
- package/utilities/utilities.cjs +261 -59
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +261 -59
- package/version.js +1 -1
- package/cache/inmemory/__mocks__/optimism.d.ts +0 -2
- package/cache/inmemory/__mocks__/optimism.d.ts.map +0 -1
- package/cache/inmemory/__mocks__/optimism.js +0 -14
- package/cache/inmemory/__mocks__/optimism.js.map +0 -1
- package/react/hooks/compareResults.d.ts +0 -3
- package/react/hooks/compareResults.d.ts.map +0 -1
- package/react/hooks/compareResults.js.map +0 -1
package/apollo-client.cjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var tsInvariant = require('ts-invariant');
|
|
7
6
|
var process$1 = require('ts-invariant/process');
|
|
8
7
|
var graphql = require('graphql');
|
|
9
|
-
var
|
|
8
|
+
var equal = require('@wry/equality');
|
|
9
|
+
var tsInvariant = require('ts-invariant');
|
|
10
10
|
var zenObservableTs = require('zen-observable-ts');
|
|
11
11
|
require('symbol-observable');
|
|
12
12
|
var optimism = require('optimism');
|
|
@@ -15,6 +15,8 @@ var trie = require('@wry/trie');
|
|
|
15
15
|
var graphqlTag = require('graphql-tag');
|
|
16
16
|
var React = require('react');
|
|
17
17
|
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
19
|
+
|
|
18
20
|
function _interopNamespace(e) {
|
|
19
21
|
if (e && e.__esModule) return e;
|
|
20
22
|
var n = Object.create(null);
|
|
@@ -27,7 +29,11 @@ function _interopNamespace(e) {
|
|
|
27
29
|
return Object.freeze(n);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
30
33
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
35
|
+
|
|
36
|
+
var version = '3.8.0-beta.1';
|
|
31
37
|
|
|
32
38
|
function maybe(thunk) {
|
|
33
39
|
try {
|
|
@@ -42,6 +48,68 @@ var global$1 = (maybe(function () { return globalThis; }) ||
|
|
|
42
48
|
maybe(function () { return global; }) ||
|
|
43
49
|
maybe(function () { return maybe.constructor("return this")(); }));
|
|
44
50
|
|
|
51
|
+
var prefixCounts = new Map();
|
|
52
|
+
function makeUniqueId(prefix) {
|
|
53
|
+
var count = prefixCounts.get(prefix) || 1;
|
|
54
|
+
prefixCounts.set(prefix, count + 1);
|
|
55
|
+
return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function stringifyForDisplay(value, space) {
|
|
59
|
+
if (space === void 0) { space = 0; }
|
|
60
|
+
var undefId = makeUniqueId("stringifyForDisplay");
|
|
61
|
+
return JSON.stringify(value, function (key, value) {
|
|
62
|
+
return value === void 0 ? undefId : value;
|
|
63
|
+
}, space).split(JSON.stringify(undefId)).join("<undefined>");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function wrap(fn) {
|
|
67
|
+
return function (message) {
|
|
68
|
+
var args = [];
|
|
69
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
70
|
+
args[_i - 1] = arguments[_i];
|
|
71
|
+
}
|
|
72
|
+
fn.apply(void 0, tslib.__spreadArray([typeof message === 'number' ? getErrorMsg(message) : message], args, false));
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
var invariant = Object.assign(function invariant(condition, message) {
|
|
76
|
+
var args = [];
|
|
77
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
78
|
+
args[_i - 2] = arguments[_i];
|
|
79
|
+
}
|
|
80
|
+
if (!condition) {
|
|
81
|
+
tsInvariant.invariant(condition, getErrorMsg(message, args));
|
|
82
|
+
}
|
|
83
|
+
}, {
|
|
84
|
+
debug: wrap(tsInvariant.invariant.debug),
|
|
85
|
+
log: wrap(tsInvariant.invariant.log),
|
|
86
|
+
warn: wrap(tsInvariant.invariant.warn),
|
|
87
|
+
error: wrap(tsInvariant.invariant.error),
|
|
88
|
+
});
|
|
89
|
+
function newInvariantError(message) {
|
|
90
|
+
var optionalParams = [];
|
|
91
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
92
|
+
optionalParams[_i - 1] = arguments[_i];
|
|
93
|
+
}
|
|
94
|
+
return new tsInvariant.InvariantError(getErrorMsg(message, optionalParams));
|
|
95
|
+
}
|
|
96
|
+
var ApolloErrorMessageHandler = Symbol.for('ApolloErrorMessageHandler_' + version);
|
|
97
|
+
function getErrorMsg(message, messageArgs) {
|
|
98
|
+
if (messageArgs === void 0) { messageArgs = []; }
|
|
99
|
+
if (!message)
|
|
100
|
+
return;
|
|
101
|
+
var args = messageArgs.map(function (arg) {
|
|
102
|
+
return typeof arg == 'string' ? arg : stringifyForDisplay(arg, 2).slice(0, 1000);
|
|
103
|
+
});
|
|
104
|
+
return ((global$1[ApolloErrorMessageHandler] &&
|
|
105
|
+
global$1[ApolloErrorMessageHandler](message, args)) ||
|
|
106
|
+
"An error occured! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({
|
|
107
|
+
version: version,
|
|
108
|
+
message: message,
|
|
109
|
+
args: args,
|
|
110
|
+
}))));
|
|
111
|
+
}
|
|
112
|
+
|
|
45
113
|
var DEV = ("__DEV__" in global$1
|
|
46
114
|
? Boolean(global$1.__DEV__)
|
|
47
115
|
: maybe(function () { return process.env.NODE_ENV; }) !== "production");
|
|
@@ -63,7 +131,7 @@ function shouldInclude(_a, variables) {
|
|
|
63
131
|
var evaledValue = false;
|
|
64
132
|
if (ifArgument.value.kind === 'Variable') {
|
|
65
133
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
66
|
-
|
|
134
|
+
invariant(evaledValue !== void 0, 66, directive.name.value);
|
|
67
135
|
}
|
|
68
136
|
else {
|
|
69
137
|
evaledValue = ifArgument.value.value;
|
|
@@ -99,33 +167,49 @@ function getInclusionDirectives(directives) {
|
|
|
99
167
|
return;
|
|
100
168
|
var directiveArguments = directive.arguments;
|
|
101
169
|
var directiveName = directive.name.value;
|
|
102
|
-
|
|
170
|
+
invariant(directiveArguments && directiveArguments.length === 1, 67, directiveName);
|
|
103
171
|
var ifArgument = directiveArguments[0];
|
|
104
|
-
|
|
172
|
+
invariant(ifArgument.name && ifArgument.name.value === 'if', 68, directiveName);
|
|
105
173
|
var ifValue = ifArgument.value;
|
|
106
|
-
|
|
107
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
108
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 44);
|
|
174
|
+
invariant(ifValue &&
|
|
175
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 69, directiveName);
|
|
109
176
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
110
177
|
});
|
|
111
178
|
}
|
|
112
179
|
return result;
|
|
113
180
|
}
|
|
114
181
|
|
|
182
|
+
var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
183
|
+
maybe(function () { return navigator.product; }) !== 'ReactNative';
|
|
184
|
+
var canUseWeakSet = typeof WeakSet === 'function';
|
|
185
|
+
var canUseSymbol = typeof Symbol === 'function' &&
|
|
186
|
+
typeof Symbol.for === 'function';
|
|
187
|
+
var canUseAsyncIteratorSymbol = canUseSymbol && Symbol.asyncIterator;
|
|
188
|
+
var canUseDOM = typeof maybe(function () { return window.document.createElement; }) === "function";
|
|
189
|
+
var usingJSDOM = maybe(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
|
|
190
|
+
var canUseLayoutEffect = canUseDOM && !usingJSDOM;
|
|
191
|
+
|
|
192
|
+
function isNonNullObject(obj) {
|
|
193
|
+
return obj !== null && typeof obj === 'object';
|
|
194
|
+
}
|
|
195
|
+
|
|
115
196
|
function getFragmentQueryDocument(document, fragmentName) {
|
|
116
197
|
var actualFragmentName = fragmentName;
|
|
117
198
|
var fragments = [];
|
|
118
199
|
document.definitions.forEach(function (definition) {
|
|
119
200
|
if (definition.kind === 'OperationDefinition') {
|
|
120
|
-
throw
|
|
121
|
-
|
|
201
|
+
throw newInvariantError(
|
|
202
|
+
70,
|
|
203
|
+
definition.operation,
|
|
204
|
+
definition.name ? " named '".concat(definition.name.value, "'") : ''
|
|
205
|
+
);
|
|
122
206
|
}
|
|
123
207
|
if (definition.kind === 'FragmentDefinition') {
|
|
124
208
|
fragments.push(definition);
|
|
125
209
|
}
|
|
126
210
|
});
|
|
127
211
|
if (typeof actualFragmentName === 'undefined') {
|
|
128
|
-
|
|
212
|
+
invariant(fragments.length === 1, 71, fragments.length);
|
|
129
213
|
actualFragmentName = fragments[0].name.value;
|
|
130
214
|
}
|
|
131
215
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -166,7 +250,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
166
250
|
return fragmentMap(fragmentName);
|
|
167
251
|
}
|
|
168
252
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
169
|
-
|
|
253
|
+
invariant(fragment, 72, fragmentName);
|
|
170
254
|
return fragment || null;
|
|
171
255
|
}
|
|
172
256
|
default:
|
|
@@ -174,10 +258,6 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
174
258
|
}
|
|
175
259
|
}
|
|
176
260
|
|
|
177
|
-
function isNonNullObject(obj) {
|
|
178
|
-
return obj !== null && typeof obj === 'object';
|
|
179
|
-
}
|
|
180
|
-
|
|
181
261
|
function makeReference(id) {
|
|
182
262
|
return { __ref: String(id) };
|
|
183
263
|
}
|
|
@@ -248,9 +328,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
248
328
|
argObj[name.value] = null;
|
|
249
329
|
}
|
|
250
330
|
else {
|
|
251
|
-
throw
|
|
252
|
-
'is not supported. Use variables instead of inline arguments to ' +
|
|
253
|
-
'overcome this limitation.') : new tsInvariant.InvariantError(56);
|
|
331
|
+
throw newInvariantError(81, name.value, value.kind);
|
|
254
332
|
}
|
|
255
333
|
}
|
|
256
334
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -284,6 +362,7 @@ var KNOWN_DIRECTIVES = [
|
|
|
284
362
|
'client',
|
|
285
363
|
'rest',
|
|
286
364
|
'export',
|
|
365
|
+
'nonreactive',
|
|
287
366
|
];
|
|
288
367
|
var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
289
368
|
if (args &&
|
|
@@ -358,9 +437,7 @@ function resultKeyNameFromField(field) {
|
|
|
358
437
|
return field.alias ? field.alias.value : field.name.value;
|
|
359
438
|
}
|
|
360
439
|
function getTypenameFromResult(result, selectionSet, fragmentMap) {
|
|
361
|
-
|
|
362
|
-
return result.__typename;
|
|
363
|
-
}
|
|
440
|
+
var fragments;
|
|
364
441
|
for (var _i = 0, _a = selectionSet.selections; _i < _a.length; _i++) {
|
|
365
442
|
var selection = _a[_i];
|
|
366
443
|
if (isField(selection)) {
|
|
@@ -368,7 +445,19 @@ function getTypenameFromResult(result, selectionSet, fragmentMap) {
|
|
|
368
445
|
return result[resultKeyNameFromField(selection)];
|
|
369
446
|
}
|
|
370
447
|
}
|
|
448
|
+
else if (fragments) {
|
|
449
|
+
fragments.push(selection);
|
|
450
|
+
}
|
|
371
451
|
else {
|
|
452
|
+
fragments = [selection];
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
if (typeof result.__typename === 'string') {
|
|
456
|
+
return result.__typename;
|
|
457
|
+
}
|
|
458
|
+
if (fragments) {
|
|
459
|
+
for (var _b = 0, fragments_1 = fragments; _b < fragments_1.length; _b++) {
|
|
460
|
+
var selection = fragments_1[_b];
|
|
372
461
|
var typename = getTypenameFromResult(result, getFragmentFromSelection(selection, fragmentMap).selectionSet, fragmentMap);
|
|
373
462
|
if (typeof typename === 'string') {
|
|
374
463
|
return typename;
|
|
@@ -384,16 +473,16 @@ function isInlineFragment(selection) {
|
|
|
384
473
|
}
|
|
385
474
|
|
|
386
475
|
function checkDocument(doc) {
|
|
387
|
-
|
|
476
|
+
invariant(doc && doc.kind === 'Document', 73);
|
|
388
477
|
var operations = doc.definitions
|
|
389
478
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
390
479
|
.map(function (definition) {
|
|
391
480
|
if (definition.kind !== 'OperationDefinition') {
|
|
392
|
-
throw
|
|
481
|
+
throw newInvariantError(74, definition.kind);
|
|
393
482
|
}
|
|
394
483
|
return definition;
|
|
395
484
|
});
|
|
396
|
-
|
|
485
|
+
invariant(operations.length <= 1, 75, operations.length);
|
|
397
486
|
return doc;
|
|
398
487
|
}
|
|
399
488
|
function getOperationDefinition(doc) {
|
|
@@ -416,14 +505,14 @@ function getFragmentDefinitions(doc) {
|
|
|
416
505
|
}
|
|
417
506
|
function getQueryDefinition(doc) {
|
|
418
507
|
var queryDef = getOperationDefinition(doc);
|
|
419
|
-
|
|
508
|
+
invariant(queryDef && queryDef.operation === 'query', 76);
|
|
420
509
|
return queryDef;
|
|
421
510
|
}
|
|
422
511
|
function getFragmentDefinition(doc) {
|
|
423
|
-
|
|
424
|
-
|
|
512
|
+
invariant(doc.kind === 'Document', 77);
|
|
513
|
+
invariant(doc.definitions.length <= 1, 78);
|
|
425
514
|
var fragmentDef = doc.definitions[0];
|
|
426
|
-
|
|
515
|
+
invariant(fragmentDef.kind === 'FragmentDefinition', 79);
|
|
427
516
|
return fragmentDef;
|
|
428
517
|
}
|
|
429
518
|
function getMainDefinition(queryDoc) {
|
|
@@ -446,7 +535,7 @@ function getMainDefinition(queryDoc) {
|
|
|
446
535
|
if (fragmentDefinition) {
|
|
447
536
|
return fragmentDefinition;
|
|
448
537
|
}
|
|
449
|
-
throw
|
|
538
|
+
throw newInvariantError(80);
|
|
450
539
|
}
|
|
451
540
|
function getDefaultValues(definition) {
|
|
452
541
|
var defaultValues = Object.create(null);
|
|
@@ -461,6 +550,70 @@ function getDefaultValues(definition) {
|
|
|
461
550
|
return defaultValues;
|
|
462
551
|
}
|
|
463
552
|
|
|
553
|
+
function identity(document) {
|
|
554
|
+
return document;
|
|
555
|
+
}
|
|
556
|
+
var DocumentTransform = (function () {
|
|
557
|
+
function DocumentTransform(transform, options) {
|
|
558
|
+
if (options === void 0) { options = Object.create(null); }
|
|
559
|
+
this.resultCache = canUseWeakSet
|
|
560
|
+
? new WeakSet()
|
|
561
|
+
: new Set();
|
|
562
|
+
this.transform = transform;
|
|
563
|
+
if (options.getCacheKey) {
|
|
564
|
+
this.getCacheKey = options.getCacheKey;
|
|
565
|
+
}
|
|
566
|
+
if (options.cache !== false) {
|
|
567
|
+
this.stableCacheKeys = new trie.Trie(canUseWeakMap, function (key) { return ({ key: key }); });
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
DocumentTransform.prototype.getCacheKey = function (document) {
|
|
571
|
+
return [document];
|
|
572
|
+
};
|
|
573
|
+
DocumentTransform.identity = function () {
|
|
574
|
+
return new DocumentTransform(identity, { cache: false });
|
|
575
|
+
};
|
|
576
|
+
DocumentTransform.split = function (predicate, left, right) {
|
|
577
|
+
if (right === void 0) { right = DocumentTransform.identity(); }
|
|
578
|
+
return new DocumentTransform(function (document) {
|
|
579
|
+
var documentTransform = predicate(document) ? left : right;
|
|
580
|
+
return documentTransform.transformDocument(document);
|
|
581
|
+
}, { cache: false });
|
|
582
|
+
};
|
|
583
|
+
DocumentTransform.prototype.transformDocument = function (document) {
|
|
584
|
+
if (this.resultCache.has(document)) {
|
|
585
|
+
return document;
|
|
586
|
+
}
|
|
587
|
+
var cacheEntry = this.getStableCacheEntry(document);
|
|
588
|
+
if (cacheEntry && cacheEntry.value) {
|
|
589
|
+
return cacheEntry.value;
|
|
590
|
+
}
|
|
591
|
+
checkDocument(document);
|
|
592
|
+
var transformedDocument = this.transform(document);
|
|
593
|
+
this.resultCache.add(transformedDocument);
|
|
594
|
+
if (cacheEntry) {
|
|
595
|
+
cacheEntry.value = transformedDocument;
|
|
596
|
+
}
|
|
597
|
+
return transformedDocument;
|
|
598
|
+
};
|
|
599
|
+
DocumentTransform.prototype.concat = function (otherTransform) {
|
|
600
|
+
var _this = this;
|
|
601
|
+
return new DocumentTransform(function (document) {
|
|
602
|
+
return otherTransform.transformDocument(_this.transformDocument(document));
|
|
603
|
+
}, { cache: false });
|
|
604
|
+
};
|
|
605
|
+
DocumentTransform.prototype.getStableCacheEntry = function (document) {
|
|
606
|
+
if (!this.stableCacheKeys)
|
|
607
|
+
return;
|
|
608
|
+
var cacheKeys = this.getCacheKey(document);
|
|
609
|
+
if (cacheKeys) {
|
|
610
|
+
invariant(Array.isArray(cacheKeys), 65);
|
|
611
|
+
return this.stableCacheKeys.lookupArray(cacheKeys);
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
return DocumentTransform;
|
|
615
|
+
}());
|
|
616
|
+
|
|
464
617
|
var isArray = Array.isArray;
|
|
465
618
|
function isNonEmptyArray(value) {
|
|
466
619
|
return Array.isArray(value) && value.length > 0;
|
|
@@ -482,19 +635,30 @@ function nullIfDocIsEmpty(doc) {
|
|
|
482
635
|
? null
|
|
483
636
|
: doc;
|
|
484
637
|
}
|
|
485
|
-
function getDirectiveMatcher(
|
|
486
|
-
var
|
|
487
|
-
var tests =
|
|
488
|
-
|
|
489
|
-
if (directive
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
638
|
+
function getDirectiveMatcher(configs) {
|
|
639
|
+
var names = new Map();
|
|
640
|
+
var tests = new Map();
|
|
641
|
+
configs.forEach(function (directive) {
|
|
642
|
+
if (directive) {
|
|
643
|
+
if (directive.name) {
|
|
644
|
+
names.set(directive.name, directive);
|
|
645
|
+
}
|
|
646
|
+
else if (directive.test) {
|
|
647
|
+
tests.set(directive.test, directive);
|
|
648
|
+
}
|
|
494
649
|
}
|
|
495
650
|
});
|
|
496
|
-
return function (directive) {
|
|
497
|
-
|
|
651
|
+
return function (directive) {
|
|
652
|
+
var config = names.get(directive.name.value);
|
|
653
|
+
if (!config && tests.size) {
|
|
654
|
+
tests.forEach(function (testConfig, test) {
|
|
655
|
+
if (test(directive)) {
|
|
656
|
+
config = testConfig;
|
|
657
|
+
}
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
return config;
|
|
661
|
+
};
|
|
498
662
|
}
|
|
499
663
|
function makeInUseGetterFunction(defaultKey) {
|
|
500
664
|
var map = new Map();
|
|
@@ -511,6 +675,7 @@ function makeInUseGetterFunction(defaultKey) {
|
|
|
511
675
|
};
|
|
512
676
|
}
|
|
513
677
|
function removeDirectivesFromDocument(directives, doc) {
|
|
678
|
+
checkDocument(doc);
|
|
514
679
|
var getInUseByOperationName = makeInUseGetterFunction("");
|
|
515
680
|
var getInUseByFragmentName = makeInUseGetterFunction("");
|
|
516
681
|
var getInUse = function (ancestors) {
|
|
@@ -524,7 +689,7 @@ function removeDirectivesFromDocument(directives, doc) {
|
|
|
524
689
|
return getInUseByFragmentName(ancestor.name.value);
|
|
525
690
|
}
|
|
526
691
|
}
|
|
527
|
-
__DEV__ &&
|
|
692
|
+
__DEV__ && invariant.error(82);
|
|
528
693
|
return null;
|
|
529
694
|
};
|
|
530
695
|
var operationCount = 0;
|
|
@@ -534,10 +699,8 @@ function removeDirectivesFromDocument(directives, doc) {
|
|
|
534
699
|
}
|
|
535
700
|
}
|
|
536
701
|
var directiveMatcher = getDirectiveMatcher(directives);
|
|
537
|
-
var
|
|
538
|
-
|
|
539
|
-
nodeDirectives &&
|
|
540
|
-
nodeDirectives.some(directiveMatcher)); };
|
|
702
|
+
var shouldRemoveField = function (nodeDirectives) { return (isNonEmptyArray(nodeDirectives) &&
|
|
703
|
+
nodeDirectives.map(directiveMatcher).some(function (config) { return config && config.remove; })); };
|
|
541
704
|
var originalFragmentDefsByPath = new Map();
|
|
542
705
|
var firstVisitMadeChanges = false;
|
|
543
706
|
var fieldOrInlineFragmentVisitor = {
|
|
@@ -696,22 +859,6 @@ var addTypenameToDocument = Object.assign(function (doc) {
|
|
|
696
859
|
return field === TYPENAME_FIELD;
|
|
697
860
|
},
|
|
698
861
|
});
|
|
699
|
-
var connectionRemoveConfig = {
|
|
700
|
-
test: function (directive) {
|
|
701
|
-
var willRemove = directive.name.value === 'connection';
|
|
702
|
-
if (willRemove) {
|
|
703
|
-
if (!directive.arguments ||
|
|
704
|
-
!directive.arguments.some(function (arg) { return arg.name.value === 'key'; })) {
|
|
705
|
-
__DEV__ && tsInvariant.invariant.warn('Removing an @connection directive even though it does not have a key. ' +
|
|
706
|
-
'You may want to use the key parameter to specify a store key.');
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
return willRemove;
|
|
710
|
-
},
|
|
711
|
-
};
|
|
712
|
-
function removeConnectionDirectiveFromDocument(doc) {
|
|
713
|
-
return removeDirectivesFromDocument([connectionRemoveConfig], checkDocument(doc));
|
|
714
|
-
}
|
|
715
862
|
function buildQueryFromSelectionSet(document) {
|
|
716
863
|
var definition = getMainDefinition(document);
|
|
717
864
|
var definitionOperation = definition.operation;
|
|
@@ -811,6 +958,43 @@ var DeepMerger = (function () {
|
|
|
811
958
|
return DeepMerger;
|
|
812
959
|
}());
|
|
813
960
|
|
|
961
|
+
function createFulfilledPromise(value) {
|
|
962
|
+
var promise = Promise.resolve(value);
|
|
963
|
+
promise.status = 'fulfilled';
|
|
964
|
+
promise.value = value;
|
|
965
|
+
return promise;
|
|
966
|
+
}
|
|
967
|
+
function createRejectedPromise(reason) {
|
|
968
|
+
var promise = Promise.reject(reason);
|
|
969
|
+
promise.status = 'rejected';
|
|
970
|
+
promise.reason = reason;
|
|
971
|
+
return promise;
|
|
972
|
+
}
|
|
973
|
+
function isStatefulPromise(promise) {
|
|
974
|
+
return 'status' in promise;
|
|
975
|
+
}
|
|
976
|
+
function wrapPromiseWithState(promise) {
|
|
977
|
+
if (isStatefulPromise(promise)) {
|
|
978
|
+
return promise;
|
|
979
|
+
}
|
|
980
|
+
var pendingPromise = promise;
|
|
981
|
+
pendingPromise.status = 'pending';
|
|
982
|
+
pendingPromise.then(function (value) {
|
|
983
|
+
if (pendingPromise.status === 'pending') {
|
|
984
|
+
var fulfilledPromise = pendingPromise;
|
|
985
|
+
fulfilledPromise.status = 'fulfilled';
|
|
986
|
+
fulfilledPromise.value = value;
|
|
987
|
+
}
|
|
988
|
+
}, function (reason) {
|
|
989
|
+
if (pendingPromise.status === 'pending') {
|
|
990
|
+
var rejectedPromise = pendingPromise;
|
|
991
|
+
rejectedPromise.status = 'rejected';
|
|
992
|
+
rejectedPromise.reason = reason;
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
return promise;
|
|
996
|
+
}
|
|
997
|
+
|
|
814
998
|
var toString = Object.prototype.toString;
|
|
815
999
|
function cloneDeep(value) {
|
|
816
1000
|
return cloneDeepHelper(value);
|
|
@@ -930,16 +1114,6 @@ function asyncMap(observable, mapFn, catchFn) {
|
|
|
930
1114
|
});
|
|
931
1115
|
}
|
|
932
1116
|
|
|
933
|
-
var canUseWeakMap = typeof WeakMap === 'function' &&
|
|
934
|
-
maybe(function () { return navigator.product; }) !== 'ReactNative';
|
|
935
|
-
var canUseWeakSet = typeof WeakSet === 'function';
|
|
936
|
-
var canUseSymbol = typeof Symbol === 'function' &&
|
|
937
|
-
typeof Symbol.for === 'function';
|
|
938
|
-
var canUseAsyncIteratorSymbol = canUseSymbol && Symbol.asyncIterator;
|
|
939
|
-
var canUseDOM = typeof maybe(function () { return window.document.createElement; }) === "function";
|
|
940
|
-
var usingJSDOM = maybe(function () { return navigator.userAgent.indexOf("jsdom") >= 0; }) || false;
|
|
941
|
-
var canUseLayoutEffect = canUseDOM && !usingJSDOM;
|
|
942
|
-
|
|
943
1117
|
function fixObservableSubclass(subclass) {
|
|
944
1118
|
function set(key) {
|
|
945
1119
|
Object.defineProperty(subclass, key, { value: zenObservableTs.Observable });
|
|
@@ -1093,6 +1267,9 @@ function isExecutionPatchResult(value) {
|
|
|
1093
1267
|
return (isExecutionPatchIncrementalResult(value) ||
|
|
1094
1268
|
isExecutionPatchInitialResult(value));
|
|
1095
1269
|
}
|
|
1270
|
+
function isApolloPayloadResult(value) {
|
|
1271
|
+
return isNonNullObject(value) && "payload" in value;
|
|
1272
|
+
}
|
|
1096
1273
|
function mergeIncrementalData(prevResult, result) {
|
|
1097
1274
|
var mergedData = prevResult;
|
|
1098
1275
|
var merger = new DeepMerger();
|
|
@@ -1151,23 +1328,9 @@ function compact() {
|
|
|
1151
1328
|
return result;
|
|
1152
1329
|
}
|
|
1153
1330
|
|
|
1154
|
-
var prefixCounts = new Map();
|
|
1155
|
-
function makeUniqueId(prefix) {
|
|
1156
|
-
var count = prefixCounts.get(prefix) || 1;
|
|
1157
|
-
prefixCounts.set(prefix, count + 1);
|
|
1158
|
-
return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
function stringifyForDisplay(value) {
|
|
1162
|
-
var undefId = makeUniqueId("stringifyForDisplay");
|
|
1163
|
-
return JSON.stringify(value, function (key, value) {
|
|
1164
|
-
return value === void 0 ? undefId : value;
|
|
1165
|
-
}).split(JSON.stringify(undefId)).join("<undefined>");
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
1331
|
function mergeOptions(defaults, options) {
|
|
1169
1332
|
return compact(defaults, options, options.variables && {
|
|
1170
|
-
variables: tslib.__assign(tslib.__assign({}, (defaults && defaults.variables)), options.variables),
|
|
1333
|
+
variables: compact(tslib.__assign(tslib.__assign({}, (defaults && defaults.variables)), options.variables)),
|
|
1171
1334
|
});
|
|
1172
1335
|
}
|
|
1173
1336
|
|
|
@@ -1203,7 +1366,7 @@ function toPromise(observable) {
|
|
|
1203
1366
|
observable.subscribe({
|
|
1204
1367
|
next: function (data) {
|
|
1205
1368
|
if (completed) {
|
|
1206
|
-
__DEV__ &&
|
|
1369
|
+
__DEV__ && invariant.warn(41);
|
|
1207
1370
|
}
|
|
1208
1371
|
else {
|
|
1209
1372
|
completed = true;
|
|
@@ -1246,7 +1409,7 @@ function validateOperation(operation) {
|
|
|
1246
1409
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1247
1410
|
var key = _a[_i];
|
|
1248
1411
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1249
|
-
throw
|
|
1412
|
+
throw newInvariantError(42, key);
|
|
1250
1413
|
}
|
|
1251
1414
|
}
|
|
1252
1415
|
return operation;
|
|
@@ -1290,6 +1453,22 @@ function transformOperation(operation) {
|
|
|
1290
1453
|
return transformedOperation;
|
|
1291
1454
|
}
|
|
1292
1455
|
|
|
1456
|
+
function filterOperationVariables(variables, operation) {
|
|
1457
|
+
var result = tslib.__assign({}, variables);
|
|
1458
|
+
var unusedNames = new Set(Object.keys(variables));
|
|
1459
|
+
graphql.visit(operation.query, {
|
|
1460
|
+
Variable: function (node, _key, parent) {
|
|
1461
|
+
if (parent && parent.kind !== 'VariableDefinition') {
|
|
1462
|
+
unusedNames.delete(node.name.value);
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
});
|
|
1466
|
+
unusedNames.forEach(function (name) {
|
|
1467
|
+
delete result[name];
|
|
1468
|
+
});
|
|
1469
|
+
return result;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1293
1472
|
function passthrough(op, forward) {
|
|
1294
1473
|
return (forward ? forward(op) : zenObservableTs.Observable.of());
|
|
1295
1474
|
}
|
|
@@ -1299,15 +1478,6 @@ function toLink(handler) {
|
|
|
1299
1478
|
function isTerminating(link) {
|
|
1300
1479
|
return link.request.length <= 1;
|
|
1301
1480
|
}
|
|
1302
|
-
var LinkError = (function (_super) {
|
|
1303
|
-
tslib.__extends(LinkError, _super);
|
|
1304
|
-
function LinkError(message, link) {
|
|
1305
|
-
var _this = _super.call(this, message) || this;
|
|
1306
|
-
_this.link = link;
|
|
1307
|
-
return _this;
|
|
1308
|
-
}
|
|
1309
|
-
return LinkError;
|
|
1310
|
-
}(Error));
|
|
1311
1481
|
var ApolloLink = (function () {
|
|
1312
1482
|
function ApolloLink(request) {
|
|
1313
1483
|
if (request)
|
|
@@ -1345,7 +1515,7 @@ var ApolloLink = (function () {
|
|
|
1345
1515
|
ApolloLink.concat = function (first, second) {
|
|
1346
1516
|
var firstLink = toLink(first);
|
|
1347
1517
|
if (isTerminating(firstLink)) {
|
|
1348
|
-
__DEV__ &&
|
|
1518
|
+
__DEV__ && invariant.warn(34, firstLink);
|
|
1349
1519
|
return firstLink;
|
|
1350
1520
|
}
|
|
1351
1521
|
var nextLink = toLink(second);
|
|
@@ -1369,7 +1539,7 @@ var ApolloLink = (function () {
|
|
|
1369
1539
|
return ApolloLink.concat(this, next);
|
|
1370
1540
|
};
|
|
1371
1541
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
1372
|
-
throw
|
|
1542
|
+
throw newInvariantError(35);
|
|
1373
1543
|
};
|
|
1374
1544
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
1375
1545
|
if (observer && observer.error) {
|
|
@@ -1395,8 +1565,6 @@ var concat = ApolloLink.concat;
|
|
|
1395
1565
|
|
|
1396
1566
|
var execute = ApolloLink.execute;
|
|
1397
1567
|
|
|
1398
|
-
var version = '3.8.0-alpha.9';
|
|
1399
|
-
|
|
1400
1568
|
function asyncIterator(source) {
|
|
1401
1569
|
var _a;
|
|
1402
1570
|
var iterator = source[Symbol.asyncIterator]();
|
|
@@ -1540,60 +1708,115 @@ function responseIterator(response) {
|
|
|
1540
1708
|
throw new Error("Unknown body type for responseIterator. Please pass a streamable response.");
|
|
1541
1709
|
}
|
|
1542
1710
|
|
|
1711
|
+
var PROTOCOL_ERRORS_SYMBOL = Symbol();
|
|
1712
|
+
function graphQLResultHasProtocolErrors(result) {
|
|
1713
|
+
if (result.extensions) {
|
|
1714
|
+
return Array.isArray(result.extensions[PROTOCOL_ERRORS_SYMBOL]);
|
|
1715
|
+
}
|
|
1716
|
+
return false;
|
|
1717
|
+
}
|
|
1718
|
+
function isApolloError(err) {
|
|
1719
|
+
return err.hasOwnProperty('graphQLErrors');
|
|
1720
|
+
}
|
|
1721
|
+
var generateErrorMessage = function (err) {
|
|
1722
|
+
var errors = tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], err.graphQLErrors, true), err.clientErrors, true), err.protocolErrors, true);
|
|
1723
|
+
if (err.networkError)
|
|
1724
|
+
errors.push(err.networkError);
|
|
1725
|
+
return errors
|
|
1726
|
+
.map(function (err) { return isNonNullObject(err) && err.message || 'Error message not found.'; })
|
|
1727
|
+
.join('\n');
|
|
1728
|
+
};
|
|
1729
|
+
var ApolloError = (function (_super) {
|
|
1730
|
+
tslib.__extends(ApolloError, _super);
|
|
1731
|
+
function ApolloError(_a) {
|
|
1732
|
+
var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
1733
|
+
var _this = _super.call(this, errorMessage) || this;
|
|
1734
|
+
_this.name = 'ApolloError';
|
|
1735
|
+
_this.graphQLErrors = graphQLErrors || [];
|
|
1736
|
+
_this.protocolErrors = protocolErrors || [];
|
|
1737
|
+
_this.clientErrors = clientErrors || [];
|
|
1738
|
+
_this.networkError = networkError || null;
|
|
1739
|
+
_this.message = errorMessage || generateErrorMessage(_this);
|
|
1740
|
+
_this.extraInfo = extraInfo;
|
|
1741
|
+
_this.__proto__ = ApolloError.prototype;
|
|
1742
|
+
return _this;
|
|
1743
|
+
}
|
|
1744
|
+
return ApolloError;
|
|
1745
|
+
}(Error));
|
|
1746
|
+
|
|
1543
1747
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1544
1748
|
function readMultipartBody(response, observer) {
|
|
1545
|
-
var _a, _b, _c;
|
|
1749
|
+
var _a, _b, _c, _d, _e;
|
|
1546
1750
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1547
|
-
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running,
|
|
1548
|
-
var
|
|
1549
|
-
return tslib.__generator(this, function (
|
|
1550
|
-
switch (
|
|
1751
|
+
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _f, value, done, chunk, searchFrom, bi, message, i, headers, contentType_1, body, result, next;
|
|
1752
|
+
var _g, _h;
|
|
1753
|
+
return tslib.__generator(this, function (_j) {
|
|
1754
|
+
switch (_j.label) {
|
|
1551
1755
|
case 0:
|
|
1552
1756
|
if (TextDecoder === undefined) {
|
|
1553
1757
|
throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
|
|
1554
1758
|
}
|
|
1555
1759
|
decoder = new TextDecoder("utf-8");
|
|
1556
|
-
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get(
|
|
1760
|
+
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get("content-type");
|
|
1557
1761
|
delimiter = "boundary=";
|
|
1558
1762
|
boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter))
|
|
1559
1763
|
? contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
|
|
1560
1764
|
: "-";
|
|
1561
|
-
boundary = "--".concat(boundaryVal);
|
|
1765
|
+
boundary = "\r\n--".concat(boundaryVal);
|
|
1562
1766
|
buffer = "";
|
|
1563
1767
|
iterator = responseIterator(response);
|
|
1564
1768
|
running = true;
|
|
1565
|
-
|
|
1769
|
+
_j.label = 1;
|
|
1566
1770
|
case 1:
|
|
1567
1771
|
if (!running) return [3, 3];
|
|
1568
1772
|
return [4, iterator.next()];
|
|
1569
1773
|
case 2:
|
|
1570
|
-
|
|
1774
|
+
_f = _j.sent(), value = _f.value, done = _f.done;
|
|
1571
1775
|
chunk = typeof value === "string" ? value : decoder.decode(value);
|
|
1776
|
+
searchFrom = buffer.length - boundary.length + 1;
|
|
1572
1777
|
running = !done;
|
|
1573
1778
|
buffer += chunk;
|
|
1574
|
-
bi = buffer.indexOf(boundary);
|
|
1779
|
+
bi = buffer.indexOf(boundary, searchFrom);
|
|
1575
1780
|
while (bi > -1) {
|
|
1576
1781
|
message = void 0;
|
|
1577
|
-
|
|
1782
|
+
_g = [
|
|
1578
1783
|
buffer.slice(0, bi),
|
|
1579
1784
|
buffer.slice(bi + boundary.length),
|
|
1580
|
-
], message =
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1785
|
+
], message = _g[0], buffer = _g[1];
|
|
1786
|
+
i = message.indexOf("\r\n\r\n");
|
|
1787
|
+
headers = parseHeaders(message.slice(0, i));
|
|
1788
|
+
contentType_1 = headers["content-type"];
|
|
1789
|
+
if (contentType_1 &&
|
|
1790
|
+
contentType_1.toLowerCase().indexOf("application/json") === -1) {
|
|
1791
|
+
throw new Error("Unsupported patch content type: application/json is required.");
|
|
1792
|
+
}
|
|
1793
|
+
body = message.slice(i);
|
|
1794
|
+
if (body) {
|
|
1590
1795
|
try {
|
|
1591
|
-
result = parseJsonBody(response, body
|
|
1796
|
+
result = parseJsonBody(response, body);
|
|
1592
1797
|
if (Object.keys(result).length > 1 ||
|
|
1593
1798
|
"data" in result ||
|
|
1594
1799
|
"incremental" in result ||
|
|
1595
|
-
"errors" in result
|
|
1596
|
-
|
|
1800
|
+
"errors" in result ||
|
|
1801
|
+
"payload" in result) {
|
|
1802
|
+
if (isApolloPayloadResult(result)) {
|
|
1803
|
+
next = {};
|
|
1804
|
+
if ("payload" in result) {
|
|
1805
|
+
next = tslib.__assign({}, result.payload);
|
|
1806
|
+
}
|
|
1807
|
+
if ("errors" in result) {
|
|
1808
|
+
next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (_h = {}, _h[PROTOCOL_ERRORS_SYMBOL] = result.errors, _h)) });
|
|
1809
|
+
}
|
|
1810
|
+
(_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, next);
|
|
1811
|
+
}
|
|
1812
|
+
else {
|
|
1813
|
+
(_c = observer.next) === null || _c === void 0 ? void 0 : _c.call(observer, result);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
else if (Object.keys(result).length === 1 &&
|
|
1817
|
+
"hasNext" in result &&
|
|
1818
|
+
!result.hasNext) {
|
|
1819
|
+
(_d = observer.complete) === null || _d === void 0 ? void 0 : _d.call(observer);
|
|
1597
1820
|
}
|
|
1598
1821
|
}
|
|
1599
1822
|
catch (err) {
|
|
@@ -1604,7 +1827,7 @@ function readMultipartBody(response, observer) {
|
|
|
1604
1827
|
}
|
|
1605
1828
|
return [3, 1];
|
|
1606
1829
|
case 3:
|
|
1607
|
-
(
|
|
1830
|
+
(_e = observer.complete) === null || _e === void 0 ? void 0 : _e.call(observer);
|
|
1608
1831
|
return [2];
|
|
1609
1832
|
}
|
|
1610
1833
|
});
|
|
@@ -1691,7 +1914,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
1691
1914
|
serialized = JSON.stringify(p);
|
|
1692
1915
|
}
|
|
1693
1916
|
catch (e) {
|
|
1694
|
-
var parseError =
|
|
1917
|
+
var parseError = newInvariantError(38, label, e.message);
|
|
1695
1918
|
parseError.parseError = e;
|
|
1696
1919
|
throw parseError;
|
|
1697
1920
|
}
|
|
@@ -1774,7 +1997,7 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
|
|
|
1774
1997
|
|
|
1775
1998
|
var checkFetcher = function (fetcher) {
|
|
1776
1999
|
if (!fetcher && typeof fetch === 'undefined') {
|
|
1777
|
-
throw
|
|
2000
|
+
throw newInvariantError(36);
|
|
1778
2001
|
}
|
|
1779
2002
|
};
|
|
1780
2003
|
|
|
@@ -1884,20 +2107,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
1884
2107
|
}
|
|
1885
2108
|
var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
|
|
1886
2109
|
if (body.variables && !includeUnusedVariables) {
|
|
1887
|
-
|
|
1888
|
-
graphql.visit(operation.query, {
|
|
1889
|
-
Variable: function (node, _key, parent) {
|
|
1890
|
-
if (parent && parent.kind !== 'VariableDefinition') {
|
|
1891
|
-
unusedNames_1.delete(node.name.value);
|
|
1892
|
-
}
|
|
1893
|
-
},
|
|
1894
|
-
});
|
|
1895
|
-
if (unusedNames_1.size) {
|
|
1896
|
-
body.variables = tslib.__assign({}, body.variables);
|
|
1897
|
-
unusedNames_1.forEach(function (name) {
|
|
1898
|
-
delete body.variables[name];
|
|
1899
|
-
});
|
|
1900
|
-
}
|
|
2110
|
+
body.variables = filterOperationVariables(body.variables, operation);
|
|
1901
2111
|
}
|
|
1902
2112
|
var controller;
|
|
1903
2113
|
if (!options.signal) {
|
|
@@ -1909,13 +2119,28 @@ var createHttpLink = function (linkOptions) {
|
|
|
1909
2119
|
var definitionIsMutation = function (d) {
|
|
1910
2120
|
return d.kind === 'OperationDefinition' && d.operation === 'mutation';
|
|
1911
2121
|
};
|
|
2122
|
+
var definitionIsSubscription = function (d) {
|
|
2123
|
+
return d.kind === 'OperationDefinition' && d.operation === 'subscription';
|
|
2124
|
+
};
|
|
2125
|
+
var isSubscription = definitionIsSubscription(getMainDefinition(operation.query));
|
|
2126
|
+
var hasDefer = hasDirectives(['defer'], operation.query);
|
|
1912
2127
|
if (useGETForQueries &&
|
|
1913
2128
|
!operation.query.definitions.some(definitionIsMutation)) {
|
|
1914
2129
|
options.method = 'GET';
|
|
1915
2130
|
}
|
|
1916
|
-
if (
|
|
2131
|
+
if (hasDefer || isSubscription) {
|
|
1917
2132
|
options.headers = options.headers || {};
|
|
1918
|
-
|
|
2133
|
+
var acceptHeader = "multipart/mixed;";
|
|
2134
|
+
if (isSubscription && hasDefer) {
|
|
2135
|
+
__DEV__ && invariant.warn(37);
|
|
2136
|
+
}
|
|
2137
|
+
if (isSubscription) {
|
|
2138
|
+
acceptHeader += 'boundary=graphql;subscriptionSpec=1.0,application/json';
|
|
2139
|
+
}
|
|
2140
|
+
else if (hasDefer) {
|
|
2141
|
+
acceptHeader += 'deferSpec=20220824,application/json';
|
|
2142
|
+
}
|
|
2143
|
+
options.headers.accept = acceptHeader;
|
|
1919
2144
|
}
|
|
1920
2145
|
if (options.method === 'GET') {
|
|
1921
2146
|
var _d = rewriteURIForGET(chosenURI, body), newURI = _d.newURI, parseError = _d.parseError;
|
|
@@ -1968,6 +2193,7 @@ var HttpLink = (function (_super) {
|
|
|
1968
2193
|
|
|
1969
2194
|
var ApolloCache = (function () {
|
|
1970
2195
|
function ApolloCache() {
|
|
2196
|
+
this.assumeImmutableResults = false;
|
|
1971
2197
|
this.getFragmentDoc = optimism.wrap(getFragmentQueryDocument);
|
|
1972
2198
|
}
|
|
1973
2199
|
ApolloCache.prototype.batch = function (options) {
|
|
@@ -2243,7 +2469,7 @@ var EntityStore = (function () {
|
|
|
2243
2469
|
: newer;
|
|
2244
2470
|
if (!incoming)
|
|
2245
2471
|
return;
|
|
2246
|
-
|
|
2472
|
+
invariant(typeof dataId === "string", 1);
|
|
2247
2473
|
var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
|
|
2248
2474
|
this.data[dataId] = merged;
|
|
2249
2475
|
if (merged !== existing) {
|
|
@@ -2566,7 +2792,7 @@ var Layer = (function (_super) {
|
|
|
2566
2792
|
}
|
|
2567
2793
|
else if (ownStoreObject !== parentStoreObject) {
|
|
2568
2794
|
Object.keys(ownStoreObject).forEach(function (storeFieldName) {
|
|
2569
|
-
if (!
|
|
2795
|
+
if (!equal.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
|
|
2570
2796
|
_this.group.dirty(dataId, storeFieldName);
|
|
2571
2797
|
}
|
|
2572
2798
|
});
|
|
@@ -2610,7 +2836,7 @@ var Stump = (function (_super) {
|
|
|
2610
2836
|
function storeObjectReconciler(existingObject, incomingObject, property) {
|
|
2611
2837
|
var existingValue = existingObject[property];
|
|
2612
2838
|
var incomingValue = incomingObject[property];
|
|
2613
|
-
return
|
|
2839
|
+
return equal.equal(existingValue, incomingValue) ? existingValue : incomingValue;
|
|
2614
2840
|
}
|
|
2615
2841
|
function supportsResultCaching(store) {
|
|
2616
2842
|
return !!(store instanceof EntityStore && store.group.caching);
|
|
@@ -2898,7 +3124,7 @@ var StoreReader = (function () {
|
|
|
2898
3124
|
else {
|
|
2899
3125
|
var fragment = getFragmentFromSelection(selection, context.lookupFragment);
|
|
2900
3126
|
if (!fragment && selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
|
|
2901
|
-
throw
|
|
3127
|
+
throw newInvariantError(7, selection.name.value);
|
|
2902
3128
|
}
|
|
2903
3129
|
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
2904
3130
|
fragment.selectionSet.selections.forEach(workSet.add, workSet);
|
|
@@ -2979,7 +3205,12 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
2979
3205
|
var workSet_1 = new Set([fieldValue]);
|
|
2980
3206
|
workSet_1.forEach(function (value) {
|
|
2981
3207
|
if (isNonNullObject(value)) {
|
|
2982
|
-
|
|
3208
|
+
invariant(
|
|
3209
|
+
!isReference(value),
|
|
3210
|
+
8,
|
|
3211
|
+
getTypenameFromStoreObject(store, value),
|
|
3212
|
+
field.name.value
|
|
3213
|
+
);
|
|
2983
3214
|
Object.values(value).forEach(workSet_1.add, workSet_1);
|
|
2984
3215
|
}
|
|
2985
3216
|
});
|
|
@@ -3066,7 +3297,7 @@ function keyFieldsFnFromSpecifier(specifier) {
|
|
|
3066
3297
|
hasOwn.call(object, schemaKeyPath[0])) {
|
|
3067
3298
|
extracted = extractKeyPath(object, schemaKeyPath, extractKey);
|
|
3068
3299
|
}
|
|
3069
|
-
|
|
3300
|
+
invariant(extracted !== void 0, 2, schemaKeyPath.join('.'), object);
|
|
3070
3301
|
return extracted;
|
|
3071
3302
|
});
|
|
3072
3303
|
return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
|
|
@@ -3218,7 +3449,7 @@ var Policies = (function () {
|
|
|
3218
3449
|
var policy = typename && this.getTypePolicy(typename);
|
|
3219
3450
|
var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
|
|
3220
3451
|
while (keyFn) {
|
|
3221
|
-
var specifierOrId = keyFn(object, context);
|
|
3452
|
+
var specifierOrId = keyFn(tslib.__assign(tslib.__assign({}, object), storeObject), context);
|
|
3222
3453
|
if (isArray(specifierOrId)) {
|
|
3223
3454
|
keyFn = keyFieldsFnFromSpecifier(specifierOrId);
|
|
3224
3455
|
}
|
|
@@ -3295,7 +3526,7 @@ var Policies = (function () {
|
|
|
3295
3526
|
var rootId = "ROOT_" + which.toUpperCase();
|
|
3296
3527
|
var old = this.rootTypenamesById[rootId];
|
|
3297
3528
|
if (typename !== old) {
|
|
3298
|
-
|
|
3529
|
+
invariant(!old || old === which, 3, which);
|
|
3299
3530
|
if (old)
|
|
3300
3531
|
delete this.rootIdsByTypename[old];
|
|
3301
3532
|
this.rootIdsByTypename[typename] = rootId;
|
|
@@ -3390,7 +3621,7 @@ var Policies = (function () {
|
|
|
3390
3621
|
if (supertypeSet.has(supertype)) {
|
|
3391
3622
|
if (!typenameSupertypeSet.has(supertype)) {
|
|
3392
3623
|
if (checkingFuzzySubtypes) {
|
|
3393
|
-
__DEV__ &&
|
|
3624
|
+
__DEV__ && invariant.warn(4, typename, supertype);
|
|
3394
3625
|
}
|
|
3395
3626
|
typenameSupertypeSet.add(supertype);
|
|
3396
3627
|
}
|
|
@@ -3544,7 +3775,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
3544
3775
|
}
|
|
3545
3776
|
}
|
|
3546
3777
|
if (__DEV__ && options.from === void 0) {
|
|
3547
|
-
__DEV__ &&
|
|
3778
|
+
__DEV__ && invariant.warn(5, stringifyForDisplay(Array.from(readFieldArgs)));
|
|
3548
3779
|
}
|
|
3549
3780
|
if (void 0 === options.variables) {
|
|
3550
3781
|
options.variables = variables;
|
|
@@ -3554,7 +3785,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
3554
3785
|
function makeMergeObjectsFunction(store) {
|
|
3555
3786
|
return function mergeObjects(existing, incoming) {
|
|
3556
3787
|
if (isArray(existing) || isArray(incoming)) {
|
|
3557
|
-
throw
|
|
3788
|
+
throw newInvariantError(6);
|
|
3558
3789
|
}
|
|
3559
3790
|
if (isNonNullObject(existing) &&
|
|
3560
3791
|
isNonNullObject(incoming)) {
|
|
@@ -3615,7 +3846,7 @@ var StoreWriter = (function () {
|
|
|
3615
3846
|
context: context,
|
|
3616
3847
|
});
|
|
3617
3848
|
if (!isReference(ref)) {
|
|
3618
|
-
throw
|
|
3849
|
+
throw newInvariantError(9, result);
|
|
3619
3850
|
}
|
|
3620
3851
|
context.incomingById.forEach(function (_a, dataId) {
|
|
3621
3852
|
var storeObject = _a.storeObject, mergeTree = _a.mergeTree, fieldNodeSet = _a.fieldNodeSet;
|
|
@@ -3720,7 +3951,7 @@ var StoreWriter = (function () {
|
|
|
3720
3951
|
!context.deferred &&
|
|
3721
3952
|
!addTypenameToDocument.added(field) &&
|
|
3722
3953
|
!policies.getReadFunction(typename, field.name.value)) {
|
|
3723
|
-
__DEV__ &&
|
|
3954
|
+
__DEV__ && invariant.error(10, resultKeyNameFromField(field), result);
|
|
3724
3955
|
}
|
|
3725
3956
|
});
|
|
3726
3957
|
try {
|
|
@@ -3824,7 +4055,7 @@ var StoreWriter = (function () {
|
|
|
3824
4055
|
else {
|
|
3825
4056
|
var fragment = getFragmentFromSelection(selection, context.lookupFragment);
|
|
3826
4057
|
if (!fragment && selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
|
|
3827
|
-
throw
|
|
4058
|
+
throw newInvariantError(11, selection.name.value);
|
|
3828
4059
|
}
|
|
3829
4060
|
if (fragment &&
|
|
3830
4061
|
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
@@ -3865,7 +4096,7 @@ var StoreWriter = (function () {
|
|
|
3865
4096
|
changedFields_1.set(storeFieldName, aVal);
|
|
3866
4097
|
}
|
|
3867
4098
|
if (getStorageArgs) {
|
|
3868
|
-
|
|
4099
|
+
invariant(getStorageArgs.pop() === storeFieldName);
|
|
3869
4100
|
}
|
|
3870
4101
|
});
|
|
3871
4102
|
if (changedFields_1) {
|
|
@@ -3937,7 +4168,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
3937
4168
|
return;
|
|
3938
4169
|
if (isReference(existing))
|
|
3939
4170
|
return;
|
|
3940
|
-
if (
|
|
4171
|
+
if (equal.equal(existing, incoming))
|
|
3941
4172
|
return;
|
|
3942
4173
|
if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
|
|
3943
4174
|
return;
|
|
@@ -3960,10 +4191,9 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
3960
4191
|
}
|
|
3961
4192
|
});
|
|
3962
4193
|
}
|
|
3963
|
-
__DEV__ &&
|
|
3964
|
-
? "either ensure all objects of type " +
|
|
3965
|
-
|
|
3966
|
-
: "", "define a custom merge function for the ").concat(typeDotName, " field, so InMemoryCache can safely merge these objects:\n\n existing: ").concat(JSON.stringify(existing).slice(0, 1000), "\n incoming: ").concat(JSON.stringify(incoming).slice(0, 1000), "\n\nFor more information about these options, please refer to the documentation:\n\n * Ensuring entity objects have IDs: https://go.apollo.dev/c/generating-unique-identifiers\n * Defining custom merge functions: https://go.apollo.dev/c/merging-non-normalized-objects\n"));
|
|
4194
|
+
__DEV__ && invariant.warn(12, fieldName, parentType, childTypenames.length
|
|
4195
|
+
? "either ensure all objects of type " + childTypenames.join(" and ") + " have an ID or a custom merge function, or "
|
|
4196
|
+
: "", typeDotName, existing, incoming);
|
|
3967
4197
|
}
|
|
3968
4198
|
|
|
3969
4199
|
var InMemoryCache = (function (_super) {
|
|
@@ -3972,7 +4202,8 @@ var InMemoryCache = (function (_super) {
|
|
|
3972
4202
|
if (config === void 0) { config = {}; }
|
|
3973
4203
|
var _this = _super.call(this) || this;
|
|
3974
4204
|
_this.watches = new Set();
|
|
3975
|
-
_this.
|
|
4205
|
+
_this.addTypenameTransform = new DocumentTransform(addTypenameToDocument);
|
|
4206
|
+
_this.assumeImmutableResults = true;
|
|
3976
4207
|
_this.makeVar = makeVar;
|
|
3977
4208
|
_this.txCount = 0;
|
|
3978
4209
|
_this.config = normalizeConfig(config);
|
|
@@ -4120,7 +4351,7 @@ var InMemoryCache = (function (_super) {
|
|
|
4120
4351
|
return this.policies.identify(object)[0];
|
|
4121
4352
|
}
|
|
4122
4353
|
catch (e) {
|
|
4123
|
-
__DEV__ &&
|
|
4354
|
+
__DEV__ && invariant.warn(e);
|
|
4124
4355
|
}
|
|
4125
4356
|
};
|
|
4126
4357
|
InMemoryCache.prototype.evict = function (options) {
|
|
@@ -4223,28 +4454,25 @@ var InMemoryCache = (function (_super) {
|
|
|
4223
4454
|
});
|
|
4224
4455
|
};
|
|
4225
4456
|
InMemoryCache.prototype.transformDocument = function (document) {
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
}
|
|
4233
|
-
return result;
|
|
4457
|
+
return this.addTypenameToDocument(this.addFragmentsToDocument(document));
|
|
4458
|
+
};
|
|
4459
|
+
InMemoryCache.prototype.broadcastWatches = function (options) {
|
|
4460
|
+
var _this = this;
|
|
4461
|
+
if (!this.txCount) {
|
|
4462
|
+
this.watches.forEach(function (c) { return _this.maybeBroadcastWatch(c, options); });
|
|
4234
4463
|
}
|
|
4235
|
-
return document;
|
|
4236
4464
|
};
|
|
4237
|
-
InMemoryCache.prototype.
|
|
4465
|
+
InMemoryCache.prototype.addFragmentsToDocument = function (document) {
|
|
4238
4466
|
var fragments = this.config.fragments;
|
|
4239
4467
|
return fragments
|
|
4240
4468
|
? fragments.transform(document)
|
|
4241
4469
|
: document;
|
|
4242
4470
|
};
|
|
4243
|
-
InMemoryCache.prototype.
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
this.watches.forEach(function (c) { return _this.maybeBroadcastWatch(c, options); });
|
|
4471
|
+
InMemoryCache.prototype.addTypenameToDocument = function (document) {
|
|
4472
|
+
if (this.addTypename) {
|
|
4473
|
+
return this.addTypenameTransform.transformDocument(document);
|
|
4247
4474
|
}
|
|
4475
|
+
return document;
|
|
4248
4476
|
};
|
|
4249
4477
|
InMemoryCache.prototype.broadcastWatch = function (c, options) {
|
|
4250
4478
|
var lastDiff = c.lastDiff;
|
|
@@ -4259,51 +4487,13 @@ var InMemoryCache = (function (_super) {
|
|
|
4259
4487
|
return;
|
|
4260
4488
|
}
|
|
4261
4489
|
}
|
|
4262
|
-
if (!lastDiff || !
|
|
4490
|
+
if (!lastDiff || !equal.equal(lastDiff.result, diff.result)) {
|
|
4263
4491
|
c.callback(c.lastDiff = diff, lastDiff);
|
|
4264
4492
|
}
|
|
4265
4493
|
};
|
|
4266
4494
|
return InMemoryCache;
|
|
4267
4495
|
}(ApolloCache));
|
|
4268
4496
|
|
|
4269
|
-
function isApolloError(err) {
|
|
4270
|
-
return err.hasOwnProperty('graphQLErrors');
|
|
4271
|
-
}
|
|
4272
|
-
var generateErrorMessage = function (err) {
|
|
4273
|
-
var message = '';
|
|
4274
|
-
if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {
|
|
4275
|
-
var errors = (err.graphQLErrors || [])
|
|
4276
|
-
.concat(err.clientErrors || []);
|
|
4277
|
-
errors.forEach(function (error) {
|
|
4278
|
-
var errorMessage = error
|
|
4279
|
-
? error.message
|
|
4280
|
-
: 'Error message not found.';
|
|
4281
|
-
message += "".concat(errorMessage, "\n");
|
|
4282
|
-
});
|
|
4283
|
-
}
|
|
4284
|
-
if (err.networkError) {
|
|
4285
|
-
message += "".concat(err.networkError.message, "\n");
|
|
4286
|
-
}
|
|
4287
|
-
message = message.replace(/\n$/, '');
|
|
4288
|
-
return message;
|
|
4289
|
-
};
|
|
4290
|
-
var ApolloError = (function (_super) {
|
|
4291
|
-
tslib.__extends(ApolloError, _super);
|
|
4292
|
-
function ApolloError(_a) {
|
|
4293
|
-
var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
4294
|
-
var _this = _super.call(this, errorMessage) || this;
|
|
4295
|
-
_this.name = 'ApolloError';
|
|
4296
|
-
_this.graphQLErrors = graphQLErrors || [];
|
|
4297
|
-
_this.clientErrors = clientErrors || [];
|
|
4298
|
-
_this.networkError = networkError || null;
|
|
4299
|
-
_this.message = errorMessage || generateErrorMessage(_this);
|
|
4300
|
-
_this.extraInfo = extraInfo;
|
|
4301
|
-
_this.__proto__ = ApolloError.prototype;
|
|
4302
|
-
return _this;
|
|
4303
|
-
}
|
|
4304
|
-
return ApolloError;
|
|
4305
|
-
}(Error));
|
|
4306
|
-
|
|
4307
4497
|
exports.NetworkStatus = void 0;
|
|
4308
4498
|
(function (NetworkStatus) {
|
|
4309
4499
|
NetworkStatus[NetworkStatus["loading"] = 1] = "loading";
|
|
@@ -4317,6 +4507,73 @@ exports.NetworkStatus = void 0;
|
|
|
4317
4507
|
function isNetworkRequestInFlight(networkStatus) {
|
|
4318
4508
|
return networkStatus ? networkStatus < 7 : false;
|
|
4319
4509
|
}
|
|
4510
|
+
function isNetworkRequestSettled(networkStatus) {
|
|
4511
|
+
return networkStatus === 7 || networkStatus === 8;
|
|
4512
|
+
}
|
|
4513
|
+
|
|
4514
|
+
function equalByQuery(query, _a, _b, variables) {
|
|
4515
|
+
var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
|
|
4516
|
+
var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
|
|
4517
|
+
return equal__default(aRest, bRest) && equalBySelectionSet(getMainDefinition(query).selectionSet, aData, bData, {
|
|
4518
|
+
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
4519
|
+
variables: variables,
|
|
4520
|
+
});
|
|
4521
|
+
}
|
|
4522
|
+
function equalBySelectionSet(selectionSet, aResult, bResult, context) {
|
|
4523
|
+
if (aResult === bResult) {
|
|
4524
|
+
return true;
|
|
4525
|
+
}
|
|
4526
|
+
var seenSelections = new Set();
|
|
4527
|
+
return selectionSet.selections.every(function (selection) {
|
|
4528
|
+
if (seenSelections.has(selection))
|
|
4529
|
+
return true;
|
|
4530
|
+
seenSelections.add(selection);
|
|
4531
|
+
if (!shouldInclude(selection, context.variables))
|
|
4532
|
+
return true;
|
|
4533
|
+
if (selectionHasNonreactiveDirective(selection))
|
|
4534
|
+
return true;
|
|
4535
|
+
if (isField(selection)) {
|
|
4536
|
+
var resultKey = resultKeyNameFromField(selection);
|
|
4537
|
+
var aResultChild = aResult && aResult[resultKey];
|
|
4538
|
+
var bResultChild = bResult && bResult[resultKey];
|
|
4539
|
+
var childSelectionSet = selection.selectionSet;
|
|
4540
|
+
if (!childSelectionSet) {
|
|
4541
|
+
return equal__default(aResultChild, bResultChild);
|
|
4542
|
+
}
|
|
4543
|
+
var aChildIsArray = Array.isArray(aResultChild);
|
|
4544
|
+
var bChildIsArray = Array.isArray(bResultChild);
|
|
4545
|
+
if (aChildIsArray !== bChildIsArray)
|
|
4546
|
+
return false;
|
|
4547
|
+
if (aChildIsArray && bChildIsArray) {
|
|
4548
|
+
var length_1 = aResultChild.length;
|
|
4549
|
+
if (bResultChild.length !== length_1) {
|
|
4550
|
+
return false;
|
|
4551
|
+
}
|
|
4552
|
+
for (var i = 0; i < length_1; ++i) {
|
|
4553
|
+
if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
|
|
4554
|
+
return false;
|
|
4555
|
+
}
|
|
4556
|
+
}
|
|
4557
|
+
return true;
|
|
4558
|
+
}
|
|
4559
|
+
return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
|
|
4560
|
+
}
|
|
4561
|
+
else {
|
|
4562
|
+
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
4563
|
+
if (fragment) {
|
|
4564
|
+
if (selectionHasNonreactiveDirective(fragment))
|
|
4565
|
+
return true;
|
|
4566
|
+
return equalBySelectionSet(fragment.selectionSet, aResult, bResult, context);
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4569
|
+
});
|
|
4570
|
+
}
|
|
4571
|
+
function selectionHasNonreactiveDirective(selection) {
|
|
4572
|
+
return !!selection.directives && selection.directives.some(directiveIsNonreactive);
|
|
4573
|
+
}
|
|
4574
|
+
function directiveIsNonreactive(dir) {
|
|
4575
|
+
return dir.name.value === "nonreactive";
|
|
4576
|
+
}
|
|
4320
4577
|
|
|
4321
4578
|
var assign = Object.assign, hasOwnProperty$2 = Object.hasOwnProperty;
|
|
4322
4579
|
var ObservableQuery = (function (_super) {
|
|
@@ -4324,14 +4581,13 @@ var ObservableQuery = (function (_super) {
|
|
|
4324
4581
|
function ObservableQuery(_a) {
|
|
4325
4582
|
var queryManager = _a.queryManager, queryInfo = _a.queryInfo, options = _a.options;
|
|
4326
4583
|
var _this = _super.call(this, function (observer) {
|
|
4327
|
-
var _a = options.fetchOnFirstSubscribe, fetchOnFirstSubscribe = _a === void 0 ? true : _a;
|
|
4328
4584
|
try {
|
|
4329
4585
|
var subObserver = observer._subscription._observer;
|
|
4330
4586
|
if (subObserver && !subObserver.error) {
|
|
4331
4587
|
subObserver.error = defaultSubscriptionObserverErrorCallback;
|
|
4332
4588
|
}
|
|
4333
4589
|
}
|
|
4334
|
-
catch (
|
|
4590
|
+
catch (_a) { }
|
|
4335
4591
|
var first = !_this.observers.size;
|
|
4336
4592
|
_this.observers.add(observer);
|
|
4337
4593
|
var last = _this.last;
|
|
@@ -4341,7 +4597,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4341
4597
|
else if (last && last.result) {
|
|
4342
4598
|
observer.next && observer.next(last.result);
|
|
4343
4599
|
}
|
|
4344
|
-
if (first
|
|
4600
|
+
if (first) {
|
|
4345
4601
|
_this.reobserve().catch(function () { });
|
|
4346
4602
|
}
|
|
4347
4603
|
return function () {
|
|
@@ -4365,7 +4621,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4365
4621
|
}
|
|
4366
4622
|
Object.defineProperty(ObservableQuery.prototype, "query", {
|
|
4367
4623
|
get: function () {
|
|
4368
|
-
return this.
|
|
4624
|
+
return this.lastQuery || this.options.query;
|
|
4369
4625
|
},
|
|
4370
4626
|
enumerable: false,
|
|
4371
4627
|
configurable: true
|
|
@@ -4407,13 +4663,13 @@ var ObservableQuery = (function (_super) {
|
|
|
4407
4663
|
if (fetchPolicy === 'network-only' ||
|
|
4408
4664
|
fetchPolicy === 'no-cache' ||
|
|
4409
4665
|
fetchPolicy === 'standby' ||
|
|
4410
|
-
this.queryManager.
|
|
4666
|
+
this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) ;
|
|
4411
4667
|
else {
|
|
4412
4668
|
var diff = this.queryInfo.getDiff();
|
|
4413
4669
|
if (diff.complete || this.options.returnPartialData) {
|
|
4414
4670
|
result.data = diff.result;
|
|
4415
4671
|
}
|
|
4416
|
-
if (
|
|
4672
|
+
if (equal.equal(result.data, {})) {
|
|
4417
4673
|
result.data = void 0;
|
|
4418
4674
|
}
|
|
4419
4675
|
if (diff.complete) {
|
|
@@ -4444,15 +4700,20 @@ var ObservableQuery = (function (_super) {
|
|
|
4444
4700
|
return result;
|
|
4445
4701
|
};
|
|
4446
4702
|
ObservableQuery.prototype.isDifferentFromLastResult = function (newResult, variables) {
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4703
|
+
if (!this.last) {
|
|
4704
|
+
return true;
|
|
4705
|
+
}
|
|
4706
|
+
var resultIsDifferent = this.queryManager.getDocumentInfo(this.query).hasNonreactiveDirective
|
|
4707
|
+
? !equalByQuery(this.query, this.last.result, newResult, this.variables)
|
|
4708
|
+
: !equal.equal(this.last.result, newResult);
|
|
4709
|
+
return (resultIsDifferent ||
|
|
4710
|
+
(variables && !equal.equal(this.last.variables, variables)));
|
|
4450
4711
|
};
|
|
4451
4712
|
ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
|
|
4452
4713
|
var last = this.last;
|
|
4453
4714
|
if (last &&
|
|
4454
4715
|
last[key] &&
|
|
4455
|
-
(!variablesMustMatch ||
|
|
4716
|
+
(!variablesMustMatch || equal.equal(last.variables, this.variables))) {
|
|
4456
4717
|
return last[key];
|
|
4457
4718
|
}
|
|
4458
4719
|
};
|
|
@@ -4488,10 +4749,14 @@ var ObservableQuery = (function (_super) {
|
|
|
4488
4749
|
var queryDef = getQueryDefinition(this.query);
|
|
4489
4750
|
var vars = queryDef.variableDefinitions;
|
|
4490
4751
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
4491
|
-
__DEV__ &&
|
|
4752
|
+
__DEV__ && invariant.warn(
|
|
4753
|
+
19,
|
|
4754
|
+
variables,
|
|
4755
|
+
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
4756
|
+
);
|
|
4492
4757
|
}
|
|
4493
4758
|
}
|
|
4494
|
-
if (variables && !
|
|
4759
|
+
if (variables && !equal.equal(this.options.variables, variables)) {
|
|
4495
4760
|
reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
|
|
4496
4761
|
}
|
|
4497
4762
|
this.queryInfo.resetLastWrite();
|
|
@@ -4499,8 +4764,12 @@ var ObservableQuery = (function (_super) {
|
|
|
4499
4764
|
};
|
|
4500
4765
|
ObservableQuery.prototype.fetchMore = function (fetchMoreOptions) {
|
|
4501
4766
|
var _this = this;
|
|
4502
|
-
var combinedOptions = tslib.__assign(tslib.__assign({}, (fetchMoreOptions.query ? fetchMoreOptions : tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, this.options), { query: this.query }), fetchMoreOptions), { variables: tslib.__assign(tslib.__assign({}, this.options.variables), fetchMoreOptions.variables) }))), { fetchPolicy: "no-cache" });
|
|
4767
|
+
var combinedOptions = tslib.__assign(tslib.__assign({}, (fetchMoreOptions.query ? fetchMoreOptions : tslib.__assign(tslib.__assign(tslib.__assign(tslib.__assign({}, this.options), { query: this.options.query }), fetchMoreOptions), { variables: tslib.__assign(tslib.__assign({}, this.options.variables), fetchMoreOptions.variables) }))), { fetchPolicy: "no-cache" });
|
|
4768
|
+
combinedOptions.query = this.transformDocument(combinedOptions.query);
|
|
4503
4769
|
var qid = this.queryManager.generateQueryId();
|
|
4770
|
+
this.lastQuery = fetchMoreOptions.query
|
|
4771
|
+
? this.transformDocument(this.options.query)
|
|
4772
|
+
: combinedOptions.query;
|
|
4504
4773
|
var queryInfo = this.queryInfo;
|
|
4505
4774
|
var originalNetworkStatus = queryInfo.networkStatus;
|
|
4506
4775
|
queryInfo.networkStatus = exports.NetworkStatus.fetchMore;
|
|
@@ -4572,7 +4841,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4572
4841
|
options.onError(err);
|
|
4573
4842
|
return;
|
|
4574
4843
|
}
|
|
4575
|
-
__DEV__ &&
|
|
4844
|
+
__DEV__ && invariant.error(20, err);
|
|
4576
4845
|
},
|
|
4577
4846
|
});
|
|
4578
4847
|
this.subscriptions.add(subscription);
|
|
@@ -4586,7 +4855,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4586
4855
|
return this.reobserve(newOptions);
|
|
4587
4856
|
};
|
|
4588
4857
|
ObservableQuery.prototype.setVariables = function (variables) {
|
|
4589
|
-
if (
|
|
4858
|
+
if (equal.equal(this.variables, variables)) {
|
|
4590
4859
|
return this.observers.size
|
|
4591
4860
|
? this.result()
|
|
4592
4861
|
: Promise.resolve();
|
|
@@ -4651,7 +4920,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4651
4920
|
};
|
|
4652
4921
|
ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
|
|
4653
4922
|
this.queryManager.setObservableQuery(this);
|
|
4654
|
-
return this.queryManager
|
|
4923
|
+
return this.queryManager['fetchConcastWithInfo'](this.queryId, options, newNetworkStatus);
|
|
4655
4924
|
};
|
|
4656
4925
|
ObservableQuery.prototype.updatePolling = function () {
|
|
4657
4926
|
var _this = this;
|
|
@@ -4670,7 +4939,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4670
4939
|
pollingInfo.interval === pollInterval) {
|
|
4671
4940
|
return;
|
|
4672
4941
|
}
|
|
4673
|
-
|
|
4942
|
+
invariant(pollInterval, 21);
|
|
4674
4943
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
4675
4944
|
info.interval = pollInterval;
|
|
4676
4945
|
var maybeFetch = function () {
|
|
@@ -4696,13 +4965,13 @@ var ObservableQuery = (function (_super) {
|
|
|
4696
4965
|
};
|
|
4697
4966
|
ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
|
|
4698
4967
|
if (variables === void 0) { variables = this.variables; }
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
if (!isNonEmptyArray(newResult.errors)) {
|
|
4703
|
-
delete this.last.error;
|
|
4968
|
+
var error = this.getLastError();
|
|
4969
|
+
if (error && this.last && !equal.equal(variables, this.last.variables)) {
|
|
4970
|
+
error = void 0;
|
|
4704
4971
|
}
|
|
4705
|
-
return this.last
|
|
4972
|
+
return this.last = tslib.__assign({ result: this.queryManager.assumeImmutableResults
|
|
4973
|
+
? newResult
|
|
4974
|
+
: cloneDeep(newResult), variables: variables }, (error ? { error: error } : null));
|
|
4706
4975
|
};
|
|
4707
4976
|
ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
|
|
4708
4977
|
var _this = this;
|
|
@@ -4716,11 +4985,13 @@ var ObservableQuery = (function (_super) {
|
|
|
4716
4985
|
var options = useDisposableConcast
|
|
4717
4986
|
? mergedOptions
|
|
4718
4987
|
: assign(this.options, mergedOptions);
|
|
4988
|
+
var query = this.transformDocument(options.query);
|
|
4989
|
+
this.lastQuery = query;
|
|
4719
4990
|
if (!useDisposableConcast) {
|
|
4720
4991
|
this.updatePolling();
|
|
4721
4992
|
if (newOptions &&
|
|
4722
4993
|
newOptions.variables &&
|
|
4723
|
-
!
|
|
4994
|
+
!equal.equal(newOptions.variables, oldVariables) &&
|
|
4724
4995
|
options.fetchPolicy !== "standby" &&
|
|
4725
4996
|
options.fetchPolicy === oldFetchPolicy) {
|
|
4726
4997
|
this.applyNextFetchPolicy("variables-changed", options);
|
|
@@ -4729,8 +5000,9 @@ var ObservableQuery = (function (_super) {
|
|
|
4729
5000
|
}
|
|
4730
5001
|
}
|
|
4731
5002
|
}
|
|
5003
|
+
var fetchOptions = query === options.query ? options : tslib.__assign(tslib.__assign({}, options), { query: query });
|
|
4732
5004
|
var variables = options.variables && tslib.__assign({}, options.variables);
|
|
4733
|
-
var
|
|
5005
|
+
var _a = this.fetch(fetchOptions, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
|
|
4734
5006
|
var observer = {
|
|
4735
5007
|
next: function (result) {
|
|
4736
5008
|
_this.reportResult(result, variables);
|
|
@@ -4739,7 +5011,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4739
5011
|
_this.reportError(error, variables);
|
|
4740
5012
|
},
|
|
4741
5013
|
};
|
|
4742
|
-
if (!useDisposableConcast) {
|
|
5014
|
+
if (!useDisposableConcast && (fromLink || !this.concast)) {
|
|
4743
5015
|
if (this.concast && this.observer) {
|
|
4744
5016
|
this.concast.removeObserver(this.observer);
|
|
4745
5017
|
}
|
|
@@ -4757,11 +5029,12 @@ var ObservableQuery = (function (_super) {
|
|
|
4757
5029
|
};
|
|
4758
5030
|
ObservableQuery.prototype.reportResult = function (result, variables) {
|
|
4759
5031
|
var lastError = this.getLastError();
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
5032
|
+
var isDifferent = this.isDifferentFromLastResult(result, variables);
|
|
5033
|
+
if (lastError || !result.partial || this.options.returnPartialData) {
|
|
5034
|
+
this.updateLastResult(result, variables);
|
|
5035
|
+
}
|
|
5036
|
+
if (lastError || isDifferent) {
|
|
5037
|
+
iterateObserversSafely(this.observers, "next", result);
|
|
4765
5038
|
}
|
|
4766
5039
|
};
|
|
4767
5040
|
ObservableQuery.prototype.reportError = function (error, variables) {
|
|
@@ -4787,6 +5060,9 @@ var ObservableQuery = (function (_super) {
|
|
|
4787
5060
|
this.observers.clear();
|
|
4788
5061
|
this.isTornDown = true;
|
|
4789
5062
|
};
|
|
5063
|
+
ObservableQuery.prototype.transformDocument = function (document) {
|
|
5064
|
+
return this.queryManager.transform(document);
|
|
5065
|
+
};
|
|
4790
5066
|
return ObservableQuery;
|
|
4791
5067
|
}(zenObservableTs.Observable));
|
|
4792
5068
|
fixObservableSubclass(ObservableQuery);
|
|
@@ -4808,11 +5084,11 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
4808
5084
|
return obsQuery.reobserve();
|
|
4809
5085
|
}
|
|
4810
5086
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
4811
|
-
__DEV__ &&
|
|
5087
|
+
__DEV__ && invariant.error(22, error.message, error.stack);
|
|
4812
5088
|
}
|
|
4813
5089
|
function logMissingFieldErrors(missing) {
|
|
4814
5090
|
if (__DEV__ && missing) {
|
|
4815
|
-
__DEV__ &&
|
|
5091
|
+
__DEV__ && invariant.debug(23, missing);
|
|
4816
5092
|
}
|
|
4817
5093
|
}
|
|
4818
5094
|
|
|
@@ -4875,12 +5151,8 @@ var LocalState = (function () {
|
|
|
4875
5151
|
}
|
|
4876
5152
|
return null;
|
|
4877
5153
|
};
|
|
4878
|
-
LocalState.prototype.serverQuery = function (document
|
|
4879
|
-
|
|
4880
|
-
var _a = options.removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
4881
|
-
return removeClientFields
|
|
4882
|
-
? removeClientSetsFromDocument(document)
|
|
4883
|
-
: document;
|
|
5154
|
+
LocalState.prototype.serverQuery = function (document) {
|
|
5155
|
+
return removeClientSetsFromDocument(document);
|
|
4884
5156
|
};
|
|
4885
5157
|
LocalState.prototype.prepareContext = function (context) {
|
|
4886
5158
|
var cache = this.cache;
|
|
@@ -4995,7 +5267,7 @@ var LocalState = (function () {
|
|
|
4995
5267
|
}
|
|
4996
5268
|
else {
|
|
4997
5269
|
fragment = fragmentMap[selection.name.value];
|
|
4998
|
-
|
|
5270
|
+
invariant(fragment, 17, selection.name.value);
|
|
4999
5271
|
}
|
|
5000
5272
|
if (fragment && fragment.typeCondition) {
|
|
5001
5273
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -5108,7 +5380,7 @@ var LocalState = (function () {
|
|
|
5108
5380
|
},
|
|
5109
5381
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
5110
5382
|
var fragment = fragmentMap[spread.name.value];
|
|
5111
|
-
|
|
5383
|
+
invariant(fragment, 18, spread.name.value);
|
|
5112
5384
|
var fragmentSelections = collectByDefinition(fragment);
|
|
5113
5385
|
if (fragmentSelections.size > 0) {
|
|
5114
5386
|
ancestors.forEach(function (node) {
|
|
@@ -5170,10 +5442,10 @@ var QueryInfo = (function () {
|
|
|
5170
5442
|
var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
|
|
5171
5443
|
if (this.variables &&
|
|
5172
5444
|
this.networkStatus !== exports.NetworkStatus.loading &&
|
|
5173
|
-
!
|
|
5445
|
+
!equal.equal(this.variables, query.variables)) {
|
|
5174
5446
|
networkStatus = exports.NetworkStatus.setVariables;
|
|
5175
5447
|
}
|
|
5176
|
-
if (!
|
|
5448
|
+
if (!equal.equal(query.variables, this.variables)) {
|
|
5177
5449
|
this.lastDiff = void 0;
|
|
5178
5450
|
}
|
|
5179
5451
|
Object.assign(this, {
|
|
@@ -5198,7 +5470,7 @@ var QueryInfo = (function () {
|
|
|
5198
5470
|
QueryInfo.prototype.getDiff = function (variables) {
|
|
5199
5471
|
if (variables === void 0) { variables = this.variables; }
|
|
5200
5472
|
var options = this.getDiffOptions(variables);
|
|
5201
|
-
if (this.lastDiff &&
|
|
5473
|
+
if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
|
|
5202
5474
|
return this.lastDiff.diff;
|
|
5203
5475
|
}
|
|
5204
5476
|
this.updateWatch(this.variables = variables);
|
|
@@ -5232,7 +5504,7 @@ var QueryInfo = (function () {
|
|
|
5232
5504
|
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
5233
5505
|
this.updateLastDiff(diff);
|
|
5234
5506
|
if (!this.dirty &&
|
|
5235
|
-
!
|
|
5507
|
+
!equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
5236
5508
|
this.dirty = true;
|
|
5237
5509
|
if (!this.notifyTimeout) {
|
|
5238
5510
|
this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
|
|
@@ -5307,7 +5579,7 @@ var QueryInfo = (function () {
|
|
|
5307
5579
|
}
|
|
5308
5580
|
var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
|
|
5309
5581
|
if (!this.lastWatch ||
|
|
5310
|
-
!
|
|
5582
|
+
!equal.equal(watchOptions, this.lastWatch)) {
|
|
5311
5583
|
this.cancel();
|
|
5312
5584
|
this.cancel = this.cache.watch(this.lastWatch = watchOptions);
|
|
5313
5585
|
}
|
|
@@ -5319,8 +5591,8 @@ var QueryInfo = (function () {
|
|
|
5319
5591
|
var lastWrite = this.lastWrite;
|
|
5320
5592
|
return !(lastWrite &&
|
|
5321
5593
|
lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
|
|
5322
|
-
|
|
5323
|
-
|
|
5594
|
+
equal.equal(variables, lastWrite.variables) &&
|
|
5595
|
+
equal.equal(result.data, lastWrite.result.data));
|
|
5324
5596
|
};
|
|
5325
5597
|
QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
|
|
5326
5598
|
var _this = this;
|
|
@@ -5412,7 +5684,8 @@ function shouldWriteResult(result, errorPolicy) {
|
|
|
5412
5684
|
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
5413
5685
|
var QueryManager = (function () {
|
|
5414
5686
|
function QueryManager(_a) {
|
|
5415
|
-
var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState,
|
|
5687
|
+
var cache = _a.cache, link = _a.link, defaultOptions = _a.defaultOptions, documentTransform = _a.documentTransform, _b = _a.queryDeduplication, queryDeduplication = _b === void 0 ? false : _b, onBroadcast = _a.onBroadcast, _c = _a.ssrMode, ssrMode = _c === void 0 ? false : _c, _d = _a.clientAwareness, clientAwareness = _d === void 0 ? {} : _d, localState = _a.localState, _e = _a.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? !!cache.assumeImmutableResults : _e;
|
|
5688
|
+
var _this = this;
|
|
5416
5689
|
this.clientAwareness = {};
|
|
5417
5690
|
this.queries = new Map();
|
|
5418
5691
|
this.fetchCancelFns = new Map();
|
|
@@ -5421,6 +5694,7 @@ var QueryManager = (function () {
|
|
|
5421
5694
|
this.requestIdCounter = 1;
|
|
5422
5695
|
this.mutationIdCounter = 1;
|
|
5423
5696
|
this.inFlightLinkObservables = new Map();
|
|
5697
|
+
var defaultDocumentTransform = new DocumentTransform(function (document) { return _this.cache.transformDocument(document); }, { cache: false });
|
|
5424
5698
|
this.cache = cache;
|
|
5425
5699
|
this.link = link;
|
|
5426
5700
|
this.defaultOptions = defaultOptions || Object.create(null);
|
|
@@ -5428,7 +5702,12 @@ var QueryManager = (function () {
|
|
|
5428
5702
|
this.clientAwareness = clientAwareness;
|
|
5429
5703
|
this.localState = localState || new LocalState({ cache: cache });
|
|
5430
5704
|
this.ssrMode = ssrMode;
|
|
5431
|
-
this.assumeImmutableResults =
|
|
5705
|
+
this.assumeImmutableResults = assumeImmutableResults;
|
|
5706
|
+
this.documentTransform = documentTransform
|
|
5707
|
+
? defaultDocumentTransform
|
|
5708
|
+
.concat(documentTransform)
|
|
5709
|
+
.concat(defaultDocumentTransform)
|
|
5710
|
+
: defaultDocumentTransform;
|
|
5432
5711
|
if ((this.onBroadcast = onBroadcast)) {
|
|
5433
5712
|
this.mutationStore = Object.create(null);
|
|
5434
5713
|
}
|
|
@@ -5438,7 +5717,7 @@ var QueryManager = (function () {
|
|
|
5438
5717
|
this.queries.forEach(function (_info, queryId) {
|
|
5439
5718
|
_this.stopQueryNoBroadcast(queryId);
|
|
5440
5719
|
});
|
|
5441
|
-
this.cancelPendingFetches(
|
|
5720
|
+
this.cancelPendingFetches(newInvariantError(24));
|
|
5442
5721
|
};
|
|
5443
5722
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
5444
5723
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -5448,23 +5727,22 @@ var QueryManager = (function () {
|
|
|
5448
5727
|
var _b, _c;
|
|
5449
5728
|
var mutation = _a.mutation, variables = _a.variables, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries, _d = _a.refetchQueries, refetchQueries = _d === void 0 ? [] : _d, _e = _a.awaitRefetchQueries, awaitRefetchQueries = _e === void 0 ? false : _e, updateWithProxyFn = _a.update, onQueryUpdated = _a.onQueryUpdated, _f = _a.fetchPolicy, fetchPolicy = _f === void 0 ? ((_b = this.defaultOptions.mutate) === null || _b === void 0 ? void 0 : _b.fetchPolicy) || "network-only" : _f, _g = _a.errorPolicy, errorPolicy = _g === void 0 ? ((_c = this.defaultOptions.mutate) === null || _c === void 0 ? void 0 : _c.errorPolicy) || "none" : _g, keepRootFields = _a.keepRootFields, context = _a.context;
|
|
5450
5729
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
5451
|
-
var mutationId,
|
|
5452
|
-
return tslib.__generator(this, function (
|
|
5453
|
-
switch (
|
|
5730
|
+
var mutationId, hasClientExports, mutationStoreValue, self;
|
|
5731
|
+
return tslib.__generator(this, function (_h) {
|
|
5732
|
+
switch (_h.label) {
|
|
5454
5733
|
case 0:
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
fetchPolicy === 'no-cache',
|
|
5458
|
-
fetchPolicy === 'no-cache', 16);
|
|
5734
|
+
invariant(mutation, 25);
|
|
5735
|
+
invariant(fetchPolicy === 'network-only' ||
|
|
5736
|
+
fetchPolicy === 'no-cache', 26);
|
|
5459
5737
|
mutationId = this.generateMutationId();
|
|
5460
|
-
|
|
5461
|
-
|
|
5738
|
+
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
5739
|
+
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
5462
5740
|
variables = this.getVariables(mutation, variables);
|
|
5463
5741
|
if (!hasClientExports) return [3, 2];
|
|
5464
5742
|
return [4, this.localState.addExportedVariables(mutation, variables, context)];
|
|
5465
5743
|
case 1:
|
|
5466
|
-
variables = (
|
|
5467
|
-
|
|
5744
|
+
variables = (_h.sent());
|
|
5745
|
+
_h.label = 2;
|
|
5468
5746
|
case 2:
|
|
5469
5747
|
mutationStoreValue = this.mutationStore &&
|
|
5470
5748
|
(this.mutationStore[mutationId] = {
|
|
@@ -5567,7 +5845,7 @@ var QueryManager = (function () {
|
|
|
5567
5845
|
if (isExecutionPatchIncrementalResult(result) && isNonEmptyArray(result.incremental)) {
|
|
5568
5846
|
var diff = cache.diff({
|
|
5569
5847
|
id: "ROOT_MUTATION",
|
|
5570
|
-
query: this.
|
|
5848
|
+
query: this.getDocumentInfo(mutation.document).asQuery,
|
|
5571
5849
|
variables: mutation.variables,
|
|
5572
5850
|
optimistic: false,
|
|
5573
5851
|
returnPartialData: true,
|
|
@@ -5638,7 +5916,7 @@ var QueryManager = (function () {
|
|
|
5638
5916
|
if (!skipCache) {
|
|
5639
5917
|
var diff = cache.diff({
|
|
5640
5918
|
id: "ROOT_MUTATION",
|
|
5641
|
-
query: _this.
|
|
5919
|
+
query: _this.getDocumentInfo(mutation.document).asQuery,
|
|
5642
5920
|
variables: mutation.variables,
|
|
5643
5921
|
optimistic: false,
|
|
5644
5922
|
returnPartialData: true,
|
|
@@ -5691,12 +5969,12 @@ var QueryManager = (function () {
|
|
|
5691
5969
|
_this.markMutationResult(tslib.__assign(tslib.__assign({}, mutation), { result: { data: data } }), cache);
|
|
5692
5970
|
}
|
|
5693
5971
|
catch (error) {
|
|
5694
|
-
__DEV__ &&
|
|
5972
|
+
__DEV__ && invariant.error(error);
|
|
5695
5973
|
}
|
|
5696
5974
|
}, mutation.mutationId);
|
|
5697
5975
|
};
|
|
5698
5976
|
QueryManager.prototype.fetchQuery = function (queryId, options, networkStatus) {
|
|
5699
|
-
return this.
|
|
5977
|
+
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast.promise;
|
|
5700
5978
|
};
|
|
5701
5979
|
QueryManager.prototype.getQueryStore = function () {
|
|
5702
5980
|
var store = Object.create(null);
|
|
@@ -5718,22 +5996,23 @@ var QueryManager = (function () {
|
|
|
5718
5996
|
}
|
|
5719
5997
|
};
|
|
5720
5998
|
QueryManager.prototype.transform = function (document) {
|
|
5999
|
+
return this.documentTransform.transformDocument(document);
|
|
6000
|
+
};
|
|
6001
|
+
QueryManager.prototype.getDocumentInfo = function (document) {
|
|
5721
6002
|
var transformCache = this.transformCache;
|
|
5722
|
-
var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
5723
6003
|
if (!transformCache.has(document)) {
|
|
5724
|
-
var
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
this.localState.
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
asQuery: tslib.__assign(tslib.__assign({}, transformed), { definitions: transformed.definitions.map(function (def) {
|
|
6004
|
+
var cacheEntry = {
|
|
6005
|
+
hasClientExports: hasClientExports(document),
|
|
6006
|
+
hasForcedResolvers: this.localState.shouldForceResolvers(document),
|
|
6007
|
+
hasNonreactiveDirective: hasDirectives(['nonreactive'], document),
|
|
6008
|
+
clientQuery: this.localState.clientQuery(document),
|
|
6009
|
+
serverQuery: removeDirectivesFromDocument([
|
|
6010
|
+
{ name: 'client', remove: true },
|
|
6011
|
+
{ name: 'connection' },
|
|
6012
|
+
{ name: 'nonreactive' },
|
|
6013
|
+
], document),
|
|
6014
|
+
defaultVars: getDefaultValues(getOperationDefinition(document)),
|
|
6015
|
+
asQuery: tslib.__assign(tslib.__assign({}, document), { definitions: document.definitions.map(function (def) {
|
|
5737
6016
|
if (def.kind === "OperationDefinition" &&
|
|
5738
6017
|
def.operation !== "query") {
|
|
5739
6018
|
return tslib.__assign(tslib.__assign({}, def), { operation: "query" });
|
|
@@ -5741,23 +6020,16 @@ var QueryManager = (function () {
|
|
|
5741
6020
|
return def;
|
|
5742
6021
|
}) })
|
|
5743
6022
|
};
|
|
5744
|
-
|
|
5745
|
-
if (doc && !transformCache.has(doc)) {
|
|
5746
|
-
transformCache.set(doc, cacheEntry_1);
|
|
5747
|
-
}
|
|
5748
|
-
};
|
|
5749
|
-
add(document);
|
|
5750
|
-
add(transformed);
|
|
5751
|
-
add(clientQuery);
|
|
5752
|
-
add(serverQuery);
|
|
6023
|
+
transformCache.set(document, cacheEntry);
|
|
5753
6024
|
}
|
|
5754
6025
|
return transformCache.get(document);
|
|
5755
6026
|
};
|
|
5756
6027
|
QueryManager.prototype.getVariables = function (document, variables) {
|
|
5757
|
-
return tslib.__assign(tslib.__assign({}, this.
|
|
6028
|
+
return tslib.__assign(tslib.__assign({}, this.getDocumentInfo(document).defaultVars), variables);
|
|
5758
6029
|
};
|
|
5759
6030
|
QueryManager.prototype.watchQuery = function (options) {
|
|
5760
|
-
|
|
6031
|
+
var query = this.transform(options.query);
|
|
6032
|
+
options = tslib.__assign(tslib.__assign({}, options), { variables: this.getVariables(query, options.variables) });
|
|
5761
6033
|
if (typeof options.notifyOnNetworkStatusChange === 'undefined') {
|
|
5762
6034
|
options.notifyOnNetworkStatusChange = false;
|
|
5763
6035
|
}
|
|
@@ -5767,9 +6039,10 @@ var QueryManager = (function () {
|
|
|
5767
6039
|
queryInfo: queryInfo,
|
|
5768
6040
|
options: options,
|
|
5769
6041
|
});
|
|
6042
|
+
observable['lastQuery'] = query;
|
|
5770
6043
|
this.queries.set(observable.queryId, queryInfo);
|
|
5771
6044
|
queryInfo.init({
|
|
5772
|
-
document:
|
|
6045
|
+
document: query,
|
|
5773
6046
|
observableQuery: observable,
|
|
5774
6047
|
variables: observable.variables,
|
|
5775
6048
|
});
|
|
@@ -5778,12 +6051,11 @@ var QueryManager = (function () {
|
|
|
5778
6051
|
QueryManager.prototype.query = function (options, queryId) {
|
|
5779
6052
|
var _this = this;
|
|
5780
6053
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
6054
|
+
invariant(options.query, 27);
|
|
6055
|
+
invariant(options.query.kind === 'Document', 28);
|
|
6056
|
+
invariant(!options.returnPartialData, 29);
|
|
6057
|
+
invariant(!options.pollInterval, 30);
|
|
6058
|
+
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
|
|
5787
6059
|
};
|
|
5788
6060
|
QueryManager.prototype.generateQueryId = function () {
|
|
5789
6061
|
return String(this.queryIdCounter++);
|
|
@@ -5807,7 +6079,7 @@ var QueryManager = (function () {
|
|
|
5807
6079
|
if (options === void 0) { options = {
|
|
5808
6080
|
discardWatches: true,
|
|
5809
6081
|
}; }
|
|
5810
|
-
this.cancelPendingFetches(
|
|
6082
|
+
this.cancelPendingFetches(newInvariantError(31));
|
|
5811
6083
|
this.queries.forEach(function (queryInfo) {
|
|
5812
6084
|
if (queryInfo.observableQuery) {
|
|
5813
6085
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -5833,7 +6105,7 @@ var QueryManager = (function () {
|
|
|
5833
6105
|
queryNamesAndDocs.set(desc, false);
|
|
5834
6106
|
}
|
|
5835
6107
|
else if (isDocumentNode(desc)) {
|
|
5836
|
-
queryNamesAndDocs.set(_this.transform(desc)
|
|
6108
|
+
queryNamesAndDocs.set(_this.transform(desc), false);
|
|
5837
6109
|
}
|
|
5838
6110
|
else if (isNonNullObject(desc) && desc.query) {
|
|
5839
6111
|
legacyQueryOptions.add(desc);
|
|
@@ -5875,7 +6147,7 @@ var QueryManager = (function () {
|
|
|
5875
6147
|
queryInfo: queryInfo,
|
|
5876
6148
|
options: tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "network-only" }),
|
|
5877
6149
|
});
|
|
5878
|
-
|
|
6150
|
+
invariant(oq.queryId === queryId);
|
|
5879
6151
|
queryInfo.setObservableQuery(oq);
|
|
5880
6152
|
queries.set(queryId, oq);
|
|
5881
6153
|
});
|
|
@@ -5883,7 +6155,7 @@ var QueryManager = (function () {
|
|
|
5883
6155
|
if (__DEV__ && queryNamesAndDocs.size) {
|
|
5884
6156
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
5885
6157
|
if (!included) {
|
|
5886
|
-
__DEV__ &&
|
|
6158
|
+
__DEV__ && invariant.warn(typeof nameOrDoc === "string" ? 32 : 33, nameOrDoc);
|
|
5887
6159
|
}
|
|
5888
6160
|
});
|
|
5889
6161
|
}
|
|
@@ -5912,7 +6184,7 @@ var QueryManager = (function () {
|
|
|
5912
6184
|
QueryManager.prototype.startGraphQLSubscription = function (_a) {
|
|
5913
6185
|
var _this = this;
|
|
5914
6186
|
var query = _a.query, fetchPolicy = _a.fetchPolicy, errorPolicy = _a.errorPolicy, variables = _a.variables, _b = _a.context, context = _b === void 0 ? {} : _b;
|
|
5915
|
-
query = this.transform(query)
|
|
6187
|
+
query = this.transform(query);
|
|
5916
6188
|
variables = this.getVariables(query, variables);
|
|
5917
6189
|
var makeObservable = function (variables) {
|
|
5918
6190
|
return _this.getObservableFromLink(query, context, variables).map(function (result) {
|
|
@@ -5927,15 +6199,22 @@ var QueryManager = (function () {
|
|
|
5927
6199
|
}
|
|
5928
6200
|
_this.broadcastQueries();
|
|
5929
6201
|
}
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
}
|
|
6202
|
+
var hasErrors = graphQLResultHasError(result);
|
|
6203
|
+
var hasProtocolErrors = graphQLResultHasProtocolErrors(result);
|
|
6204
|
+
if (hasErrors || hasProtocolErrors) {
|
|
6205
|
+
var errors = {};
|
|
6206
|
+
if (hasErrors) {
|
|
6207
|
+
errors.graphQLErrors = result.errors;
|
|
6208
|
+
}
|
|
6209
|
+
if (hasProtocolErrors) {
|
|
6210
|
+
errors.protocolErrors = result.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
6211
|
+
}
|
|
6212
|
+
throw new ApolloError(errors);
|
|
5934
6213
|
}
|
|
5935
6214
|
return result;
|
|
5936
6215
|
});
|
|
5937
6216
|
};
|
|
5938
|
-
if (this.
|
|
6217
|
+
if (this.getDocumentInfo(query).hasClientExports) {
|
|
5939
6218
|
var observablePromise_1 = this.localState.addExportedVariables(query, variables, context).then(makeObservable);
|
|
5940
6219
|
return new zenObservableTs.Observable(function (observer) {
|
|
5941
6220
|
var sub = null;
|
|
@@ -5973,9 +6252,9 @@ var QueryManager = (function () {
|
|
|
5973
6252
|
var _a;
|
|
5974
6253
|
if (deduplication === void 0) { deduplication = (_a = context === null || context === void 0 ? void 0 : context.queryDeduplication) !== null && _a !== void 0 ? _a : this.queryDeduplication; }
|
|
5975
6254
|
var observable;
|
|
5976
|
-
var
|
|
6255
|
+
var _b = this.getDocumentInfo(query), serverQuery = _b.serverQuery, clientQuery = _b.clientQuery;
|
|
5977
6256
|
if (serverQuery) {
|
|
5978
|
-
var
|
|
6257
|
+
var _c = this, inFlightLinkObservables_1 = _c.inFlightLinkObservables, link = _c.link;
|
|
5979
6258
|
var operation = {
|
|
5980
6259
|
query: serverQuery,
|
|
5981
6260
|
variables: variables,
|
|
@@ -6013,7 +6292,6 @@ var QueryManager = (function () {
|
|
|
6013
6292
|
]);
|
|
6014
6293
|
context = this.prepareContext(context);
|
|
6015
6294
|
}
|
|
6016
|
-
var clientQuery = this.transform(query).clientQuery;
|
|
6017
6295
|
if (clientQuery) {
|
|
6018
6296
|
observable = asyncMap(observable, function (result) {
|
|
6019
6297
|
return _this.localState.runResolvers({
|
|
@@ -6028,7 +6306,7 @@ var QueryManager = (function () {
|
|
|
6028
6306
|
};
|
|
6029
6307
|
QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
|
|
6030
6308
|
var requestId = queryInfo.lastRequestId = this.generateRequestId();
|
|
6031
|
-
var linkDocument = this.cache.transformForLink(
|
|
6309
|
+
var linkDocument = this.cache.transformForLink(options.query);
|
|
6032
6310
|
return asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
6033
6311
|
var graphQLErrors = getGraphQLErrorsFromResult(result);
|
|
6034
6312
|
var hasErrors = graphQLErrors.length > 0;
|
|
@@ -6061,10 +6339,10 @@ var QueryManager = (function () {
|
|
|
6061
6339
|
throw error;
|
|
6062
6340
|
});
|
|
6063
6341
|
};
|
|
6064
|
-
QueryManager.prototype.
|
|
6342
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
|
|
6065
6343
|
var _this = this;
|
|
6066
6344
|
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
6067
|
-
var query =
|
|
6345
|
+
var query = options.query;
|
|
6068
6346
|
var variables = this.getVariables(query, options.variables);
|
|
6069
6347
|
var queryInfo = this.getQuery(queryId);
|
|
6070
6348
|
var defaults = this.defaultOptions.watchQuery;
|
|
@@ -6080,24 +6358,36 @@ var QueryManager = (function () {
|
|
|
6080
6358
|
});
|
|
6081
6359
|
var fromVariables = function (variables) {
|
|
6082
6360
|
normalized.variables = variables;
|
|
6083
|
-
var
|
|
6361
|
+
var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
6084
6362
|
if (normalized.fetchPolicy !== "standby" &&
|
|
6085
|
-
|
|
6363
|
+
sourcesWithInfo.sources.length > 0 &&
|
|
6086
6364
|
queryInfo.observableQuery) {
|
|
6087
6365
|
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
6088
6366
|
}
|
|
6089
|
-
return
|
|
6367
|
+
return sourcesWithInfo;
|
|
6090
6368
|
};
|
|
6091
6369
|
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
6092
6370
|
this.fetchCancelFns.set(queryId, function (reason) {
|
|
6093
6371
|
cleanupCancelFn();
|
|
6094
6372
|
setTimeout(function () { return concast.cancel(reason); });
|
|
6095
6373
|
});
|
|
6096
|
-
var concast
|
|
6097
|
-
|
|
6098
|
-
|
|
6374
|
+
var concast, containsDataFromLink;
|
|
6375
|
+
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
6376
|
+
concast = new Concast(this.localState
|
|
6377
|
+
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
6378
|
+
.then(fromVariables).then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
6379
|
+
containsDataFromLink = true;
|
|
6380
|
+
}
|
|
6381
|
+
else {
|
|
6382
|
+
var sourcesWithInfo = fromVariables(normalized.variables);
|
|
6383
|
+
containsDataFromLink = sourcesWithInfo.fromLink;
|
|
6384
|
+
concast = new Concast(sourcesWithInfo.sources);
|
|
6385
|
+
}
|
|
6099
6386
|
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
6100
|
-
return
|
|
6387
|
+
return {
|
|
6388
|
+
concast: concast,
|
|
6389
|
+
fromLink: containsDataFromLink,
|
|
6390
|
+
};
|
|
6101
6391
|
};
|
|
6102
6392
|
QueryManager.prototype.refetchQueries = function (_a) {
|
|
6103
6393
|
var _this = this;
|
|
@@ -6172,7 +6462,7 @@ var QueryManager = (function () {
|
|
|
6172
6462
|
var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange;
|
|
6173
6463
|
var oldNetworkStatus = queryInfo.networkStatus;
|
|
6174
6464
|
queryInfo.init({
|
|
6175
|
-
document:
|
|
6465
|
+
document: query,
|
|
6176
6466
|
variables: variables,
|
|
6177
6467
|
networkStatus: networkStatus,
|
|
6178
6468
|
});
|
|
@@ -6182,11 +6472,11 @@ var QueryManager = (function () {
|
|
|
6182
6472
|
var data = diff.result;
|
|
6183
6473
|
if (__DEV__ &&
|
|
6184
6474
|
!returnPartialData &&
|
|
6185
|
-
!
|
|
6475
|
+
!equal.equal(data, {})) {
|
|
6186
6476
|
logMissingFieldErrors(diff.missing);
|
|
6187
6477
|
}
|
|
6188
6478
|
var fromData = function (data) { return zenObservableTs.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
|
|
6189
|
-
if (data && _this.
|
|
6479
|
+
if (data && _this.getDocumentInfo(query).hasForcedResolvers) {
|
|
6190
6480
|
return _this.localState.runResolvers({
|
|
6191
6481
|
document: query,
|
|
6192
6482
|
remoteResult: { data: data },
|
|
@@ -6207,6 +6497,7 @@ var QueryManager = (function () {
|
|
|
6207
6497
|
refetchWritePolicy !== "merge") ? 1
|
|
6208
6498
|
: 2;
|
|
6209
6499
|
var resultsFromLink = function () { return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
|
|
6500
|
+
query: query,
|
|
6210
6501
|
variables: variables,
|
|
6211
6502
|
context: context,
|
|
6212
6503
|
fetchPolicy: fetchPolicy,
|
|
@@ -6221,54 +6512,40 @@ var QueryManager = (function () {
|
|
|
6221
6512
|
case "cache-first": {
|
|
6222
6513
|
var diff = readCache();
|
|
6223
6514
|
if (diff.complete) {
|
|
6224
|
-
return [
|
|
6225
|
-
resultsFromCache(diff, queryInfo.markReady()),
|
|
6226
|
-
];
|
|
6515
|
+
return { fromLink: false, sources: [resultsFromCache(diff, queryInfo.markReady())] };
|
|
6227
6516
|
}
|
|
6228
6517
|
if (returnPartialData || shouldNotify) {
|
|
6229
|
-
return [
|
|
6230
|
-
resultsFromCache(diff),
|
|
6231
|
-
resultsFromLink(),
|
|
6232
|
-
];
|
|
6518
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
6233
6519
|
}
|
|
6234
|
-
return [
|
|
6235
|
-
resultsFromLink(),
|
|
6236
|
-
];
|
|
6520
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6237
6521
|
}
|
|
6238
6522
|
case "cache-and-network": {
|
|
6239
6523
|
var diff = readCache();
|
|
6240
6524
|
if (diff.complete || returnPartialData || shouldNotify) {
|
|
6241
|
-
return [
|
|
6242
|
-
resultsFromCache(diff),
|
|
6243
|
-
resultsFromLink(),
|
|
6244
|
-
];
|
|
6525
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
6245
6526
|
}
|
|
6246
|
-
return [
|
|
6247
|
-
resultsFromLink(),
|
|
6248
|
-
];
|
|
6527
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6249
6528
|
}
|
|
6250
6529
|
case "cache-only":
|
|
6251
|
-
return [
|
|
6252
|
-
resultsFromCache(readCache(), queryInfo.markReady()),
|
|
6253
|
-
];
|
|
6530
|
+
return { fromLink: false, sources: [resultsFromCache(readCache(), queryInfo.markReady())] };
|
|
6254
6531
|
case "network-only":
|
|
6255
6532
|
if (shouldNotify) {
|
|
6256
|
-
return [
|
|
6257
|
-
resultsFromCache(readCache()),
|
|
6258
|
-
resultsFromLink(),
|
|
6259
|
-
];
|
|
6533
|
+
return { fromLink: true, sources: [resultsFromCache(readCache()), resultsFromLink()] };
|
|
6260
6534
|
}
|
|
6261
|
-
return [resultsFromLink()];
|
|
6535
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6262
6536
|
case "no-cache":
|
|
6263
6537
|
if (shouldNotify) {
|
|
6264
|
-
return
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6538
|
+
return {
|
|
6539
|
+
fromLink: true,
|
|
6540
|
+
sources: [
|
|
6541
|
+
resultsFromCache(queryInfo.getDiff()),
|
|
6542
|
+
resultsFromLink(),
|
|
6543
|
+
],
|
|
6544
|
+
};
|
|
6268
6545
|
}
|
|
6269
|
-
return [resultsFromLink()];
|
|
6546
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6270
6547
|
case "standby":
|
|
6271
|
-
return [];
|
|
6548
|
+
return { fromLink: false, sources: [] };
|
|
6272
6549
|
}
|
|
6273
6550
|
};
|
|
6274
6551
|
QueryManager.prototype.getQuery = function (queryId) {
|
|
@@ -6291,20 +6568,18 @@ var ApolloClient = (function () {
|
|
|
6291
6568
|
var _this = this;
|
|
6292
6569
|
this.resetStoreCallbacks = [];
|
|
6293
6570
|
this.clearStoreCallbacks = [];
|
|
6294
|
-
|
|
6571
|
+
if (!options.cache) {
|
|
6572
|
+
throw newInvariantError(13);
|
|
6573
|
+
}
|
|
6574
|
+
var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b, _c = options.connectToDevTools, connectToDevTools = _c === void 0 ? typeof window === 'object' &&
|
|
6295
6575
|
!window.__APOLLO_CLIENT__ &&
|
|
6296
|
-
__DEV__ : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ?
|
|
6576
|
+
__DEV__ : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? cache.assumeImmutableResults : _e, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version;
|
|
6297
6577
|
var link = options.link;
|
|
6298
6578
|
if (!link) {
|
|
6299
6579
|
link = uri
|
|
6300
6580
|
? new HttpLink({ uri: uri, credentials: credentials, headers: headers })
|
|
6301
6581
|
: ApolloLink.empty();
|
|
6302
6582
|
}
|
|
6303
|
-
if (!cache) {
|
|
6304
|
-
throw __DEV__ ? new tsInvariant.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
|
|
6305
|
-
"in the options object. \n" +
|
|
6306
|
-
"For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(9);
|
|
6307
|
-
}
|
|
6308
6583
|
this.link = link;
|
|
6309
6584
|
this.cache = cache;
|
|
6310
6585
|
this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0;
|
|
@@ -6341,8 +6616,7 @@ var ApolloClient = (function () {
|
|
|
6341
6616
|
}
|
|
6342
6617
|
}
|
|
6343
6618
|
if (url) {
|
|
6344
|
-
__DEV__ &&
|
|
6345
|
-
"experience: " + url);
|
|
6619
|
+
__DEV__ && invariant.log(14, url);
|
|
6346
6620
|
}
|
|
6347
6621
|
}
|
|
6348
6622
|
}
|
|
@@ -6357,6 +6631,7 @@ var ApolloClient = (function () {
|
|
|
6357
6631
|
cache: this.cache,
|
|
6358
6632
|
link: this.link,
|
|
6359
6633
|
defaultOptions: this.defaultOptions,
|
|
6634
|
+
documentTransform: documentTransform,
|
|
6360
6635
|
queryDeduplication: queryDeduplication,
|
|
6361
6636
|
ssrMode: ssrMode,
|
|
6362
6637
|
clientAwareness: {
|
|
@@ -6379,6 +6654,13 @@ var ApolloClient = (function () {
|
|
|
6379
6654
|
} : void 0,
|
|
6380
6655
|
});
|
|
6381
6656
|
}
|
|
6657
|
+
Object.defineProperty(ApolloClient.prototype, "documentTransform", {
|
|
6658
|
+
get: function () {
|
|
6659
|
+
return this.queryManager.documentTransform;
|
|
6660
|
+
},
|
|
6661
|
+
enumerable: false,
|
|
6662
|
+
configurable: true
|
|
6663
|
+
});
|
|
6382
6664
|
ApolloClient.prototype.stop = function () {
|
|
6383
6665
|
this.queryManager.stop();
|
|
6384
6666
|
};
|
|
@@ -6397,10 +6679,7 @@ var ApolloClient = (function () {
|
|
|
6397
6679
|
if (this.defaultOptions.query) {
|
|
6398
6680
|
options = mergeOptions(this.defaultOptions.query, options);
|
|
6399
6681
|
}
|
|
6400
|
-
|
|
6401
|
-
'client.query can only return a single result. Please use client.watchQuery ' +
|
|
6402
|
-
'to receive multiple results from the cache and the network, or consider ' +
|
|
6403
|
-
'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 10);
|
|
6682
|
+
invariant(options.fetchPolicy !== 'cache-and-network', 15);
|
|
6404
6683
|
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
|
|
6405
6684
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
|
|
6406
6685
|
}
|
|
@@ -6489,7 +6768,7 @@ var ApolloClient = (function () {
|
|
|
6489
6768
|
result.queries = queries;
|
|
6490
6769
|
result.results = results;
|
|
6491
6770
|
result.catch(function (error) {
|
|
6492
|
-
__DEV__ &&
|
|
6771
|
+
__DEV__ && invariant.debug(16, error);
|
|
6493
6772
|
});
|
|
6494
6773
|
return result;
|
|
6495
6774
|
};
|
|
@@ -6525,24 +6804,25 @@ var contextKey = canUseSymbol
|
|
|
6525
6804
|
? Symbol.for('__APOLLO_CONTEXT__')
|
|
6526
6805
|
: '__APOLLO_CONTEXT__';
|
|
6527
6806
|
function getApolloContext() {
|
|
6528
|
-
|
|
6807
|
+
invariant('createContext' in React__namespace, 44);
|
|
6808
|
+
var contextStorage = global$1[contextKey];
|
|
6809
|
+
if (!contextStorage) {
|
|
6810
|
+
contextStorage = global$1[contextKey] = new Map();
|
|
6811
|
+
}
|
|
6812
|
+
var context = contextStorage.get(React__namespace);
|
|
6529
6813
|
if (!context) {
|
|
6530
|
-
|
|
6531
|
-
value: context = React__namespace.createContext({}),
|
|
6532
|
-
enumerable: false,
|
|
6533
|
-
writable: false,
|
|
6534
|
-
configurable: true,
|
|
6535
|
-
});
|
|
6814
|
+
context = React__namespace.createContext({});
|
|
6536
6815
|
context.displayName = 'ApolloContext';
|
|
6816
|
+
contextStorage.set(React__namespace, context);
|
|
6537
6817
|
}
|
|
6538
6818
|
return context;
|
|
6539
6819
|
}
|
|
6820
|
+
var resetApolloContext = getApolloContext;
|
|
6540
6821
|
|
|
6541
6822
|
var ApolloConsumer = function (props) {
|
|
6542
6823
|
var ApolloContext = getApolloContext();
|
|
6543
6824
|
return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
6544
|
-
|
|
6545
|
-
'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client, 28);
|
|
6825
|
+
invariant(context && context.client, 43);
|
|
6546
6826
|
return props.children(context.client);
|
|
6547
6827
|
}));
|
|
6548
6828
|
};
|
|
@@ -6550,39 +6830,31 @@ var ApolloConsumer = function (props) {
|
|
|
6550
6830
|
var ApolloProvider = function (_a) {
|
|
6551
6831
|
var client = _a.client, suspenseCache = _a.suspenseCache, children = _a.children;
|
|
6552
6832
|
var ApolloContext = getApolloContext();
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6558
|
-
|
|
6559
|
-
context = Object.assign({}, context, { suspenseCache: suspenseCache });
|
|
6560
|
-
}
|
|
6561
|
-
__DEV__ ? tsInvariant.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
|
|
6562
|
-
'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client, 29);
|
|
6563
|
-
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
6564
|
-
}));
|
|
6833
|
+
var parentContext = React__namespace.useContext(ApolloContext);
|
|
6834
|
+
var context = React__namespace.useMemo(function () {
|
|
6835
|
+
return tslib.__assign(tslib.__assign({}, parentContext), { client: client || parentContext.client, suspenseCache: suspenseCache || parentContext.suspenseCache });
|
|
6836
|
+
}, [parentContext, client, suspenseCache]);
|
|
6837
|
+
invariant(context.client, 45);
|
|
6838
|
+
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
6565
6839
|
};
|
|
6566
6840
|
|
|
6567
6841
|
function useApolloClient(override) {
|
|
6568
6842
|
var context = React.useContext(getApolloContext());
|
|
6569
6843
|
var client = override || context.client;
|
|
6570
|
-
|
|
6571
|
-
'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
|
|
6572
|
-
'instance in via options.') : tsInvariant.invariant(!!client, 32);
|
|
6844
|
+
invariant(!!client, 48);
|
|
6573
6845
|
return client;
|
|
6574
6846
|
}
|
|
6575
6847
|
|
|
6576
6848
|
var didWarnUncachedGetSnapshot = false;
|
|
6577
6849
|
var uSESKey = "useSyncExternalStore";
|
|
6578
|
-
var realHook = React__namespace[uSESKey];
|
|
6579
|
-
var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
6850
|
+
var realHook$1 = React__namespace[uSESKey];
|
|
6851
|
+
var useSyncExternalStore = realHook$1 || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
6580
6852
|
var value = getSnapshot();
|
|
6581
6853
|
if (__DEV__ &&
|
|
6582
6854
|
!didWarnUncachedGetSnapshot &&
|
|
6583
6855
|
value !== getSnapshot()) {
|
|
6584
6856
|
didWarnUncachedGetSnapshot = true;
|
|
6585
|
-
__DEV__ &&
|
|
6857
|
+
__DEV__ && invariant.error(58);
|
|
6586
6858
|
}
|
|
6587
6859
|
var _a = React__namespace.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
|
|
6588
6860
|
if (canUseLayoutEffect) {
|
|
@@ -6645,9 +6917,7 @@ function parser(document) {
|
|
|
6645
6917
|
if (cached)
|
|
6646
6918
|
return cached;
|
|
6647
6919
|
var variables, type, name;
|
|
6648
|
-
|
|
6649
|
-
"DocumentNode. You may need to use 'graphql-tag' or another method " +
|
|
6650
|
-
"to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 35);
|
|
6920
|
+
invariant(!!document && !!document.kind, 59, document);
|
|
6651
6921
|
var fragments = [];
|
|
6652
6922
|
var queries = [];
|
|
6653
6923
|
var mutations = [];
|
|
@@ -6672,14 +6942,16 @@ function parser(document) {
|
|
|
6672
6942
|
}
|
|
6673
6943
|
}
|
|
6674
6944
|
}
|
|
6675
|
-
|
|
6676
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
|
|
6681
|
-
|
|
6682
|
-
|
|
6945
|
+
invariant(!fragments.length ||
|
|
6946
|
+
(queries.length || mutations.length || subscriptions.length), 60);
|
|
6947
|
+
invariant(
|
|
6948
|
+
queries.length + mutations.length + subscriptions.length <= 1,
|
|
6949
|
+
61,
|
|
6950
|
+
document,
|
|
6951
|
+
queries.length,
|
|
6952
|
+
subscriptions.length,
|
|
6953
|
+
mutations.length
|
|
6954
|
+
);
|
|
6683
6955
|
type = queries.length ? exports.DocumentType.Query : exports.DocumentType.Mutation;
|
|
6684
6956
|
if (!queries.length && !mutations.length)
|
|
6685
6957
|
type = exports.DocumentType.Subscription;
|
|
@@ -6688,9 +6960,7 @@ function parser(document) {
|
|
|
6688
6960
|
: mutations.length
|
|
6689
6961
|
? mutations
|
|
6690
6962
|
: subscriptions;
|
|
6691
|
-
|
|
6692
|
-
"".concat(definitions.length, " definitions. ") +
|
|
6693
|
-
"You can use 'compose' to join multiple operation types to a component") : tsInvariant.invariant(definitions.length === 1, 38);
|
|
6963
|
+
invariant(definitions.length === 1, 62, document, definitions.length);
|
|
6694
6964
|
var definition = definitions[0];
|
|
6695
6965
|
variables = definition.variableDefinitions || [];
|
|
6696
6966
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -6707,8 +6977,13 @@ function verifyDocumentType(document, type) {
|
|
|
6707
6977
|
var operation = parser(document);
|
|
6708
6978
|
var requiredOperationName = operationName(type);
|
|
6709
6979
|
var usedOperationName = operationName(operation.type);
|
|
6710
|
-
|
|
6711
|
-
|
|
6980
|
+
invariant(
|
|
6981
|
+
operation.type === type,
|
|
6982
|
+
63,
|
|
6983
|
+
requiredOperationName,
|
|
6984
|
+
requiredOperationName,
|
|
6985
|
+
usedOperationName
|
|
6986
|
+
);
|
|
6712
6987
|
}
|
|
6713
6988
|
|
|
6714
6989
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
@@ -6734,8 +7009,6 @@ var InternalState = (function () {
|
|
|
6734
7009
|
function InternalState(client, query, previous) {
|
|
6735
7010
|
this.client = client;
|
|
6736
7011
|
this.query = query;
|
|
6737
|
-
this.asyncResolveFns = new Set();
|
|
6738
|
-
this.optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)();
|
|
6739
7012
|
this.ssrDisabledResult = maybeDeepFreeze({
|
|
6740
7013
|
loading: true,
|
|
6741
7014
|
data: void 0,
|
|
@@ -6757,22 +7030,32 @@ var InternalState = (function () {
|
|
|
6757
7030
|
}
|
|
6758
7031
|
}
|
|
6759
7032
|
InternalState.prototype.forceUpdate = function () {
|
|
6760
|
-
__DEV__ &&
|
|
7033
|
+
__DEV__ && invariant.warn(50);
|
|
6761
7034
|
};
|
|
6762
|
-
InternalState.prototype.
|
|
7035
|
+
InternalState.prototype.executeQuery = function (options) {
|
|
6763
7036
|
var _this = this;
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
7037
|
+
var _a;
|
|
7038
|
+
if (options.query) {
|
|
7039
|
+
Object.assign(this, { query: options.query });
|
|
7040
|
+
}
|
|
7041
|
+
this.watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
7042
|
+
var concast = this.observable.reobserveAsConcast(this.getObsQueryOptions());
|
|
7043
|
+
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
7044
|
+
this.result = void 0;
|
|
7045
|
+
this.forceUpdate();
|
|
7046
|
+
return new Promise(function (resolve) {
|
|
7047
|
+
var result;
|
|
7048
|
+
concast.subscribe({
|
|
7049
|
+
next: function (value) {
|
|
7050
|
+
result = value;
|
|
7051
|
+
},
|
|
7052
|
+
error: function () {
|
|
7053
|
+
resolve(_this.toQueryResult(_this.observable.getCurrentResult()));
|
|
7054
|
+
},
|
|
7055
|
+
complete: function () {
|
|
7056
|
+
resolve(_this.toQueryResult(result));
|
|
7057
|
+
}
|
|
7058
|
+
});
|
|
6776
7059
|
});
|
|
6777
7060
|
};
|
|
6778
7061
|
InternalState.prototype.useQuery = function (options) {
|
|
@@ -6790,7 +7073,7 @@ var InternalState = (function () {
|
|
|
6790
7073
|
if (previousResult &&
|
|
6791
7074
|
previousResult.loading === result.loading &&
|
|
6792
7075
|
previousResult.networkStatus === result.networkStatus &&
|
|
6793
|
-
|
|
7076
|
+
equal.equal(previousResult.data, result.data)) {
|
|
6794
7077
|
return;
|
|
6795
7078
|
}
|
|
6796
7079
|
_this.setResult(result);
|
|
@@ -6811,7 +7094,7 @@ var InternalState = (function () {
|
|
|
6811
7094
|
var previousResult = _this.result;
|
|
6812
7095
|
if (!previousResult ||
|
|
6813
7096
|
(previousResult && previousResult.loading) ||
|
|
6814
|
-
!
|
|
7097
|
+
!equal.equal(error, previousResult.error)) {
|
|
6815
7098
|
_this.setResult({
|
|
6816
7099
|
data: (previousResult && previousResult.data),
|
|
6817
7100
|
error: error,
|
|
@@ -6828,22 +7111,15 @@ var InternalState = (function () {
|
|
|
6828
7111
|
this.client.disableNetworkFetches,
|
|
6829
7112
|
]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
|
|
6830
7113
|
this.unsafeHandlePartialRefetch(result);
|
|
6831
|
-
|
|
6832
|
-
if (!queryResult.loading && this.asyncResolveFns.size) {
|
|
6833
|
-
this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
|
|
6834
|
-
this.asyncResolveFns.clear();
|
|
6835
|
-
}
|
|
6836
|
-
return queryResult;
|
|
7114
|
+
return this.toQueryResult(result);
|
|
6837
7115
|
};
|
|
6838
7116
|
InternalState.prototype.useOptions = function (options) {
|
|
6839
7117
|
var _a;
|
|
6840
7118
|
var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
6841
7119
|
var currentWatchQueryOptions = this.watchQueryOptions;
|
|
6842
|
-
if (
|
|
6843
|
-
!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
7120
|
+
if (!equal.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
6844
7121
|
this.watchQueryOptions = watchQueryOptions;
|
|
6845
7122
|
if (currentWatchQueryOptions && this.observable) {
|
|
6846
|
-
this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
|
|
6847
7123
|
this.observable.reobserve(this.getObsQueryOptions());
|
|
6848
7124
|
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6849
7125
|
this.result = void 0;
|
|
@@ -6959,7 +7235,7 @@ var InternalState = (function () {
|
|
|
6959
7235
|
_this.onCompleted(result.data);
|
|
6960
7236
|
}
|
|
6961
7237
|
}).catch(function (error) {
|
|
6962
|
-
__DEV__ &&
|
|
7238
|
+
__DEV__ && invariant.warn(error);
|
|
6963
7239
|
});
|
|
6964
7240
|
}
|
|
6965
7241
|
};
|
|
@@ -7010,11 +7286,15 @@ var EAGER_METHODS = [
|
|
|
7010
7286
|
'subscribeToMore',
|
|
7011
7287
|
];
|
|
7012
7288
|
function useLazyQuery(query, options) {
|
|
7013
|
-
var _a
|
|
7014
|
-
var abortControllersRef = React.useRef(new Set());
|
|
7289
|
+
var _a;
|
|
7015
7290
|
var execOptionsRef = React.useRef();
|
|
7016
|
-
var
|
|
7017
|
-
var
|
|
7291
|
+
var optionsRef = React.useRef();
|
|
7292
|
+
var queryRef = React.useRef();
|
|
7293
|
+
var merged = mergeOptions(options, execOptionsRef.current || {});
|
|
7294
|
+
var document = (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query;
|
|
7295
|
+
optionsRef.current = merged;
|
|
7296
|
+
queryRef.current = document;
|
|
7297
|
+
var internalState = useInternalState(useApolloClient(options && options.client), document);
|
|
7018
7298
|
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
7019
7299
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
7020
7300
|
internalState.getDefaultFetchPolicy();
|
|
@@ -7040,28 +7320,15 @@ function useLazyQuery(query, options) {
|
|
|
7040
7320
|
return eagerMethods;
|
|
7041
7321
|
}, []);
|
|
7042
7322
|
Object.assign(result, eagerMethods);
|
|
7043
|
-
React.useEffect(function () {
|
|
7044
|
-
return function () {
|
|
7045
|
-
abortControllersRef.current.forEach(function (controller) {
|
|
7046
|
-
controller.abort();
|
|
7047
|
-
});
|
|
7048
|
-
};
|
|
7049
|
-
}, []);
|
|
7050
7323
|
var execute = React.useCallback(function (executeOptions) {
|
|
7051
|
-
var controller = new AbortController();
|
|
7052
|
-
abortControllersRef.current.add(controller);
|
|
7053
7324
|
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
7054
7325
|
fetchPolicy: initialFetchPolicy,
|
|
7055
7326
|
};
|
|
7327
|
+
var options = mergeOptions(optionsRef.current, tslib.__assign({ query: queryRef.current }, execOptionsRef.current));
|
|
7056
7328
|
var promise = internalState
|
|
7057
|
-
.
|
|
7058
|
-
.then(function (queryResult) {
|
|
7059
|
-
|
|
7060
|
-
return Object.assign(queryResult, eagerMethods);
|
|
7061
|
-
});
|
|
7062
|
-
promise.catch(function () {
|
|
7063
|
-
abortControllersRef.current.delete(controller);
|
|
7064
|
-
});
|
|
7329
|
+
.executeQuery(tslib.__assign(tslib.__assign({}, options), { skip: false }))
|
|
7330
|
+
.then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
7331
|
+
promise.catch(function () { });
|
|
7065
7332
|
return promise;
|
|
7066
7333
|
}, []);
|
|
7067
7334
|
return [execute, result];
|
|
@@ -7117,7 +7384,7 @@ function useMutation(mutation, options) {
|
|
|
7117
7384
|
error: error,
|
|
7118
7385
|
client: client,
|
|
7119
7386
|
};
|
|
7120
|
-
if (ref.current.isMounted && !
|
|
7387
|
+
if (ref.current.isMounted && !equal.equal(ref.current.result, result_1)) {
|
|
7121
7388
|
setResult(ref.current.result = result_1);
|
|
7122
7389
|
}
|
|
7123
7390
|
}
|
|
@@ -7135,7 +7402,7 @@ function useMutation(mutation, options) {
|
|
|
7135
7402
|
called: true,
|
|
7136
7403
|
client: client,
|
|
7137
7404
|
};
|
|
7138
|
-
if (!
|
|
7405
|
+
if (!equal.equal(ref.current.result, result_2)) {
|
|
7139
7406
|
setResult(ref.current.result = result_2);
|
|
7140
7407
|
}
|
|
7141
7408
|
}
|
|
@@ -7174,14 +7441,10 @@ function useSubscription(subscription, options) {
|
|
|
7174
7441
|
if (!hasIssuedDeprecationWarningRef.current) {
|
|
7175
7442
|
hasIssuedDeprecationWarningRef.current = true;
|
|
7176
7443
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionData) {
|
|
7177
|
-
__DEV__ &&
|
|
7178
|
-
? "'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used."
|
|
7179
|
-
: "'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead.");
|
|
7444
|
+
__DEV__ && invariant.warn(options.onData ? 51 : 52);
|
|
7180
7445
|
}
|
|
7181
7446
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionComplete) {
|
|
7182
|
-
__DEV__ &&
|
|
7183
|
-
? "'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used."
|
|
7184
|
-
: "'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead.");
|
|
7447
|
+
__DEV__ && invariant.warn(options.onComplete ? 53 : 54);
|
|
7185
7448
|
}
|
|
7186
7449
|
}
|
|
7187
7450
|
var _b = React.useState(function () {
|
|
@@ -7225,7 +7488,7 @@ function useSubscription(subscription, options) {
|
|
|
7225
7488
|
subscription !== ref.current.subscription ||
|
|
7226
7489
|
(options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
|
|
7227
7490
|
!(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
|
|
7228
|
-
!
|
|
7491
|
+
!equal.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) ||
|
|
7229
7492
|
canResetObservableRef.current) {
|
|
7230
7493
|
setResult({
|
|
7231
7494
|
loading: true,
|
|
@@ -7247,9 +7510,13 @@ function useSubscription(subscription, options) {
|
|
|
7247
7510
|
if (!observable) {
|
|
7248
7511
|
return;
|
|
7249
7512
|
}
|
|
7513
|
+
var subscriptionStopped = false;
|
|
7250
7514
|
var subscription = observable.subscribe({
|
|
7251
7515
|
next: function (fetchResult) {
|
|
7252
7516
|
var _a, _b;
|
|
7517
|
+
if (subscriptionStopped) {
|
|
7518
|
+
return;
|
|
7519
|
+
}
|
|
7253
7520
|
var result = {
|
|
7254
7521
|
loading: false,
|
|
7255
7522
|
data: fetchResult.data,
|
|
@@ -7272,26 +7539,33 @@ function useSubscription(subscription, options) {
|
|
|
7272
7539
|
},
|
|
7273
7540
|
error: function (error) {
|
|
7274
7541
|
var _a, _b;
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7542
|
+
if (!subscriptionStopped) {
|
|
7543
|
+
setResult({
|
|
7544
|
+
loading: false,
|
|
7545
|
+
data: void 0,
|
|
7546
|
+
error: error,
|
|
7547
|
+
variables: options === null || options === void 0 ? void 0 : options.variables,
|
|
7548
|
+
});
|
|
7549
|
+
(_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
7550
|
+
}
|
|
7282
7551
|
},
|
|
7283
7552
|
complete: function () {
|
|
7284
7553
|
var _a, _b;
|
|
7285
|
-
if (
|
|
7286
|
-
ref.current.options.onComplete
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
ref.current.options.onSubscriptionComplete
|
|
7554
|
+
if (!subscriptionStopped) {
|
|
7555
|
+
if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
|
|
7556
|
+
ref.current.options.onComplete();
|
|
7557
|
+
}
|
|
7558
|
+
else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
|
|
7559
|
+
ref.current.options.onSubscriptionComplete();
|
|
7560
|
+
}
|
|
7290
7561
|
}
|
|
7291
7562
|
},
|
|
7292
7563
|
});
|
|
7293
7564
|
return function () {
|
|
7294
|
-
|
|
7565
|
+
subscriptionStopped = true;
|
|
7566
|
+
setTimeout(function () {
|
|
7567
|
+
subscription.unsubscribe();
|
|
7568
|
+
});
|
|
7295
7569
|
};
|
|
7296
7570
|
}, [observable]);
|
|
7297
7571
|
return result;
|
|
@@ -7312,22 +7586,22 @@ function useReactiveVar(rv) {
|
|
|
7312
7586
|
return value;
|
|
7313
7587
|
}
|
|
7314
7588
|
|
|
7315
|
-
function
|
|
7589
|
+
function useFragment(options) {
|
|
7316
7590
|
var cache = useApolloClient().cache;
|
|
7317
7591
|
var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
|
|
7318
|
-
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
7592
|
+
var diffOptions = tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
|
|
7319
7593
|
var resultRef = React.useRef();
|
|
7320
7594
|
var latestDiff = cache.diff(diffOptions);
|
|
7321
7595
|
var getSnapshot = function () {
|
|
7322
7596
|
var latestDiffToResult = diffToResult(latestDiff);
|
|
7323
7597
|
return resultRef.current &&
|
|
7324
|
-
|
|
7598
|
+
equal.equal(resultRef.current.data, latestDiffToResult.data)
|
|
7325
7599
|
? resultRef.current
|
|
7326
7600
|
: (resultRef.current = latestDiffToResult);
|
|
7327
7601
|
};
|
|
7328
7602
|
return useSyncExternalStore(function (forceUpdate) {
|
|
7329
7603
|
return cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
|
|
7330
|
-
if (!
|
|
7604
|
+
if (!equal.equal(diff, latestDiff)) {
|
|
7331
7605
|
resultRef.current = diffToResult((latestDiff = diff));
|
|
7332
7606
|
forceUpdate();
|
|
7333
7607
|
}
|
|
@@ -7347,122 +7621,116 @@ function diffToResult(diff) {
|
|
|
7347
7621
|
|
|
7348
7622
|
function useDeepMemo(memoFn, deps) {
|
|
7349
7623
|
var ref = React.useRef();
|
|
7350
|
-
if (!ref.current || !
|
|
7624
|
+
if (!ref.current || !equal.equal(ref.current.deps, deps)) {
|
|
7351
7625
|
ref.current = { value: memoFn(), deps: deps };
|
|
7352
7626
|
}
|
|
7353
7627
|
return ref.current.value;
|
|
7354
7628
|
}
|
|
7355
7629
|
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7630
|
+
function useStrictModeSafeCleanupEffect(cleanup) {
|
|
7631
|
+
var timeout;
|
|
7632
|
+
React.useEffect(function () {
|
|
7633
|
+
clearTimeout(timeout);
|
|
7634
|
+
return function () {
|
|
7635
|
+
timeout = setTimeout(cleanup);
|
|
7636
|
+
};
|
|
7637
|
+
}, []);
|
|
7638
|
+
}
|
|
7639
|
+
|
|
7640
|
+
var useKey = 'use';
|
|
7641
|
+
var realHook = React__default[useKey];
|
|
7642
|
+
var __use = realHook ||
|
|
7643
|
+
function __use(promise) {
|
|
7644
|
+
var statefulPromise = wrapPromiseWithState(promise);
|
|
7645
|
+
switch (statefulPromise.status) {
|
|
7646
|
+
case 'pending':
|
|
7647
|
+
throw statefulPromise;
|
|
7648
|
+
case 'rejected':
|
|
7649
|
+
throw statefulPromise.reason;
|
|
7650
|
+
case 'fulfilled':
|
|
7651
|
+
return statefulPromise.value;
|
|
7652
|
+
}
|
|
7653
|
+
};
|
|
7359
7654
|
|
|
7360
7655
|
function useSuspenseCache(override) {
|
|
7361
7656
|
var context = React.useContext(getApolloContext());
|
|
7362
7657
|
var suspenseCache = override || context.suspenseCache;
|
|
7363
|
-
|
|
7364
|
-
'Wrap the root component in an <ApolloProvider> and provide a suspenseCache, ' +
|
|
7365
|
-
'or pass a SuspenseCache instance in via options.') : tsInvariant.invariant(suspenseCache, 33);
|
|
7658
|
+
invariant(suspenseCache, 55);
|
|
7366
7659
|
return suspenseCache;
|
|
7367
7660
|
}
|
|
7368
7661
|
|
|
7369
|
-
|
|
7370
|
-
'cache-first',
|
|
7371
|
-
'network-only',
|
|
7372
|
-
'no-cache',
|
|
7373
|
-
'cache-and-network',
|
|
7374
|
-
];
|
|
7375
|
-
var DEFAULT_FETCH_POLICY = 'cache-first';
|
|
7376
|
-
var DEFAULT_SUSPENSE_POLICY = 'always';
|
|
7377
|
-
var DEFAULT_ERROR_POLICY = 'none';
|
|
7378
|
-
function useSuspenseQuery_experimental(query, options) {
|
|
7662
|
+
function useSuspenseQuery(query, options) {
|
|
7379
7663
|
if (options === void 0) { options = Object.create(null); }
|
|
7380
|
-
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7381
7664
|
var client = useApolloClient(options.client);
|
|
7382
|
-
var
|
|
7383
|
-
var
|
|
7384
|
-
var
|
|
7385
|
-
var
|
|
7386
|
-
var
|
|
7387
|
-
var
|
|
7388
|
-
return
|
|
7389
|
-
})
|
|
7390
|
-
var
|
|
7391
|
-
var
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
if (result.error &&
|
|
7396
|
-
(result.error.networkError || allowsThrownErrors)) {
|
|
7397
|
-
throw result.error;
|
|
7398
|
-
}
|
|
7399
|
-
if (result.loading) {
|
|
7400
|
-
if (!cacheEntry) {
|
|
7401
|
-
cacheEntry = suspenseCache.add(query, variables, {
|
|
7402
|
-
promise: maybeWrapConcastWithCustomPromise(observable.reobserveAsConcast(watchQueryOptions), { deferred: deferred }),
|
|
7403
|
-
observable: observable,
|
|
7404
|
-
});
|
|
7405
|
-
}
|
|
7406
|
-
var hasUsableResult = usePartialResult ||
|
|
7407
|
-
(fetchPolicy === 'cache-and-network' && hasFullResult);
|
|
7408
|
-
if (!hasUsableResult && !cacheEntry.fulfilled) {
|
|
7409
|
-
throw cacheEntry.promise;
|
|
7410
|
-
}
|
|
7665
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7666
|
+
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
7667
|
+
var variables = watchQueryOptions.variables;
|
|
7668
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
7669
|
+
var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
|
|
7670
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
7671
|
+
return client.watchQuery(watchQueryOptions);
|
|
7672
|
+
});
|
|
7673
|
+
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
7674
|
+
var promise = promiseCache.get(queryRef.key);
|
|
7675
|
+
if (!promise) {
|
|
7676
|
+
promise = queryRef.promise;
|
|
7677
|
+
promiseCache.set(queryRef.key, promise);
|
|
7411
7678
|
}
|
|
7679
|
+
useTrackedQueryRefs(queryRef);
|
|
7412
7680
|
React.useEffect(function () {
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
suspenseCache.remove(previousOpts.query, previousOpts.variables);
|
|
7417
|
-
suspenseCache.add(query, variables, {
|
|
7418
|
-
promise: observable.reobserve({ query: query, variables: variables }),
|
|
7419
|
-
observable: observable,
|
|
7681
|
+
return queryRef.listen(function (promise) {
|
|
7682
|
+
setPromiseCache(function (promiseCache) {
|
|
7683
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
7420
7684
|
});
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
React.
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7428
|
-
|
|
7685
|
+
});
|
|
7686
|
+
}, [queryRef]);
|
|
7687
|
+
var result = __use(promise);
|
|
7688
|
+
var fetchMore = React.useCallback(function (options) {
|
|
7689
|
+
var promise = queryRef.fetchMore(options);
|
|
7690
|
+
setPromiseCache(function (previousPromiseCache) {
|
|
7691
|
+
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
7692
|
+
});
|
|
7693
|
+
return promise;
|
|
7694
|
+
}, [queryRef]);
|
|
7695
|
+
var refetch = React.useCallback(function (variables) {
|
|
7696
|
+
var promise = queryRef.refetch(variables);
|
|
7697
|
+
setPromiseCache(function (previousPromiseCache) {
|
|
7698
|
+
return new Map(previousPromiseCache).set(queryRef.key, promise);
|
|
7699
|
+
});
|
|
7700
|
+
return promise;
|
|
7701
|
+
}, [queryRef]);
|
|
7702
|
+
var subscribeToMore = React.useCallback(function (options) { return queryRef.observable.subscribeToMore(options); }, [queryRef]);
|
|
7429
7703
|
return React.useMemo(function () {
|
|
7430
7704
|
return {
|
|
7431
7705
|
client: client,
|
|
7432
7706
|
data: result.data,
|
|
7433
|
-
error:
|
|
7434
|
-
|
|
7435
|
-
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
observable: observable,
|
|
7439
|
-
});
|
|
7440
|
-
return promise;
|
|
7441
|
-
},
|
|
7442
|
-
refetch: function (variables) {
|
|
7443
|
-
var promise = observable.refetch(variables);
|
|
7444
|
-
suspenseCache.add(query, watchQueryOptions.variables, {
|
|
7445
|
-
promise: promise,
|
|
7446
|
-
observable: observable,
|
|
7447
|
-
});
|
|
7448
|
-
return promise;
|
|
7449
|
-
},
|
|
7450
|
-
subscribeToMore: function (options) { return observable.subscribeToMore(options); },
|
|
7707
|
+
error: toApolloError(result),
|
|
7708
|
+
networkStatus: result.networkStatus,
|
|
7709
|
+
fetchMore: fetchMore,
|
|
7710
|
+
refetch: refetch,
|
|
7711
|
+
subscribeToMore: subscribeToMore,
|
|
7451
7712
|
};
|
|
7452
|
-
}, [client,
|
|
7713
|
+
}, [client, fetchMore, refetch, result, subscribeToMore]);
|
|
7453
7714
|
}
|
|
7454
7715
|
function validateOptions(options) {
|
|
7455
|
-
var query = options.query,
|
|
7716
|
+
var query = options.query, fetchPolicy = options.fetchPolicy, returnPartialData = options.returnPartialData;
|
|
7456
7717
|
verifyDocumentType(query, exports.DocumentType.Query);
|
|
7457
7718
|
validateFetchPolicy(fetchPolicy);
|
|
7458
7719
|
validatePartialDataReturn(fetchPolicy, returnPartialData);
|
|
7459
7720
|
}
|
|
7460
7721
|
function validateFetchPolicy(fetchPolicy) {
|
|
7461
|
-
|
|
7722
|
+
if (fetchPolicy === void 0) { fetchPolicy = 'cache-first'; }
|
|
7723
|
+
var supportedFetchPolicies = [
|
|
7724
|
+
'cache-first',
|
|
7725
|
+
'network-only',
|
|
7726
|
+
'no-cache',
|
|
7727
|
+
'cache-and-network',
|
|
7728
|
+
];
|
|
7729
|
+
invariant(supportedFetchPolicies.includes(fetchPolicy), 56, fetchPolicy);
|
|
7462
7730
|
}
|
|
7463
7731
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
7464
7732
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
7465
|
-
__DEV__ &&
|
|
7733
|
+
__DEV__ && invariant.warn(57);
|
|
7466
7734
|
}
|
|
7467
7735
|
}
|
|
7468
7736
|
function toApolloError(result) {
|
|
@@ -7470,120 +7738,205 @@ function toApolloError(result) {
|
|
|
7470
7738
|
? new ApolloError({ graphQLErrors: result.errors })
|
|
7471
7739
|
: result.error;
|
|
7472
7740
|
}
|
|
7473
|
-
function
|
|
7474
|
-
var
|
|
7475
|
-
|
|
7476
|
-
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
resolve(value);
|
|
7480
|
-
subscription.unsubscribe();
|
|
7481
|
-
},
|
|
7482
|
-
error: reject,
|
|
7483
|
-
});
|
|
7484
|
-
});
|
|
7485
|
-
}
|
|
7486
|
-
return concast.promise;
|
|
7741
|
+
function useTrackedQueryRefs(queryRef) {
|
|
7742
|
+
var trackedQueryRefs = React.useRef(new Set());
|
|
7743
|
+
trackedQueryRefs.current.add(queryRef);
|
|
7744
|
+
useStrictModeSafeCleanupEffect(function () {
|
|
7745
|
+
trackedQueryRefs.current.forEach(function (sub) { return sub.dispose(); });
|
|
7746
|
+
});
|
|
7487
7747
|
}
|
|
7488
7748
|
function useWatchQueryOptions(_a) {
|
|
7489
|
-
var query = _a.query, options = _a.options
|
|
7490
|
-
var
|
|
7491
|
-
var watchQueryOptions = useDeepMemo(function () {
|
|
7492
|
-
var errorPolicy = options.errorPolicy, fetchPolicy = options.fetchPolicy, _a = options.suspensePolicy, suspensePolicy = _a === void 0 ? DEFAULT_SUSPENSE_POLICY : _a, variables = options.variables, watchQueryOptions = tslib.__rest(options, ["errorPolicy", "fetchPolicy", "suspensePolicy", "variables"]);
|
|
7493
|
-
return tslib.__assign(tslib.__assign({}, watchQueryOptions), { query: query, errorPolicy: errorPolicy || (defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.errorPolicy) || DEFAULT_ERROR_POLICY, fetchPolicy: fetchPolicy || (defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.fetchPolicy) || DEFAULT_FETCH_POLICY, notifyOnNetworkStatusChange: suspensePolicy === 'always', fetchOnFirstSubscribe: false, variables: compact(tslib.__assign(tslib.__assign({}, defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.variables), variables)) });
|
|
7494
|
-
}, [options, query, defaultOptions]);
|
|
7749
|
+
var query = _a.query, options = _a.options;
|
|
7750
|
+
var watchQueryOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, options), { query: query, notifyOnNetworkStatusChange: false, nextFetchPolicy: void 0 })); }, [options, query]);
|
|
7495
7751
|
if (__DEV__) {
|
|
7496
7752
|
validateOptions(watchQueryOptions);
|
|
7497
7753
|
}
|
|
7498
7754
|
return watchQueryOptions;
|
|
7499
7755
|
}
|
|
7500
|
-
|
|
7501
|
-
|
|
7756
|
+
|
|
7757
|
+
function useBackgroundQuery(query, options) {
|
|
7758
|
+
if (options === void 0) { options = Object.create(null); }
|
|
7759
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7760
|
+
var client = useApolloClient(options.client);
|
|
7761
|
+
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
7762
|
+
var variables = watchQueryOptions.variables;
|
|
7763
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
7764
|
+
var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
|
|
7765
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
7766
|
+
return client.watchQuery(watchQueryOptions);
|
|
7767
|
+
});
|
|
7768
|
+
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
7769
|
+
useTrackedQueryRefs(queryRef);
|
|
7770
|
+
var fetchMore = React.useCallback(function (options) {
|
|
7771
|
+
var promise = queryRef.fetchMore(options);
|
|
7772
|
+
setPromiseCache(function (promiseCache) {
|
|
7773
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
7774
|
+
});
|
|
7775
|
+
return promise;
|
|
7776
|
+
}, [queryRef]);
|
|
7777
|
+
var refetch = React.useCallback(function (variables) {
|
|
7778
|
+
var promise = queryRef.refetch(variables);
|
|
7779
|
+
setPromiseCache(function (promiseCache) {
|
|
7780
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
7781
|
+
});
|
|
7782
|
+
return promise;
|
|
7783
|
+
}, [queryRef]);
|
|
7784
|
+
queryRef.promiseCache = promiseCache;
|
|
7785
|
+
return React.useMemo(function () {
|
|
7786
|
+
return [
|
|
7787
|
+
queryRef,
|
|
7788
|
+
{
|
|
7789
|
+
fetchMore: fetchMore,
|
|
7790
|
+
refetch: refetch,
|
|
7791
|
+
},
|
|
7792
|
+
];
|
|
7793
|
+
}, [queryRef, fetchMore, refetch]);
|
|
7502
7794
|
}
|
|
7503
|
-
function
|
|
7504
|
-
var
|
|
7505
|
-
|
|
7506
|
-
var
|
|
7507
|
-
if (!
|
|
7508
|
-
|
|
7795
|
+
function useReadQuery(queryRef) {
|
|
7796
|
+
var _a = React.useState(0), forceUpdate = _a[1];
|
|
7797
|
+
invariant(queryRef.promiseCache, 49);
|
|
7798
|
+
var promise = queryRef.promiseCache.get(queryRef.key);
|
|
7799
|
+
if (!promise) {
|
|
7800
|
+
promise = queryRef.promise;
|
|
7801
|
+
queryRef.promiseCache.set(queryRef.key, promise);
|
|
7509
7802
|
}
|
|
7510
|
-
|
|
7511
|
-
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
};
|
|
7515
|
-
}, []);
|
|
7516
|
-
return useSyncExternalStore(React.useCallback(function (forceUpdate) {
|
|
7517
|
-
clearTimeout(subscribeTimeoutRef.current);
|
|
7518
|
-
function handleUpdate() {
|
|
7519
|
-
var previousResult = resultRef.current;
|
|
7520
|
-
var result = observable.getCurrentResult();
|
|
7521
|
-
if (previousResult.loading === result.loading &&
|
|
7522
|
-
previousResult.networkStatus === result.networkStatus &&
|
|
7523
|
-
equality.equal(previousResult.data, result.data)) {
|
|
7524
|
-
return;
|
|
7525
|
-
}
|
|
7526
|
-
resultRef.current = result;
|
|
7527
|
-
if (isMountedRef.current) {
|
|
7528
|
-
forceUpdate();
|
|
7529
|
-
}
|
|
7530
|
-
}
|
|
7531
|
-
var subscription;
|
|
7532
|
-
subscribeTimeoutRef.current = setTimeout(function () {
|
|
7533
|
-
subscription = observable.subscribe({
|
|
7534
|
-
next: handleUpdate,
|
|
7535
|
-
error: handleUpdate,
|
|
7536
|
-
});
|
|
7803
|
+
React.useEffect(function () {
|
|
7804
|
+
return queryRef.listen(function (promise) {
|
|
7805
|
+
queryRef.promiseCache.set(queryRef.key, promise);
|
|
7806
|
+
forceUpdate(function (prevState) { return prevState + 1; });
|
|
7537
7807
|
});
|
|
7538
|
-
|
|
7539
|
-
|
|
7808
|
+
}, [queryRef]);
|
|
7809
|
+
var result = __use(promise);
|
|
7810
|
+
return React.useMemo(function () {
|
|
7811
|
+
return {
|
|
7812
|
+
data: result.data,
|
|
7813
|
+
networkStatus: result.networkStatus,
|
|
7814
|
+
error: toApolloError(result),
|
|
7540
7815
|
};
|
|
7541
|
-
}, [
|
|
7816
|
+
}, [result]);
|
|
7542
7817
|
}
|
|
7543
7818
|
|
|
7544
|
-
var
|
|
7545
|
-
function
|
|
7546
|
-
|
|
7819
|
+
var QueryReference = (function () {
|
|
7820
|
+
function QueryReference(observable, options) {
|
|
7821
|
+
var _this = this;
|
|
7822
|
+
var _a;
|
|
7823
|
+
this.listeners = new Set();
|
|
7824
|
+
this.initialized = false;
|
|
7825
|
+
this.refetching = false;
|
|
7826
|
+
this.listen = this.listen.bind(this);
|
|
7827
|
+
this.handleNext = this.handleNext.bind(this);
|
|
7828
|
+
this.handleError = this.handleError.bind(this);
|
|
7829
|
+
this.dispose = this.dispose.bind(this);
|
|
7830
|
+
this.observable = observable;
|
|
7831
|
+
this.result = observable.getCurrentResult(false);
|
|
7832
|
+
this.key = options.key;
|
|
7833
|
+
if (options.onDispose) {
|
|
7834
|
+
this.onDispose = options.onDispose;
|
|
7835
|
+
}
|
|
7836
|
+
if (isNetworkRequestSettled(this.result.networkStatus) ||
|
|
7837
|
+
(this.result.data &&
|
|
7838
|
+
(!this.result.partial || this.observable.options.returnPartialData))) {
|
|
7839
|
+
this.promise = createFulfilledPromise(this.result);
|
|
7840
|
+
this.initialized = true;
|
|
7841
|
+
this.refetching = false;
|
|
7842
|
+
}
|
|
7843
|
+
this.subscription = observable.subscribe({
|
|
7844
|
+
next: this.handleNext,
|
|
7845
|
+
error: this.handleError,
|
|
7846
|
+
});
|
|
7847
|
+
if (!this.promise) {
|
|
7848
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
7849
|
+
_this.resolve = resolve;
|
|
7850
|
+
_this.reject = reject;
|
|
7851
|
+
});
|
|
7852
|
+
}
|
|
7853
|
+
this.autoDisposeTimeoutId = setTimeout(this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
|
|
7547
7854
|
}
|
|
7548
|
-
|
|
7549
|
-
var
|
|
7550
|
-
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
fulfilled: false,
|
|
7555
|
-
promise: promise
|
|
7556
|
-
.catch(function () {
|
|
7557
|
-
})
|
|
7558
|
-
.finally(function () {
|
|
7559
|
-
entry.fulfilled = true;
|
|
7560
|
-
}),
|
|
7855
|
+
QueryReference.prototype.listen = function (listener) {
|
|
7856
|
+
var _this = this;
|
|
7857
|
+
clearTimeout(this.autoDisposeTimeoutId);
|
|
7858
|
+
this.listeners.add(listener);
|
|
7859
|
+
return function () {
|
|
7860
|
+
_this.listeners.delete(listener);
|
|
7561
7861
|
};
|
|
7562
|
-
map.set(variablesKey, entry);
|
|
7563
|
-
this.queries.set(query, map);
|
|
7564
|
-
return entry;
|
|
7565
7862
|
};
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7863
|
+
QueryReference.prototype.refetch = function (variables) {
|
|
7864
|
+
this.refetching = true;
|
|
7865
|
+
var promise = this.observable.refetch(variables);
|
|
7866
|
+
this.promise = promise;
|
|
7867
|
+
return promise;
|
|
7570
7868
|
};
|
|
7571
|
-
|
|
7572
|
-
var
|
|
7573
|
-
|
|
7869
|
+
QueryReference.prototype.fetchMore = function (options) {
|
|
7870
|
+
var promise = this.observable.fetchMore(options);
|
|
7871
|
+
this.promise = promise;
|
|
7872
|
+
return promise;
|
|
7873
|
+
};
|
|
7874
|
+
QueryReference.prototype.dispose = function () {
|
|
7875
|
+
this.subscription.unsubscribe();
|
|
7876
|
+
this.onDispose();
|
|
7877
|
+
};
|
|
7878
|
+
QueryReference.prototype.onDispose = function () {
|
|
7879
|
+
};
|
|
7880
|
+
QueryReference.prototype.handleNext = function (result) {
|
|
7881
|
+
if (!this.initialized || this.refetching) {
|
|
7882
|
+
if (!isNetworkRequestSettled(result.networkStatus)) {
|
|
7883
|
+
return;
|
|
7884
|
+
}
|
|
7885
|
+
if (this.result.data && result.data === void 0) {
|
|
7886
|
+
result.data = this.result.data;
|
|
7887
|
+
}
|
|
7888
|
+
this.initialized = true;
|
|
7889
|
+
this.refetching = false;
|
|
7890
|
+
this.result = result;
|
|
7891
|
+
this.resolve(result);
|
|
7574
7892
|
return;
|
|
7575
7893
|
}
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
if (entry && !entry.observable.hasObservers()) {
|
|
7579
|
-
map.delete(key);
|
|
7894
|
+
if (result.data === this.result.data) {
|
|
7895
|
+
return;
|
|
7580
7896
|
}
|
|
7581
|
-
|
|
7582
|
-
|
|
7897
|
+
this.result = result;
|
|
7898
|
+
this.promise = createFulfilledPromise(result);
|
|
7899
|
+
this.deliver(this.promise);
|
|
7900
|
+
};
|
|
7901
|
+
QueryReference.prototype.handleError = function (error) {
|
|
7902
|
+
var result = tslib.__assign(tslib.__assign({}, this.result), { error: error, networkStatus: exports.NetworkStatus.error });
|
|
7903
|
+
this.result = result;
|
|
7904
|
+
if (!this.initialized || this.refetching) {
|
|
7905
|
+
this.initialized = true;
|
|
7906
|
+
this.refetching = false;
|
|
7907
|
+
this.reject(error);
|
|
7908
|
+
return;
|
|
7583
7909
|
}
|
|
7910
|
+
this.result = result;
|
|
7911
|
+
this.promise = result.data
|
|
7912
|
+
? createFulfilledPromise(result)
|
|
7913
|
+
: createRejectedPromise(result);
|
|
7914
|
+
this.deliver(this.promise);
|
|
7584
7915
|
};
|
|
7585
|
-
|
|
7586
|
-
|
|
7916
|
+
QueryReference.prototype.deliver = function (promise) {
|
|
7917
|
+
this.listeners.forEach(function (listener) { return listener(promise); });
|
|
7918
|
+
};
|
|
7919
|
+
return QueryReference;
|
|
7920
|
+
}());
|
|
7921
|
+
|
|
7922
|
+
var SuspenseCache = (function () {
|
|
7923
|
+
function SuspenseCache(options) {
|
|
7924
|
+
if (options === void 0) { options = Object.create(null); }
|
|
7925
|
+
this.cacheKeys = new trie.Trie(canUseWeakMap, function (cacheKey) { return cacheKey; });
|
|
7926
|
+
this.queryRefs = new Map();
|
|
7927
|
+
this.options = options;
|
|
7928
|
+
}
|
|
7929
|
+
SuspenseCache.prototype.getQueryRef = function (cacheKey, createObservable) {
|
|
7930
|
+
var _this = this;
|
|
7931
|
+
var stableCacheKey = this.cacheKeys.lookupArray(cacheKey);
|
|
7932
|
+
if (!this.queryRefs.has(stableCacheKey)) {
|
|
7933
|
+
this.queryRefs.set(stableCacheKey, new QueryReference(createObservable(), {
|
|
7934
|
+
key: stableCacheKey,
|
|
7935
|
+
autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
|
|
7936
|
+
onDispose: function () { return _this.queryRefs.delete(stableCacheKey); },
|
|
7937
|
+
}));
|
|
7938
|
+
}
|
|
7939
|
+
return this.queryRefs.get(stableCacheKey);
|
|
7587
7940
|
};
|
|
7588
7941
|
return SuspenseCache;
|
|
7589
7942
|
}());
|
|
@@ -7601,6 +7954,7 @@ exports.ApolloConsumer = ApolloConsumer;
|
|
|
7601
7954
|
exports.ApolloError = ApolloError;
|
|
7602
7955
|
exports.ApolloLink = ApolloLink;
|
|
7603
7956
|
exports.ApolloProvider = ApolloProvider;
|
|
7957
|
+
exports.DocumentTransform = DocumentTransform;
|
|
7604
7958
|
exports.HttpLink = HttpLink;
|
|
7605
7959
|
exports.InMemoryCache = InMemoryCache;
|
|
7606
7960
|
exports.MissingFieldError = MissingFieldError;
|
|
@@ -7620,6 +7974,7 @@ exports.fromError = fromError;
|
|
|
7620
7974
|
exports.fromPromise = fromPromise;
|
|
7621
7975
|
exports.getApolloContext = getApolloContext;
|
|
7622
7976
|
exports.isApolloError = isApolloError;
|
|
7977
|
+
exports.isNetworkRequestSettled = isNetworkRequestSettled;
|
|
7623
7978
|
exports.isReference = isReference;
|
|
7624
7979
|
exports.makeReference = makeReference;
|
|
7625
7980
|
exports.makeVar = makeVar;
|
|
@@ -7627,7 +7982,7 @@ exports.mergeOptions = mergeOptions;
|
|
|
7627
7982
|
exports.operationName = operationName;
|
|
7628
7983
|
exports.parseAndCheckHttpResponse = parseAndCheckHttpResponse;
|
|
7629
7984
|
exports.parser = parser;
|
|
7630
|
-
exports.resetApolloContext =
|
|
7985
|
+
exports.resetApolloContext = resetApolloContext;
|
|
7631
7986
|
exports.rewriteURIForGET = rewriteURIForGET;
|
|
7632
7987
|
exports.selectHttpOptionsAndBody = selectHttpOptionsAndBody;
|
|
7633
7988
|
exports.selectHttpOptionsAndBodyInternal = selectHttpOptionsAndBodyInternal;
|
|
@@ -7637,11 +7992,13 @@ exports.split = split;
|
|
|
7637
7992
|
exports.throwServerError = throwServerError;
|
|
7638
7993
|
exports.toPromise = toPromise;
|
|
7639
7994
|
exports.useApolloClient = useApolloClient;
|
|
7640
|
-
exports.
|
|
7995
|
+
exports.useBackgroundQuery = useBackgroundQuery;
|
|
7996
|
+
exports.useFragment = useFragment;
|
|
7641
7997
|
exports.useLazyQuery = useLazyQuery;
|
|
7642
7998
|
exports.useMutation = useMutation;
|
|
7643
7999
|
exports.useQuery = useQuery;
|
|
7644
8000
|
exports.useReactiveVar = useReactiveVar;
|
|
8001
|
+
exports.useReadQuery = useReadQuery;
|
|
7645
8002
|
exports.useSubscription = useSubscription;
|
|
7646
|
-
exports.
|
|
8003
|
+
exports.useSuspenseQuery = useSuspenseQuery;
|
|
7647
8004
|
//# sourceMappingURL=apollo-client.cjs.map
|