@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/core/core.cjs.native.js
CHANGED
|
@@ -6,7 +6,7 @@ var globals = require('../utilities/globals');
|
|
|
6
6
|
var tslib = require('tslib');
|
|
7
7
|
var core = require('../link/core');
|
|
8
8
|
var http = require('../link/http');
|
|
9
|
-
var
|
|
9
|
+
var equal = require('@wry/equality');
|
|
10
10
|
var utilities = require('../utilities');
|
|
11
11
|
var cache = require('../cache');
|
|
12
12
|
var errors = require('../errors');
|
|
@@ -15,16 +15,20 @@ var utils = require('../link/utils');
|
|
|
15
15
|
var tsInvariant = require('ts-invariant');
|
|
16
16
|
var graphqlTag = require('graphql-tag');
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
21
|
+
|
|
22
|
+
var version = '3.8.0-beta.1';
|
|
23
23
|
|
|
24
24
|
function isNonNullObject(obj) {
|
|
25
25
|
return obj !== null && typeof obj === 'object';
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
function isNonEmptyArray(value) {
|
|
29
|
+
return Array.isArray(value) && value.length > 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
28
32
|
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
29
33
|
var defaultReconciler = function (target, source, property) {
|
|
30
34
|
return this.merge(target[property], source[property]);
|
|
@@ -116,6 +120,73 @@ exports.NetworkStatus = void 0;
|
|
|
116
120
|
function isNetworkRequestInFlight(networkStatus) {
|
|
117
121
|
return networkStatus ? networkStatus < 7 : false;
|
|
118
122
|
}
|
|
123
|
+
function isNetworkRequestSettled(networkStatus) {
|
|
124
|
+
return networkStatus === 7 || networkStatus === 8;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function equalByQuery(query, _a, _b, variables) {
|
|
128
|
+
var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
|
|
129
|
+
var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
|
|
130
|
+
return equal__default(aRest, bRest) && equalBySelectionSet(utilities.getMainDefinition(query).selectionSet, aData, bData, {
|
|
131
|
+
fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(query)),
|
|
132
|
+
variables: variables,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function equalBySelectionSet(selectionSet, aResult, bResult, context) {
|
|
136
|
+
if (aResult === bResult) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
var seenSelections = new Set();
|
|
140
|
+
return selectionSet.selections.every(function (selection) {
|
|
141
|
+
if (seenSelections.has(selection))
|
|
142
|
+
return true;
|
|
143
|
+
seenSelections.add(selection);
|
|
144
|
+
if (!utilities.shouldInclude(selection, context.variables))
|
|
145
|
+
return true;
|
|
146
|
+
if (selectionHasNonreactiveDirective(selection))
|
|
147
|
+
return true;
|
|
148
|
+
if (utilities.isField(selection)) {
|
|
149
|
+
var resultKey = utilities.resultKeyNameFromField(selection);
|
|
150
|
+
var aResultChild = aResult && aResult[resultKey];
|
|
151
|
+
var bResultChild = bResult && bResult[resultKey];
|
|
152
|
+
var childSelectionSet = selection.selectionSet;
|
|
153
|
+
if (!childSelectionSet) {
|
|
154
|
+
return equal__default(aResultChild, bResultChild);
|
|
155
|
+
}
|
|
156
|
+
var aChildIsArray = Array.isArray(aResultChild);
|
|
157
|
+
var bChildIsArray = Array.isArray(bResultChild);
|
|
158
|
+
if (aChildIsArray !== bChildIsArray)
|
|
159
|
+
return false;
|
|
160
|
+
if (aChildIsArray && bChildIsArray) {
|
|
161
|
+
var length_1 = aResultChild.length;
|
|
162
|
+
if (bResultChild.length !== length_1) {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
for (var i = 0; i < length_1; ++i) {
|
|
166
|
+
if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
var fragment = utilities.getFragmentFromSelection(selection, context.fragmentMap);
|
|
176
|
+
if (fragment) {
|
|
177
|
+
if (selectionHasNonreactiveDirective(fragment))
|
|
178
|
+
return true;
|
|
179
|
+
return equalBySelectionSet(fragment.selectionSet, aResult, bResult, context);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function selectionHasNonreactiveDirective(selection) {
|
|
185
|
+
return !!selection.directives && selection.directives.some(directiveIsNonreactive);
|
|
186
|
+
}
|
|
187
|
+
function directiveIsNonreactive(dir) {
|
|
188
|
+
return dir.name.value === "nonreactive";
|
|
189
|
+
}
|
|
119
190
|
|
|
120
191
|
var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
|
|
121
192
|
var ObservableQuery = (function (_super) {
|
|
@@ -123,14 +194,13 @@ var ObservableQuery = (function (_super) {
|
|
|
123
194
|
function ObservableQuery(_a) {
|
|
124
195
|
var queryManager = _a.queryManager, queryInfo = _a.queryInfo, options = _a.options;
|
|
125
196
|
var _this = _super.call(this, function (observer) {
|
|
126
|
-
var _a = options.fetchOnFirstSubscribe, fetchOnFirstSubscribe = _a === void 0 ? true : _a;
|
|
127
197
|
try {
|
|
128
198
|
var subObserver = observer._subscription._observer;
|
|
129
199
|
if (subObserver && !subObserver.error) {
|
|
130
200
|
subObserver.error = defaultSubscriptionObserverErrorCallback;
|
|
131
201
|
}
|
|
132
202
|
}
|
|
133
|
-
catch (
|
|
203
|
+
catch (_a) { }
|
|
134
204
|
var first = !_this.observers.size;
|
|
135
205
|
_this.observers.add(observer);
|
|
136
206
|
var last = _this.last;
|
|
@@ -140,7 +210,7 @@ var ObservableQuery = (function (_super) {
|
|
|
140
210
|
else if (last && last.result) {
|
|
141
211
|
observer.next && observer.next(last.result);
|
|
142
212
|
}
|
|
143
|
-
if (first
|
|
213
|
+
if (first) {
|
|
144
214
|
_this.reobserve().catch(function () { });
|
|
145
215
|
}
|
|
146
216
|
return function () {
|
|
@@ -164,7 +234,7 @@ var ObservableQuery = (function (_super) {
|
|
|
164
234
|
}
|
|
165
235
|
Object.defineProperty(ObservableQuery.prototype, "query", {
|
|
166
236
|
get: function () {
|
|
167
|
-
return this.
|
|
237
|
+
return this.lastQuery || this.options.query;
|
|
168
238
|
},
|
|
169
239
|
enumerable: false,
|
|
170
240
|
configurable: true
|
|
@@ -206,13 +276,13 @@ var ObservableQuery = (function (_super) {
|
|
|
206
276
|
if (fetchPolicy === 'network-only' ||
|
|
207
277
|
fetchPolicy === 'no-cache' ||
|
|
208
278
|
fetchPolicy === 'standby' ||
|
|
209
|
-
this.queryManager.
|
|
279
|
+
this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) ;
|
|
210
280
|
else {
|
|
211
281
|
var diff = this.queryInfo.getDiff();
|
|
212
282
|
if (diff.complete || this.options.returnPartialData) {
|
|
213
283
|
result.data = diff.result;
|
|
214
284
|
}
|
|
215
|
-
if (
|
|
285
|
+
if (equal.equal(result.data, {})) {
|
|
216
286
|
result.data = void 0;
|
|
217
287
|
}
|
|
218
288
|
if (diff.complete) {
|
|
@@ -243,15 +313,20 @@ var ObservableQuery = (function (_super) {
|
|
|
243
313
|
return result;
|
|
244
314
|
};
|
|
245
315
|
ObservableQuery.prototype.isDifferentFromLastResult = function (newResult, variables) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
316
|
+
if (!this.last) {
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
var resultIsDifferent = this.queryManager.getDocumentInfo(this.query).hasNonreactiveDirective
|
|
320
|
+
? !equalByQuery(this.query, this.last.result, newResult, this.variables)
|
|
321
|
+
: !equal.equal(this.last.result, newResult);
|
|
322
|
+
return (resultIsDifferent ||
|
|
323
|
+
(variables && !equal.equal(this.last.variables, variables)));
|
|
249
324
|
};
|
|
250
325
|
ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
|
|
251
326
|
var last = this.last;
|
|
252
327
|
if (last &&
|
|
253
328
|
last[key] &&
|
|
254
|
-
(!variablesMustMatch ||
|
|
329
|
+
(!variablesMustMatch || equal.equal(last.variables, this.variables))) {
|
|
255
330
|
return last[key];
|
|
256
331
|
}
|
|
257
332
|
};
|
|
@@ -287,10 +362,14 @@ var ObservableQuery = (function (_super) {
|
|
|
287
362
|
var queryDef = utilities.getQueryDefinition(this.query);
|
|
288
363
|
var vars = queryDef.variableDefinitions;
|
|
289
364
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
290
|
-
globals.__DEV__ && globals.invariant.warn(
|
|
365
|
+
globals.__DEV__ && globals.invariant.warn(
|
|
366
|
+
19,
|
|
367
|
+
variables,
|
|
368
|
+
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
369
|
+
);
|
|
291
370
|
}
|
|
292
371
|
}
|
|
293
|
-
if (variables && !
|
|
372
|
+
if (variables && !equal.equal(this.options.variables, variables)) {
|
|
294
373
|
reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
|
|
295
374
|
}
|
|
296
375
|
this.queryInfo.resetLastWrite();
|
|
@@ -298,8 +377,12 @@ var ObservableQuery = (function (_super) {
|
|
|
298
377
|
};
|
|
299
378
|
ObservableQuery.prototype.fetchMore = function (fetchMoreOptions) {
|
|
300
379
|
var _this = this;
|
|
301
|
-
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" });
|
|
380
|
+
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" });
|
|
381
|
+
combinedOptions.query = this.transformDocument(combinedOptions.query);
|
|
302
382
|
var qid = this.queryManager.generateQueryId();
|
|
383
|
+
this.lastQuery = fetchMoreOptions.query
|
|
384
|
+
? this.transformDocument(this.options.query)
|
|
385
|
+
: combinedOptions.query;
|
|
303
386
|
var queryInfo = this.queryInfo;
|
|
304
387
|
var originalNetworkStatus = queryInfo.networkStatus;
|
|
305
388
|
queryInfo.networkStatus = exports.NetworkStatus.fetchMore;
|
|
@@ -371,7 +454,7 @@ var ObservableQuery = (function (_super) {
|
|
|
371
454
|
options.onError(err);
|
|
372
455
|
return;
|
|
373
456
|
}
|
|
374
|
-
globals.__DEV__ && globals.invariant.error(
|
|
457
|
+
globals.__DEV__ && globals.invariant.error(20, err);
|
|
375
458
|
},
|
|
376
459
|
});
|
|
377
460
|
this.subscriptions.add(subscription);
|
|
@@ -385,7 +468,7 @@ var ObservableQuery = (function (_super) {
|
|
|
385
468
|
return this.reobserve(newOptions);
|
|
386
469
|
};
|
|
387
470
|
ObservableQuery.prototype.setVariables = function (variables) {
|
|
388
|
-
if (
|
|
471
|
+
if (equal.equal(this.variables, variables)) {
|
|
389
472
|
return this.observers.size
|
|
390
473
|
? this.result()
|
|
391
474
|
: Promise.resolve();
|
|
@@ -450,7 +533,7 @@ var ObservableQuery = (function (_super) {
|
|
|
450
533
|
};
|
|
451
534
|
ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
|
|
452
535
|
this.queryManager.setObservableQuery(this);
|
|
453
|
-
return this.queryManager
|
|
536
|
+
return this.queryManager['fetchConcastWithInfo'](this.queryId, options, newNetworkStatus);
|
|
454
537
|
};
|
|
455
538
|
ObservableQuery.prototype.updatePolling = function () {
|
|
456
539
|
var _this = this;
|
|
@@ -469,7 +552,7 @@ var ObservableQuery = (function (_super) {
|
|
|
469
552
|
pollingInfo.interval === pollInterval) {
|
|
470
553
|
return;
|
|
471
554
|
}
|
|
472
|
-
globals.
|
|
555
|
+
globals.invariant(pollInterval, 21);
|
|
473
556
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
474
557
|
info.interval = pollInterval;
|
|
475
558
|
var maybeFetch = function () {
|
|
@@ -495,13 +578,13 @@ var ObservableQuery = (function (_super) {
|
|
|
495
578
|
};
|
|
496
579
|
ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
|
|
497
580
|
if (variables === void 0) { variables = this.variables; }
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (!utilities.isNonEmptyArray(newResult.errors)) {
|
|
502
|
-
delete this.last.error;
|
|
581
|
+
var error = this.getLastError();
|
|
582
|
+
if (error && this.last && !equal.equal(variables, this.last.variables)) {
|
|
583
|
+
error = void 0;
|
|
503
584
|
}
|
|
504
|
-
return this.last
|
|
585
|
+
return this.last = tslib.__assign({ result: this.queryManager.assumeImmutableResults
|
|
586
|
+
? newResult
|
|
587
|
+
: utilities.cloneDeep(newResult), variables: variables }, (error ? { error: error } : null));
|
|
505
588
|
};
|
|
506
589
|
ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
|
|
507
590
|
var _this = this;
|
|
@@ -515,11 +598,13 @@ var ObservableQuery = (function (_super) {
|
|
|
515
598
|
var options = useDisposableConcast
|
|
516
599
|
? mergedOptions
|
|
517
600
|
: assign(this.options, mergedOptions);
|
|
601
|
+
var query = this.transformDocument(options.query);
|
|
602
|
+
this.lastQuery = query;
|
|
518
603
|
if (!useDisposableConcast) {
|
|
519
604
|
this.updatePolling();
|
|
520
605
|
if (newOptions &&
|
|
521
606
|
newOptions.variables &&
|
|
522
|
-
!
|
|
607
|
+
!equal.equal(newOptions.variables, oldVariables) &&
|
|
523
608
|
options.fetchPolicy !== "standby" &&
|
|
524
609
|
options.fetchPolicy === oldFetchPolicy) {
|
|
525
610
|
this.applyNextFetchPolicy("variables-changed", options);
|
|
@@ -528,8 +613,9 @@ var ObservableQuery = (function (_super) {
|
|
|
528
613
|
}
|
|
529
614
|
}
|
|
530
615
|
}
|
|
616
|
+
var fetchOptions = query === options.query ? options : tslib.__assign(tslib.__assign({}, options), { query: query });
|
|
531
617
|
var variables = options.variables && tslib.__assign({}, options.variables);
|
|
532
|
-
var
|
|
618
|
+
var _a = this.fetch(fetchOptions, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
|
|
533
619
|
var observer = {
|
|
534
620
|
next: function (result) {
|
|
535
621
|
_this.reportResult(result, variables);
|
|
@@ -538,7 +624,7 @@ var ObservableQuery = (function (_super) {
|
|
|
538
624
|
_this.reportError(error, variables);
|
|
539
625
|
},
|
|
540
626
|
};
|
|
541
|
-
if (!useDisposableConcast) {
|
|
627
|
+
if (!useDisposableConcast && (fromLink || !this.concast)) {
|
|
542
628
|
if (this.concast && this.observer) {
|
|
543
629
|
this.concast.removeObserver(this.observer);
|
|
544
630
|
}
|
|
@@ -556,11 +642,12 @@ var ObservableQuery = (function (_super) {
|
|
|
556
642
|
};
|
|
557
643
|
ObservableQuery.prototype.reportResult = function (result, variables) {
|
|
558
644
|
var lastError = this.getLastError();
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
645
|
+
var isDifferent = this.isDifferentFromLastResult(result, variables);
|
|
646
|
+
if (lastError || !result.partial || this.options.returnPartialData) {
|
|
647
|
+
this.updateLastResult(result, variables);
|
|
648
|
+
}
|
|
649
|
+
if (lastError || isDifferent) {
|
|
650
|
+
utilities.iterateObserversSafely(this.observers, "next", result);
|
|
564
651
|
}
|
|
565
652
|
};
|
|
566
653
|
ObservableQuery.prototype.reportError = function (error, variables) {
|
|
@@ -586,6 +673,9 @@ var ObservableQuery = (function (_super) {
|
|
|
586
673
|
this.observers.clear();
|
|
587
674
|
this.isTornDown = true;
|
|
588
675
|
};
|
|
676
|
+
ObservableQuery.prototype.transformDocument = function (document) {
|
|
677
|
+
return this.queryManager.transform(document);
|
|
678
|
+
};
|
|
589
679
|
return ObservableQuery;
|
|
590
680
|
}(utilities.Observable));
|
|
591
681
|
utilities.fixObservableSubclass(ObservableQuery);
|
|
@@ -607,11 +697,11 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
607
697
|
return obsQuery.reobserve();
|
|
608
698
|
}
|
|
609
699
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
610
|
-
globals.__DEV__ && globals.invariant.error(
|
|
700
|
+
globals.__DEV__ && globals.invariant.error(22, error.message, error.stack);
|
|
611
701
|
}
|
|
612
702
|
function logMissingFieldErrors(missing) {
|
|
613
703
|
if (globals.__DEV__ && missing) {
|
|
614
|
-
globals.__DEV__ && globals.invariant.debug(
|
|
704
|
+
globals.__DEV__ && globals.invariant.debug(23, missing);
|
|
615
705
|
}
|
|
616
706
|
}
|
|
617
707
|
|
|
@@ -674,12 +764,8 @@ var LocalState = (function () {
|
|
|
674
764
|
}
|
|
675
765
|
return null;
|
|
676
766
|
};
|
|
677
|
-
LocalState.prototype.serverQuery = function (document
|
|
678
|
-
|
|
679
|
-
var _a = options.removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
680
|
-
return removeClientFields
|
|
681
|
-
? utilities.removeClientSetsFromDocument(document)
|
|
682
|
-
: document;
|
|
767
|
+
LocalState.prototype.serverQuery = function (document) {
|
|
768
|
+
return utilities.removeClientSetsFromDocument(document);
|
|
683
769
|
};
|
|
684
770
|
LocalState.prototype.prepareContext = function (context) {
|
|
685
771
|
var cache = this.cache;
|
|
@@ -794,7 +880,7 @@ var LocalState = (function () {
|
|
|
794
880
|
}
|
|
795
881
|
else {
|
|
796
882
|
fragment = fragmentMap[selection.name.value];
|
|
797
|
-
globals.
|
|
883
|
+
globals.invariant(fragment, 17, selection.name.value);
|
|
798
884
|
}
|
|
799
885
|
if (fragment && fragment.typeCondition) {
|
|
800
886
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -907,7 +993,7 @@ var LocalState = (function () {
|
|
|
907
993
|
},
|
|
908
994
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
909
995
|
var fragment = fragmentMap[spread.name.value];
|
|
910
|
-
globals.
|
|
996
|
+
globals.invariant(fragment, 18, spread.name.value);
|
|
911
997
|
var fragmentSelections = collectByDefinition(fragment);
|
|
912
998
|
if (fragmentSelections.size > 0) {
|
|
913
999
|
ancestors.forEach(function (node) {
|
|
@@ -969,10 +1055,10 @@ var QueryInfo = (function () {
|
|
|
969
1055
|
var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
|
|
970
1056
|
if (this.variables &&
|
|
971
1057
|
this.networkStatus !== exports.NetworkStatus.loading &&
|
|
972
|
-
!
|
|
1058
|
+
!equal.equal(this.variables, query.variables)) {
|
|
973
1059
|
networkStatus = exports.NetworkStatus.setVariables;
|
|
974
1060
|
}
|
|
975
|
-
if (!
|
|
1061
|
+
if (!equal.equal(query.variables, this.variables)) {
|
|
976
1062
|
this.lastDiff = void 0;
|
|
977
1063
|
}
|
|
978
1064
|
Object.assign(this, {
|
|
@@ -997,7 +1083,7 @@ var QueryInfo = (function () {
|
|
|
997
1083
|
QueryInfo.prototype.getDiff = function (variables) {
|
|
998
1084
|
if (variables === void 0) { variables = this.variables; }
|
|
999
1085
|
var options = this.getDiffOptions(variables);
|
|
1000
|
-
if (this.lastDiff &&
|
|
1086
|
+
if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
|
|
1001
1087
|
return this.lastDiff.diff;
|
|
1002
1088
|
}
|
|
1003
1089
|
this.updateWatch(this.variables = variables);
|
|
@@ -1031,7 +1117,7 @@ var QueryInfo = (function () {
|
|
|
1031
1117
|
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
1032
1118
|
this.updateLastDiff(diff);
|
|
1033
1119
|
if (!this.dirty &&
|
|
1034
|
-
!
|
|
1120
|
+
!equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
1035
1121
|
this.dirty = true;
|
|
1036
1122
|
if (!this.notifyTimeout) {
|
|
1037
1123
|
this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
|
|
@@ -1106,7 +1192,7 @@ var QueryInfo = (function () {
|
|
|
1106
1192
|
}
|
|
1107
1193
|
var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
|
|
1108
1194
|
if (!this.lastWatch ||
|
|
1109
|
-
!
|
|
1195
|
+
!equal.equal(watchOptions, this.lastWatch)) {
|
|
1110
1196
|
this.cancel();
|
|
1111
1197
|
this.cancel = this.cache.watch(this.lastWatch = watchOptions);
|
|
1112
1198
|
}
|
|
@@ -1118,8 +1204,8 @@ var QueryInfo = (function () {
|
|
|
1118
1204
|
var lastWrite = this.lastWrite;
|
|
1119
1205
|
return !(lastWrite &&
|
|
1120
1206
|
lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
|
|
1121
|
-
|
|
1122
|
-
|
|
1207
|
+
equal.equal(variables, lastWrite.variables) &&
|
|
1208
|
+
equal.equal(result.data, lastWrite.result.data));
|
|
1123
1209
|
};
|
|
1124
1210
|
QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
|
|
1125
1211
|
var _this = this;
|
|
@@ -1211,7 +1297,8 @@ function shouldWriteResult(result, errorPolicy) {
|
|
|
1211
1297
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1212
1298
|
var QueryManager = (function () {
|
|
1213
1299
|
function QueryManager(_a) {
|
|
1214
|
-
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,
|
|
1300
|
+
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;
|
|
1301
|
+
var _this = this;
|
|
1215
1302
|
this.clientAwareness = {};
|
|
1216
1303
|
this.queries = new Map();
|
|
1217
1304
|
this.fetchCancelFns = new Map();
|
|
@@ -1220,6 +1307,7 @@ var QueryManager = (function () {
|
|
|
1220
1307
|
this.requestIdCounter = 1;
|
|
1221
1308
|
this.mutationIdCounter = 1;
|
|
1222
1309
|
this.inFlightLinkObservables = new Map();
|
|
1310
|
+
var defaultDocumentTransform = new utilities.DocumentTransform(function (document) { return _this.cache.transformDocument(document); }, { cache: false });
|
|
1223
1311
|
this.cache = cache;
|
|
1224
1312
|
this.link = link;
|
|
1225
1313
|
this.defaultOptions = defaultOptions || Object.create(null);
|
|
@@ -1227,7 +1315,12 @@ var QueryManager = (function () {
|
|
|
1227
1315
|
this.clientAwareness = clientAwareness;
|
|
1228
1316
|
this.localState = localState || new LocalState({ cache: cache });
|
|
1229
1317
|
this.ssrMode = ssrMode;
|
|
1230
|
-
this.assumeImmutableResults =
|
|
1318
|
+
this.assumeImmutableResults = assumeImmutableResults;
|
|
1319
|
+
this.documentTransform = documentTransform
|
|
1320
|
+
? defaultDocumentTransform
|
|
1321
|
+
.concat(documentTransform)
|
|
1322
|
+
.concat(defaultDocumentTransform)
|
|
1323
|
+
: defaultDocumentTransform;
|
|
1231
1324
|
if ((this.onBroadcast = onBroadcast)) {
|
|
1232
1325
|
this.mutationStore = Object.create(null);
|
|
1233
1326
|
}
|
|
@@ -1237,7 +1330,7 @@ var QueryManager = (function () {
|
|
|
1237
1330
|
this.queries.forEach(function (_info, queryId) {
|
|
1238
1331
|
_this.stopQueryNoBroadcast(queryId);
|
|
1239
1332
|
});
|
|
1240
|
-
this.cancelPendingFetches(globals.
|
|
1333
|
+
this.cancelPendingFetches(globals.newInvariantError(24));
|
|
1241
1334
|
};
|
|
1242
1335
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1243
1336
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1247,23 +1340,22 @@ var QueryManager = (function () {
|
|
|
1247
1340
|
var _b, _c;
|
|
1248
1341
|
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;
|
|
1249
1342
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1250
|
-
var mutationId,
|
|
1251
|
-
return tslib.__generator(this, function (
|
|
1252
|
-
switch (
|
|
1343
|
+
var mutationId, hasClientExports, mutationStoreValue, self;
|
|
1344
|
+
return tslib.__generator(this, function (_h) {
|
|
1345
|
+
switch (_h.label) {
|
|
1253
1346
|
case 0:
|
|
1254
|
-
globals.
|
|
1255
|
-
globals.
|
|
1256
|
-
fetchPolicy === 'no-cache',
|
|
1257
|
-
fetchPolicy === 'no-cache', 16);
|
|
1347
|
+
globals.invariant(mutation, 25);
|
|
1348
|
+
globals.invariant(fetchPolicy === 'network-only' ||
|
|
1349
|
+
fetchPolicy === 'no-cache', 26);
|
|
1258
1350
|
mutationId = this.generateMutationId();
|
|
1259
|
-
|
|
1260
|
-
|
|
1351
|
+
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
1352
|
+
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
1261
1353
|
variables = this.getVariables(mutation, variables);
|
|
1262
1354
|
if (!hasClientExports) return [3, 2];
|
|
1263
1355
|
return [4, this.localState.addExportedVariables(mutation, variables, context)];
|
|
1264
1356
|
case 1:
|
|
1265
|
-
variables = (
|
|
1266
|
-
|
|
1357
|
+
variables = (_h.sent());
|
|
1358
|
+
_h.label = 2;
|
|
1267
1359
|
case 2:
|
|
1268
1360
|
mutationStoreValue = this.mutationStore &&
|
|
1269
1361
|
(this.mutationStore[mutationId] = {
|
|
@@ -1366,7 +1458,7 @@ var QueryManager = (function () {
|
|
|
1366
1458
|
if (utilities.isExecutionPatchIncrementalResult(result) && utilities.isNonEmptyArray(result.incremental)) {
|
|
1367
1459
|
var diff = cache.diff({
|
|
1368
1460
|
id: "ROOT_MUTATION",
|
|
1369
|
-
query: this.
|
|
1461
|
+
query: this.getDocumentInfo(mutation.document).asQuery,
|
|
1370
1462
|
variables: mutation.variables,
|
|
1371
1463
|
optimistic: false,
|
|
1372
1464
|
returnPartialData: true,
|
|
@@ -1437,7 +1529,7 @@ var QueryManager = (function () {
|
|
|
1437
1529
|
if (!skipCache) {
|
|
1438
1530
|
var diff = cache.diff({
|
|
1439
1531
|
id: "ROOT_MUTATION",
|
|
1440
|
-
query: _this.
|
|
1532
|
+
query: _this.getDocumentInfo(mutation.document).asQuery,
|
|
1441
1533
|
variables: mutation.variables,
|
|
1442
1534
|
optimistic: false,
|
|
1443
1535
|
returnPartialData: true,
|
|
@@ -1495,7 +1587,7 @@ var QueryManager = (function () {
|
|
|
1495
1587
|
}, mutation.mutationId);
|
|
1496
1588
|
};
|
|
1497
1589
|
QueryManager.prototype.fetchQuery = function (queryId, options, networkStatus) {
|
|
1498
|
-
return this.
|
|
1590
|
+
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast.promise;
|
|
1499
1591
|
};
|
|
1500
1592
|
QueryManager.prototype.getQueryStore = function () {
|
|
1501
1593
|
var store = Object.create(null);
|
|
@@ -1517,22 +1609,23 @@ var QueryManager = (function () {
|
|
|
1517
1609
|
}
|
|
1518
1610
|
};
|
|
1519
1611
|
QueryManager.prototype.transform = function (document) {
|
|
1612
|
+
return this.documentTransform.transformDocument(document);
|
|
1613
|
+
};
|
|
1614
|
+
QueryManager.prototype.getDocumentInfo = function (document) {
|
|
1520
1615
|
var transformCache = this.transformCache;
|
|
1521
|
-
var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
1522
1616
|
if (!transformCache.has(document)) {
|
|
1523
|
-
var
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
this.localState.
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
asQuery: tslib.__assign(tslib.__assign({}, transformed), { definitions: transformed.definitions.map(function (def) {
|
|
1617
|
+
var cacheEntry = {
|
|
1618
|
+
hasClientExports: utilities.hasClientExports(document),
|
|
1619
|
+
hasForcedResolvers: this.localState.shouldForceResolvers(document),
|
|
1620
|
+
hasNonreactiveDirective: utilities.hasDirectives(['nonreactive'], document),
|
|
1621
|
+
clientQuery: this.localState.clientQuery(document),
|
|
1622
|
+
serverQuery: utilities.removeDirectivesFromDocument([
|
|
1623
|
+
{ name: 'client', remove: true },
|
|
1624
|
+
{ name: 'connection' },
|
|
1625
|
+
{ name: 'nonreactive' },
|
|
1626
|
+
], document),
|
|
1627
|
+
defaultVars: utilities.getDefaultValues(utilities.getOperationDefinition(document)),
|
|
1628
|
+
asQuery: tslib.__assign(tslib.__assign({}, document), { definitions: document.definitions.map(function (def) {
|
|
1536
1629
|
if (def.kind === "OperationDefinition" &&
|
|
1537
1630
|
def.operation !== "query") {
|
|
1538
1631
|
return tslib.__assign(tslib.__assign({}, def), { operation: "query" });
|
|
@@ -1540,23 +1633,16 @@ var QueryManager = (function () {
|
|
|
1540
1633
|
return def;
|
|
1541
1634
|
}) })
|
|
1542
1635
|
};
|
|
1543
|
-
|
|
1544
|
-
if (doc && !transformCache.has(doc)) {
|
|
1545
|
-
transformCache.set(doc, cacheEntry_1);
|
|
1546
|
-
}
|
|
1547
|
-
};
|
|
1548
|
-
add(document);
|
|
1549
|
-
add(transformed);
|
|
1550
|
-
add(clientQuery);
|
|
1551
|
-
add(serverQuery);
|
|
1636
|
+
transformCache.set(document, cacheEntry);
|
|
1552
1637
|
}
|
|
1553
1638
|
return transformCache.get(document);
|
|
1554
1639
|
};
|
|
1555
1640
|
QueryManager.prototype.getVariables = function (document, variables) {
|
|
1556
|
-
return tslib.__assign(tslib.__assign({}, this.
|
|
1641
|
+
return tslib.__assign(tslib.__assign({}, this.getDocumentInfo(document).defaultVars), variables);
|
|
1557
1642
|
};
|
|
1558
1643
|
QueryManager.prototype.watchQuery = function (options) {
|
|
1559
|
-
|
|
1644
|
+
var query = this.transform(options.query);
|
|
1645
|
+
options = tslib.__assign(tslib.__assign({}, options), { variables: this.getVariables(query, options.variables) });
|
|
1560
1646
|
if (typeof options.notifyOnNetworkStatusChange === 'undefined') {
|
|
1561
1647
|
options.notifyOnNetworkStatusChange = false;
|
|
1562
1648
|
}
|
|
@@ -1566,9 +1652,10 @@ var QueryManager = (function () {
|
|
|
1566
1652
|
queryInfo: queryInfo,
|
|
1567
1653
|
options: options,
|
|
1568
1654
|
});
|
|
1655
|
+
observable['lastQuery'] = query;
|
|
1569
1656
|
this.queries.set(observable.queryId, queryInfo);
|
|
1570
1657
|
queryInfo.init({
|
|
1571
|
-
document:
|
|
1658
|
+
document: query,
|
|
1572
1659
|
observableQuery: observable,
|
|
1573
1660
|
variables: observable.variables,
|
|
1574
1661
|
});
|
|
@@ -1577,12 +1664,11 @@ var QueryManager = (function () {
|
|
|
1577
1664
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1578
1665
|
var _this = this;
|
|
1579
1666
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1580
|
-
globals.
|
|
1581
|
-
|
|
1582
|
-
globals.
|
|
1583
|
-
globals.
|
|
1584
|
-
|
|
1585
|
-
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
1667
|
+
globals.invariant(options.query, 27);
|
|
1668
|
+
globals.invariant(options.query.kind === 'Document', 28);
|
|
1669
|
+
globals.invariant(!options.returnPartialData, 29);
|
|
1670
|
+
globals.invariant(!options.pollInterval, 30);
|
|
1671
|
+
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
|
|
1586
1672
|
};
|
|
1587
1673
|
QueryManager.prototype.generateQueryId = function () {
|
|
1588
1674
|
return String(this.queryIdCounter++);
|
|
@@ -1606,7 +1692,7 @@ var QueryManager = (function () {
|
|
|
1606
1692
|
if (options === void 0) { options = {
|
|
1607
1693
|
discardWatches: true,
|
|
1608
1694
|
}; }
|
|
1609
|
-
this.cancelPendingFetches(globals.
|
|
1695
|
+
this.cancelPendingFetches(globals.newInvariantError(31));
|
|
1610
1696
|
this.queries.forEach(function (queryInfo) {
|
|
1611
1697
|
if (queryInfo.observableQuery) {
|
|
1612
1698
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1632,7 +1718,7 @@ var QueryManager = (function () {
|
|
|
1632
1718
|
queryNamesAndDocs.set(desc, false);
|
|
1633
1719
|
}
|
|
1634
1720
|
else if (utilities.isDocumentNode(desc)) {
|
|
1635
|
-
queryNamesAndDocs.set(_this.transform(desc)
|
|
1721
|
+
queryNamesAndDocs.set(_this.transform(desc), false);
|
|
1636
1722
|
}
|
|
1637
1723
|
else if (utilities.isNonNullObject(desc) && desc.query) {
|
|
1638
1724
|
legacyQueryOptions.add(desc);
|
|
@@ -1682,7 +1768,7 @@ var QueryManager = (function () {
|
|
|
1682
1768
|
if (globals.__DEV__ && queryNamesAndDocs.size) {
|
|
1683
1769
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
1684
1770
|
if (!included) {
|
|
1685
|
-
globals.__DEV__ && globals.invariant.warn(
|
|
1771
|
+
globals.__DEV__ && globals.invariant.warn(typeof nameOrDoc === "string" ? 32 : 33, nameOrDoc);
|
|
1686
1772
|
}
|
|
1687
1773
|
});
|
|
1688
1774
|
}
|
|
@@ -1711,7 +1797,7 @@ var QueryManager = (function () {
|
|
|
1711
1797
|
QueryManager.prototype.startGraphQLSubscription = function (_a) {
|
|
1712
1798
|
var _this = this;
|
|
1713
1799
|
var query = _a.query, fetchPolicy = _a.fetchPolicy, errorPolicy = _a.errorPolicy, variables = _a.variables, _b = _a.context, context = _b === void 0 ? {} : _b;
|
|
1714
|
-
query = this.transform(query)
|
|
1800
|
+
query = this.transform(query);
|
|
1715
1801
|
variables = this.getVariables(query, variables);
|
|
1716
1802
|
var makeObservable = function (variables) {
|
|
1717
1803
|
return _this.getObservableFromLink(query, context, variables).map(function (result) {
|
|
@@ -1726,15 +1812,22 @@ var QueryManager = (function () {
|
|
|
1726
1812
|
}
|
|
1727
1813
|
_this.broadcastQueries();
|
|
1728
1814
|
}
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
}
|
|
1815
|
+
var hasErrors = utilities.graphQLResultHasError(result);
|
|
1816
|
+
var hasProtocolErrors = errors.graphQLResultHasProtocolErrors(result);
|
|
1817
|
+
if (hasErrors || hasProtocolErrors) {
|
|
1818
|
+
var errors$1 = {};
|
|
1819
|
+
if (hasErrors) {
|
|
1820
|
+
errors$1.graphQLErrors = result.errors;
|
|
1821
|
+
}
|
|
1822
|
+
if (hasProtocolErrors) {
|
|
1823
|
+
errors$1.protocolErrors = result.extensions[errors.PROTOCOL_ERRORS_SYMBOL];
|
|
1824
|
+
}
|
|
1825
|
+
throw new errors.ApolloError(errors$1);
|
|
1733
1826
|
}
|
|
1734
1827
|
return result;
|
|
1735
1828
|
});
|
|
1736
1829
|
};
|
|
1737
|
-
if (this.
|
|
1830
|
+
if (this.getDocumentInfo(query).hasClientExports) {
|
|
1738
1831
|
var observablePromise_1 = this.localState.addExportedVariables(query, variables, context).then(makeObservable);
|
|
1739
1832
|
return new utilities.Observable(function (observer) {
|
|
1740
1833
|
var sub = null;
|
|
@@ -1772,9 +1865,9 @@ var QueryManager = (function () {
|
|
|
1772
1865
|
var _a;
|
|
1773
1866
|
if (deduplication === void 0) { deduplication = (_a = context === null || context === void 0 ? void 0 : context.queryDeduplication) !== null && _a !== void 0 ? _a : this.queryDeduplication; }
|
|
1774
1867
|
var observable;
|
|
1775
|
-
var
|
|
1868
|
+
var _b = this.getDocumentInfo(query), serverQuery = _b.serverQuery, clientQuery = _b.clientQuery;
|
|
1776
1869
|
if (serverQuery) {
|
|
1777
|
-
var
|
|
1870
|
+
var _c = this, inFlightLinkObservables_1 = _c.inFlightLinkObservables, link = _c.link;
|
|
1778
1871
|
var operation = {
|
|
1779
1872
|
query: serverQuery,
|
|
1780
1873
|
variables: variables,
|
|
@@ -1812,7 +1905,6 @@ var QueryManager = (function () {
|
|
|
1812
1905
|
]);
|
|
1813
1906
|
context = this.prepareContext(context);
|
|
1814
1907
|
}
|
|
1815
|
-
var clientQuery = this.transform(query).clientQuery;
|
|
1816
1908
|
if (clientQuery) {
|
|
1817
1909
|
observable = utilities.asyncMap(observable, function (result) {
|
|
1818
1910
|
return _this.localState.runResolvers({
|
|
@@ -1827,7 +1919,7 @@ var QueryManager = (function () {
|
|
|
1827
1919
|
};
|
|
1828
1920
|
QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
|
|
1829
1921
|
var requestId = queryInfo.lastRequestId = this.generateRequestId();
|
|
1830
|
-
var linkDocument = this.cache.transformForLink(
|
|
1922
|
+
var linkDocument = this.cache.transformForLink(options.query);
|
|
1831
1923
|
return utilities.asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
1832
1924
|
var graphQLErrors = utilities.getGraphQLErrorsFromResult(result);
|
|
1833
1925
|
var hasErrors = graphQLErrors.length > 0;
|
|
@@ -1860,10 +1952,10 @@ var QueryManager = (function () {
|
|
|
1860
1952
|
throw error;
|
|
1861
1953
|
});
|
|
1862
1954
|
};
|
|
1863
|
-
QueryManager.prototype.
|
|
1955
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
|
|
1864
1956
|
var _this = this;
|
|
1865
1957
|
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
1866
|
-
var query =
|
|
1958
|
+
var query = options.query;
|
|
1867
1959
|
var variables = this.getVariables(query, options.variables);
|
|
1868
1960
|
var queryInfo = this.getQuery(queryId);
|
|
1869
1961
|
var defaults = this.defaultOptions.watchQuery;
|
|
@@ -1879,24 +1971,36 @@ var QueryManager = (function () {
|
|
|
1879
1971
|
});
|
|
1880
1972
|
var fromVariables = function (variables) {
|
|
1881
1973
|
normalized.variables = variables;
|
|
1882
|
-
var
|
|
1974
|
+
var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
1883
1975
|
if (normalized.fetchPolicy !== "standby" &&
|
|
1884
|
-
|
|
1976
|
+
sourcesWithInfo.sources.length > 0 &&
|
|
1885
1977
|
queryInfo.observableQuery) {
|
|
1886
1978
|
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
1887
1979
|
}
|
|
1888
|
-
return
|
|
1980
|
+
return sourcesWithInfo;
|
|
1889
1981
|
};
|
|
1890
1982
|
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
1891
1983
|
this.fetchCancelFns.set(queryId, function (reason) {
|
|
1892
1984
|
cleanupCancelFn();
|
|
1893
1985
|
setTimeout(function () { return concast.cancel(reason); });
|
|
1894
1986
|
});
|
|
1895
|
-
var concast
|
|
1896
|
-
|
|
1897
|
-
|
|
1987
|
+
var concast, containsDataFromLink;
|
|
1988
|
+
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
1989
|
+
concast = new utilities.Concast(this.localState
|
|
1990
|
+
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
1991
|
+
.then(fromVariables).then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
1992
|
+
containsDataFromLink = true;
|
|
1993
|
+
}
|
|
1994
|
+
else {
|
|
1995
|
+
var sourcesWithInfo = fromVariables(normalized.variables);
|
|
1996
|
+
containsDataFromLink = sourcesWithInfo.fromLink;
|
|
1997
|
+
concast = new utilities.Concast(sourcesWithInfo.sources);
|
|
1998
|
+
}
|
|
1898
1999
|
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
1899
|
-
return
|
|
2000
|
+
return {
|
|
2001
|
+
concast: concast,
|
|
2002
|
+
fromLink: containsDataFromLink,
|
|
2003
|
+
};
|
|
1900
2004
|
};
|
|
1901
2005
|
QueryManager.prototype.refetchQueries = function (_a) {
|
|
1902
2006
|
var _this = this;
|
|
@@ -1971,7 +2075,7 @@ var QueryManager = (function () {
|
|
|
1971
2075
|
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;
|
|
1972
2076
|
var oldNetworkStatus = queryInfo.networkStatus;
|
|
1973
2077
|
queryInfo.init({
|
|
1974
|
-
document:
|
|
2078
|
+
document: query,
|
|
1975
2079
|
variables: variables,
|
|
1976
2080
|
networkStatus: networkStatus,
|
|
1977
2081
|
});
|
|
@@ -1981,11 +2085,11 @@ var QueryManager = (function () {
|
|
|
1981
2085
|
var data = diff.result;
|
|
1982
2086
|
if (globals.__DEV__ &&
|
|
1983
2087
|
!returnPartialData &&
|
|
1984
|
-
!
|
|
2088
|
+
!equal.equal(data, {})) {
|
|
1985
2089
|
logMissingFieldErrors(diff.missing);
|
|
1986
2090
|
}
|
|
1987
2091
|
var fromData = function (data) { return utilities.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
|
|
1988
|
-
if (data && _this.
|
|
2092
|
+
if (data && _this.getDocumentInfo(query).hasForcedResolvers) {
|
|
1989
2093
|
return _this.localState.runResolvers({
|
|
1990
2094
|
document: query,
|
|
1991
2095
|
remoteResult: { data: data },
|
|
@@ -2006,6 +2110,7 @@ var QueryManager = (function () {
|
|
|
2006
2110
|
refetchWritePolicy !== "merge") ? 1
|
|
2007
2111
|
: 2;
|
|
2008
2112
|
var resultsFromLink = function () { return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
|
|
2113
|
+
query: query,
|
|
2009
2114
|
variables: variables,
|
|
2010
2115
|
context: context,
|
|
2011
2116
|
fetchPolicy: fetchPolicy,
|
|
@@ -2020,54 +2125,40 @@ var QueryManager = (function () {
|
|
|
2020
2125
|
case "cache-first": {
|
|
2021
2126
|
var diff = readCache();
|
|
2022
2127
|
if (diff.complete) {
|
|
2023
|
-
return [
|
|
2024
|
-
resultsFromCache(diff, queryInfo.markReady()),
|
|
2025
|
-
];
|
|
2128
|
+
return { fromLink: false, sources: [resultsFromCache(diff, queryInfo.markReady())] };
|
|
2026
2129
|
}
|
|
2027
2130
|
if (returnPartialData || shouldNotify) {
|
|
2028
|
-
return [
|
|
2029
|
-
resultsFromCache(diff),
|
|
2030
|
-
resultsFromLink(),
|
|
2031
|
-
];
|
|
2131
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
2032
2132
|
}
|
|
2033
|
-
return [
|
|
2034
|
-
resultsFromLink(),
|
|
2035
|
-
];
|
|
2133
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2036
2134
|
}
|
|
2037
2135
|
case "cache-and-network": {
|
|
2038
2136
|
var diff = readCache();
|
|
2039
2137
|
if (diff.complete || returnPartialData || shouldNotify) {
|
|
2040
|
-
return [
|
|
2041
|
-
resultsFromCache(diff),
|
|
2042
|
-
resultsFromLink(),
|
|
2043
|
-
];
|
|
2138
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
2044
2139
|
}
|
|
2045
|
-
return [
|
|
2046
|
-
resultsFromLink(),
|
|
2047
|
-
];
|
|
2140
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2048
2141
|
}
|
|
2049
2142
|
case "cache-only":
|
|
2050
|
-
return [
|
|
2051
|
-
resultsFromCache(readCache(), queryInfo.markReady()),
|
|
2052
|
-
];
|
|
2143
|
+
return { fromLink: false, sources: [resultsFromCache(readCache(), queryInfo.markReady())] };
|
|
2053
2144
|
case "network-only":
|
|
2054
2145
|
if (shouldNotify) {
|
|
2055
|
-
return [
|
|
2056
|
-
resultsFromCache(readCache()),
|
|
2057
|
-
resultsFromLink(),
|
|
2058
|
-
];
|
|
2146
|
+
return { fromLink: true, sources: [resultsFromCache(readCache()), resultsFromLink()] };
|
|
2059
2147
|
}
|
|
2060
|
-
return [resultsFromLink()];
|
|
2148
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2061
2149
|
case "no-cache":
|
|
2062
2150
|
if (shouldNotify) {
|
|
2063
|
-
return
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2151
|
+
return {
|
|
2152
|
+
fromLink: true,
|
|
2153
|
+
sources: [
|
|
2154
|
+
resultsFromCache(queryInfo.getDiff()),
|
|
2155
|
+
resultsFromLink(),
|
|
2156
|
+
],
|
|
2157
|
+
};
|
|
2067
2158
|
}
|
|
2068
|
-
return [resultsFromLink()];
|
|
2159
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2069
2160
|
case "standby":
|
|
2070
|
-
return [];
|
|
2161
|
+
return { fromLink: false, sources: [] };
|
|
2071
2162
|
}
|
|
2072
2163
|
};
|
|
2073
2164
|
QueryManager.prototype.getQuery = function (queryId) {
|
|
@@ -2090,20 +2181,18 @@ var ApolloClient = (function () {
|
|
|
2090
2181
|
var _this = this;
|
|
2091
2182
|
this.resetStoreCallbacks = [];
|
|
2092
2183
|
this.clearStoreCallbacks = [];
|
|
2093
|
-
|
|
2184
|
+
if (!options.cache) {
|
|
2185
|
+
throw globals.newInvariantError(13);
|
|
2186
|
+
}
|
|
2187
|
+
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' &&
|
|
2094
2188
|
!window.__APOLLO_CLIENT__ &&
|
|
2095
|
-
globals.__DEV__ : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ?
|
|
2189
|
+
globals.__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;
|
|
2096
2190
|
var link = options.link;
|
|
2097
2191
|
if (!link) {
|
|
2098
2192
|
link = uri
|
|
2099
2193
|
? new http.HttpLink({ uri: uri, credentials: credentials, headers: headers })
|
|
2100
2194
|
: core.ApolloLink.empty();
|
|
2101
2195
|
}
|
|
2102
|
-
if (!cache) {
|
|
2103
|
-
throw globals.__DEV__ ? new globals.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
|
|
2104
|
-
"in the options object. \n" +
|
|
2105
|
-
"For more information, please visit: https://go.apollo.dev/c/docs") : new globals.InvariantError(9);
|
|
2106
|
-
}
|
|
2107
2196
|
this.link = link;
|
|
2108
2197
|
this.cache = cache;
|
|
2109
2198
|
this.disableNetworkFetches = ssrMode || ssrForceFetchDelay > 0;
|
|
@@ -2140,8 +2229,7 @@ var ApolloClient = (function () {
|
|
|
2140
2229
|
}
|
|
2141
2230
|
}
|
|
2142
2231
|
if (url) {
|
|
2143
|
-
globals.__DEV__ && globals.invariant.log(
|
|
2144
|
-
"experience: " + url);
|
|
2232
|
+
globals.__DEV__ && globals.invariant.log(14, url);
|
|
2145
2233
|
}
|
|
2146
2234
|
}
|
|
2147
2235
|
}
|
|
@@ -2156,6 +2244,7 @@ var ApolloClient = (function () {
|
|
|
2156
2244
|
cache: this.cache,
|
|
2157
2245
|
link: this.link,
|
|
2158
2246
|
defaultOptions: this.defaultOptions,
|
|
2247
|
+
documentTransform: documentTransform,
|
|
2159
2248
|
queryDeduplication: queryDeduplication,
|
|
2160
2249
|
ssrMode: ssrMode,
|
|
2161
2250
|
clientAwareness: {
|
|
@@ -2178,6 +2267,13 @@ var ApolloClient = (function () {
|
|
|
2178
2267
|
} : void 0,
|
|
2179
2268
|
});
|
|
2180
2269
|
}
|
|
2270
|
+
Object.defineProperty(ApolloClient.prototype, "documentTransform", {
|
|
2271
|
+
get: function () {
|
|
2272
|
+
return this.queryManager.documentTransform;
|
|
2273
|
+
},
|
|
2274
|
+
enumerable: false,
|
|
2275
|
+
configurable: true
|
|
2276
|
+
});
|
|
2181
2277
|
ApolloClient.prototype.stop = function () {
|
|
2182
2278
|
this.queryManager.stop();
|
|
2183
2279
|
};
|
|
@@ -2196,10 +2292,7 @@ var ApolloClient = (function () {
|
|
|
2196
2292
|
if (this.defaultOptions.query) {
|
|
2197
2293
|
options = utilities.mergeOptions(this.defaultOptions.query, options);
|
|
2198
2294
|
}
|
|
2199
|
-
globals.
|
|
2200
|
-
'client.query can only return a single result. Please use client.watchQuery ' +
|
|
2201
|
-
'to receive multiple results from the cache and the network, or consider ' +
|
|
2202
|
-
'using a different fetchPolicy, such as cache-first or network-only.') : globals.invariant(options.fetchPolicy !== 'cache-and-network', 10);
|
|
2295
|
+
globals.invariant(options.fetchPolicy !== 'cache-and-network', 15);
|
|
2203
2296
|
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
|
|
2204
2297
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
|
|
2205
2298
|
}
|
|
@@ -2288,7 +2381,7 @@ var ApolloClient = (function () {
|
|
|
2288
2381
|
result.queries = queries;
|
|
2289
2382
|
result.results = results;
|
|
2290
2383
|
result.catch(function (error) {
|
|
2291
|
-
globals.__DEV__ && globals.invariant.debug(
|
|
2384
|
+
globals.__DEV__ && globals.invariant.debug(16, error);
|
|
2292
2385
|
});
|
|
2293
2386
|
return result;
|
|
2294
2387
|
};
|
|
@@ -2322,6 +2415,7 @@ var ApolloClient = (function () {
|
|
|
2322
2415
|
|
|
2323
2416
|
tsInvariant.setVerbosity(globals.__DEV__ ? "log" : "silent");
|
|
2324
2417
|
|
|
2418
|
+
exports.DocumentTransform = utilities.DocumentTransform;
|
|
2325
2419
|
exports.Observable = utilities.Observable;
|
|
2326
2420
|
exports.isReference = utilities.isReference;
|
|
2327
2421
|
exports.makeReference = utilities.makeReference;
|
|
@@ -2346,6 +2440,7 @@ exports.gql = graphqlTag.gql;
|
|
|
2346
2440
|
exports.resetCaches = graphqlTag.resetCaches;
|
|
2347
2441
|
exports.ApolloClient = ApolloClient;
|
|
2348
2442
|
exports.ObservableQuery = ObservableQuery;
|
|
2443
|
+
exports.isNetworkRequestSettled = isNetworkRequestSettled;
|
|
2349
2444
|
for (var k in core) {
|
|
2350
2445
|
if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = core[k];
|
|
2351
2446
|
}
|