@apollo/client 4.0.0-alpha.12 → 4.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/curvy-flies-accept.md +5 -0
- package/.changeset/dirty-cobras-change.md +7 -0
- package/.changeset/few-crabs-move.md +6 -0
- package/.changeset/friendly-olives-refuse.md +5 -0
- package/.changeset/funny-boats-wink.md +35 -0
- package/.changeset/fuzzy-seahorses-hunt.md +5 -0
- package/.changeset/gold-oranges-double.md +5 -0
- package/.changeset/little-parrots-bow.md +14 -0
- package/.changeset/olive-cougars-ring.md +9 -0
- package/.changeset/pre.json +16 -0
- package/.changeset/serious-items-develop.md +17 -0
- package/.changeset/sixty-bats-cry.md +6 -0
- package/.changeset/spotty-mugs-poke.md +5 -0
- package/.changeset/strong-rivers-fry.md +34 -0
- package/.changeset/stupid-pumpkins-travel.md +13 -0
- package/.changeset/thirty-pens-jump.md +5 -0
- package/.changeset/wicked-kiwis-buy.md +5 -0
- package/CHANGELOG.md +148 -0
- package/__cjs/cache/core/cache.cjs +11 -9
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +11 -8
- package/__cjs/cache/core/types/DataProxy.d.cts +2 -1
- package/__cjs/cache/core/types/common.cjs.map +1 -1
- package/__cjs/cache/core/types/common.d.cts +2 -1
- package/__cjs/cache/index.cjs +1 -2
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +12 -11
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/fragmentRegistry.cjs +3 -2
- package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.cjs +10 -10
- package/__cjs/cache/inmemory/helpers.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.d.cts +3 -3
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +11 -8
- package/__cjs/cache/inmemory/key-extractor.cjs +10 -10
- package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.cjs +14 -13
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +2 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +17 -16
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +50 -22
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +2 -1
- package/__cjs/core/ApolloClient.cjs +28 -52
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +10 -23
- package/__cjs/core/ObservableQuery.cjs +569 -352
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +95 -33
- package/__cjs/core/QueryInfo.cjs +111 -183
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +9 -14
- package/__cjs/core/QueryManager.cjs +232 -138
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +12 -8
- package/__cjs/core/equalByQuery.cjs +7 -7
- package/__cjs/core/equalByQuery.cjs.map +1 -1
- package/__cjs/core/index.cjs +2 -3
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +4 -5
- package/__cjs/core/types.d.cts +20 -8
- package/__cjs/core/watchQueryOptions.d.cts +1 -1
- package/__cjs/dev/loadErrorMessageHandler.cjs +2 -3
- package/__cjs/dev/loadErrorMessageHandler.cjs.map +1 -1
- package/__cjs/dev/setErrorMessageHandler.cjs +2 -3
- package/__cjs/dev/setErrorMessageHandler.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.cjs +2 -2
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/LinkError.cjs +5 -1
- package/__cjs/errors/LinkError.cjs.map +1 -1
- package/__cjs/errors/LinkError.d.cts +5 -1
- package/__cjs/errors/LocalStateError.cjs +27 -0
- package/__cjs/errors/LocalStateError.cjs.map +1 -0
- package/__cjs/errors/LocalStateError.d.cts +20 -0
- package/__cjs/errors/index.cjs +5 -1
- package/__cjs/errors/index.cjs.map +1 -1
- package/__cjs/errors/index.d.cts +2 -0
- package/__cjs/invariantErrorCodes.cjs +230 -164
- package/__cjs/link/batch-http/batchHttpLink.cjs +5 -16
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.cjs +17 -11
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +15 -9
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs +7 -14
- package/__cjs/link/http/createHttpLink.cjs.map +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +11 -3
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +9 -9
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +2 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/subscriptions/index.cjs +3 -3
- package/__cjs/link/subscriptions/index.cjs.map +1 -1
- package/__cjs/link/utils/transformOperation.cjs +2 -2
- package/__cjs/link/utils/transformOperation.cjs.map +1 -1
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +535 -0
- package/__cjs/local-state/LocalState.cjs.map +1 -0
- package/__cjs/local-state/LocalState.d.cts +89 -0
- package/__cjs/local-state/index.cjs +6 -0
- package/__cjs/local-state/index.cjs.map +1 -0
- package/__cjs/local-state/index.d.cts +2 -0
- package/__cjs/masking/__benches__/types.bench.cjs.map +1 -1
- package/__cjs/masking/internal/types.d.cts +1 -2
- package/__cjs/masking/maskDefinition.cjs +6 -6
- package/__cjs/masking/maskDefinition.cjs.map +1 -1
- package/__cjs/masking/maskDefinition.d.cts +1 -1
- package/__cjs/masking/maskFragment.cjs +9 -5
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/masking/maskFragment.d.cts +5 -1
- package/__cjs/masking/maskOperation.cjs +9 -5
- package/__cjs/masking/maskOperation.cjs.map +1 -1
- package/__cjs/masking/maskOperation.d.cts +5 -1
- package/__cjs/masking/types.d.cts +2 -2
- package/__cjs/masking/utils.cjs +35 -2
- package/__cjs/masking/utils.cjs.map +1 -1
- package/__cjs/masking/utils.d.cts +7 -1
- package/__cjs/react/context/ApolloConsumer.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/hooks/internal/__use.cjs +6 -6
- package/__cjs/react/hooks/internal/__use.cjs.map +1 -1
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.cjs +2 -2
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.cjs.map +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +2 -2
- package/__cjs/react/hooks/internal/wrapHook.cjs +36 -34
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +42 -38
- package/__cjs/react/hooks/useApolloClient.cjs +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +1 -1
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +4 -4
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
- package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +1 -1
- package/__cjs/react/hooks/useMutation.cjs +2 -2
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +1 -1
- package/__cjs/react/hooks/useQuery.cjs +4 -4
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +1 -1
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs +22 -3
- package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs +4 -4
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +2 -2
- package/__cjs/react/internal/cache/QueryReference.cjs +12 -16
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +27 -9
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
- package/__cjs/react/ssr/prerenderStatic.cjs +9 -2
- package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.cjs +19 -14
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +10 -2
- package/__cjs/testing/internal/ObservableStream.cjs +13 -1
- package/__cjs/testing/internal/ObservableStream.cjs.map +1 -1
- package/__cjs/testing/internal/ObservableStream.d.cts +12 -1
- package/__cjs/testing/internal/disposables/withCleanup.cjs +5 -1
- package/__cjs/testing/internal/disposables/withCleanup.cjs.map +1 -1
- package/__cjs/testing/internal/disposables/withCleanup.d.cts +5 -1
- package/__cjs/testing/matchers/index.cjs +3 -0
- package/__cjs/testing/matchers/index.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitTypedValue.cjs +1 -1
- package/__cjs/testing/matchers/toEmitTypedValue.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitTypedValue.d.cts +6 -1
- package/__cjs/testing/matchers/toMatchDocument.cjs +2 -1
- package/__cjs/testing/matchers/toMatchDocument.cjs.map +1 -1
- package/__cjs/testing/matchers/toRerenderWithSimilarSnapshot.cjs +65 -0
- package/__cjs/testing/matchers/toRerenderWithSimilarSnapshot.cjs.map +1 -0
- package/__cjs/testing/matchers/toRerenderWithSimilarSnapshot.d.cts +20 -0
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs +1 -1
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs.map +1 -1
- package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +4 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +16 -4
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.cjs +2 -2
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +2 -2
- package/__cjs/utilities/caching/index.cjs +1 -4
- package/__cjs/utilities/caching/index.cjs.map +1 -1
- package/__cjs/utilities/caching/index.d.cts +0 -1
- package/__cjs/utilities/caching/sizes.cjs +1 -1
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/common/stripTypename.cjs +8 -2
- package/__cjs/utilities/common/stripTypename.cjs.map +1 -1
- package/__cjs/utilities/common/stripTypename.d.cts +7 -1
- package/__cjs/utilities/graphql/DocumentTransform.cjs +13 -9
- package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
- package/__cjs/utilities/graphql/DocumentTransform.d.cts +10 -6
- package/__cjs/utilities/graphql/operations.cjs +23 -2
- package/__cjs/utilities/graphql/operations.cjs.map +1 -1
- package/__cjs/utilities/graphql/operations.d.cts +21 -0
- package/__cjs/utilities/graphql/print.cjs +9 -1
- package/__cjs/utilities/graphql/print.cjs.map +1 -1
- package/__cjs/utilities/graphql/print.d.cts +8 -0
- package/__cjs/utilities/graphql/storeUtils.cjs +5 -206
- package/__cjs/utilities/graphql/storeUtils.cjs.map +1 -1
- package/__cjs/utilities/graphql/storeUtils.d.cts +14 -22
- package/__cjs/utilities/graphql/transform.cjs +8 -454
- package/__cjs/utilities/graphql/transform.cjs.map +1 -1
- package/__cjs/utilities/graphql/transform.d.cts +6 -24
- package/__cjs/utilities/index.cjs +17 -90
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +18 -38
- package/__cjs/utilities/{common/mergeDeep.cjs → internal/DeepMerger.cjs} +10 -27
- package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -0
- package/__cjs/utilities/internal/DeepMerger.d.cts +17 -0
- package/__cjs/utilities/internal/argumentsObjectFromField.cjs +18 -0
- package/__cjs/utilities/internal/argumentsObjectFromField.cjs.map +1 -0
- package/__cjs/utilities/internal/argumentsObjectFromField.d.cts +8 -0
- package/__cjs/utilities/{caching → internal}/caches.cjs +24 -20
- package/__cjs/utilities/internal/caches.cjs.map +1 -0
- package/__cjs/utilities/internal/caches.d.cts +42 -0
- package/__cjs/utilities/internal/canUseDOM.cjs +11 -0
- package/__cjs/utilities/internal/canUseDOM.cjs.map +1 -0
- package/__cjs/utilities/internal/canUseDOM.d.cts +7 -0
- package/__cjs/utilities/internal/checkDocument.cjs +35 -0
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -0
- package/__cjs/utilities/internal/checkDocument.d.cts +10 -0
- package/__cjs/utilities/{common → internal}/cloneDeep.cjs +10 -6
- package/__cjs/utilities/internal/cloneDeep.cjs.map +1 -0
- package/__cjs/utilities/internal/cloneDeep.d.cts +9 -0
- package/__cjs/utilities/{common → internal}/compact.cjs +7 -3
- package/__cjs/utilities/internal/compact.cjs.map +1 -0
- package/__cjs/utilities/internal/compact.d.cts +11 -0
- package/__cjs/utilities/internal/createFragmentMap.cjs +19 -0
- package/__cjs/utilities/internal/createFragmentMap.cjs.map +1 -0
- package/__cjs/utilities/internal/createFragmentMap.d.cts +12 -0
- package/__cjs/utilities/internal/createFulfilledPromise.cjs +15 -0
- package/__cjs/utilities/internal/createFulfilledPromise.cjs.map +1 -0
- package/__cjs/utilities/internal/createFulfilledPromise.d.cts +8 -0
- package/__cjs/utilities/internal/createRejectedPromise.cjs +17 -0
- package/__cjs/utilities/internal/createRejectedPromise.cjs.map +1 -0
- package/__cjs/utilities/internal/createRejectedPromise.d.cts +8 -0
- package/__cjs/utilities/internal/dealias.cjs +21 -0
- package/__cjs/utilities/internal/dealias.cjs.map +1 -0
- package/__cjs/utilities/internal/dealias.d.cts +5 -0
- package/{utilities/promises/decoration.js → __cjs/utilities/internal/decoratePromise.cjs} +12 -18
- package/__cjs/utilities/internal/decoratePromise.cjs.map +1 -0
- package/__cjs/utilities/internal/decoratePromise.d.cts +8 -0
- package/__cjs/utilities/{common/maybeDeepFreeze.cjs → internal/deepFreeze.cjs} +9 -12
- package/__cjs/utilities/internal/deepFreeze.cjs.map +1 -0
- package/__cjs/utilities/internal/deepFreeze.d.cts +7 -0
- package/__cjs/utilities/internal/filterMap.cjs +31 -0
- package/__cjs/utilities/internal/filterMap.cjs.map +1 -0
- package/__cjs/utilities/internal/filterMap.d.cts +4 -0
- package/__cjs/utilities/internal/getDefaultValues.cjs +22 -0
- package/__cjs/utilities/internal/getDefaultValues.cjs.map +1 -0
- package/__cjs/utilities/internal/getDefaultValues.d.cts +8 -0
- package/__cjs/utilities/internal/getFragmentDefinition.cjs +17 -0
- package/__cjs/utilities/internal/getFragmentDefinition.cjs.map +1 -0
- package/__cjs/utilities/internal/getFragmentDefinition.d.cts +8 -0
- package/__cjs/utilities/internal/getFragmentDefinitions.cjs +12 -0
- package/__cjs/utilities/internal/getFragmentDefinitions.cjs.map +1 -0
- package/__cjs/utilities/internal/getFragmentDefinitions.d.cts +8 -0
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +27 -0
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs.map +1 -0
- package/__cjs/utilities/internal/getFragmentFromSelection.d.cts +10 -0
- package/__cjs/utilities/{graphql/fragments.cjs → internal/getFragmentQueryDocument.cjs} +26 -66
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs.map +1 -0
- package/__cjs/utilities/internal/getFragmentQueryDocument.d.cts +29 -0
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs +23 -0
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs.map +1 -0
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.d.cts +8 -0
- package/__cjs/utilities/internal/getMainDefinition.cjs +38 -0
- package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -0
- package/__cjs/utilities/internal/getMainDefinition.d.cts +12 -0
- package/__cjs/utilities/internal/getMemoryInternals.cjs +15 -9
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +15 -9
- package/__cjs/utilities/internal/getOperationDefinition.cjs +14 -0
- package/__cjs/utilities/internal/getOperationDefinition.cjs.map +1 -0
- package/__cjs/utilities/internal/getOperationDefinition.d.cts +8 -0
- package/__cjs/utilities/internal/getOperationName.cjs +12 -0
- package/__cjs/utilities/internal/getOperationName.cjs.map +1 -0
- package/__cjs/utilities/internal/getOperationName.d.cts +8 -0
- package/__cjs/utilities/internal/getQueryDefinition.cjs +16 -0
- package/__cjs/utilities/internal/getQueryDefinition.cjs.map +1 -0
- package/__cjs/utilities/internal/getQueryDefinition.d.cts +8 -0
- package/__cjs/utilities/internal/getStoreKeyName.cjs +73 -0
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -0
- package/__cjs/utilities/internal/getStoreKeyName.d.cts +16 -0
- package/__cjs/utilities/internal/globals/global.cjs.map +1 -0
- package/__cjs/utilities/internal/globals/index.cjs.map +1 -0
- package/__cjs/utilities/internal/globals/maybe.cjs.map +1 -0
- package/__cjs/utilities/internal/graphQLResultHasError.cjs +15 -0
- package/__cjs/utilities/internal/graphQLResultHasError.cjs.map +1 -0
- package/__cjs/utilities/internal/graphQLResultHasError.d.cts +8 -0
- package/__cjs/utilities/internal/hasDirectives.cjs +24 -0
- package/__cjs/utilities/internal/hasDirectives.cjs.map +1 -0
- package/__cjs/utilities/internal/hasDirectives.d.cts +8 -0
- package/__cjs/utilities/internal/hasForcedResolvers.cjs +23 -0
- package/__cjs/utilities/internal/hasForcedResolvers.cjs.map +1 -0
- package/__cjs/utilities/internal/hasForcedResolvers.d.cts +3 -0
- package/__cjs/utilities/internal/index.cjs +107 -5
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +66 -2
- package/__cjs/utilities/internal/isArray.cjs +12 -0
- package/__cjs/utilities/internal/isArray.cjs.map +1 -0
- package/__cjs/utilities/internal/isArray.d.cts +9 -0
- package/__cjs/utilities/internal/isDocumentNode.cjs +15 -0
- package/__cjs/utilities/internal/isDocumentNode.cjs.map +1 -0
- package/__cjs/utilities/internal/isDocumentNode.d.cts +8 -0
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs +12 -0
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs.map +1 -0
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.d.cts +8 -0
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs +12 -0
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs.map +1 -0
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.d.cts +8 -0
- package/__cjs/utilities/internal/isExecutionPatchResult.cjs +15 -0
- package/__cjs/utilities/internal/isExecutionPatchResult.cjs.map +1 -0
- package/__cjs/utilities/internal/isExecutionPatchResult.d.cts +8 -0
- package/__cjs/utilities/internal/isField.cjs +12 -0
- package/__cjs/utilities/internal/isField.cjs.map +1 -0
- package/__cjs/utilities/internal/isField.d.cts +8 -0
- package/__cjs/utilities/{common/arrays.cjs → internal/isNonEmptyArray.cjs} +6 -4
- package/__cjs/utilities/internal/isNonEmptyArray.cjs.map +1 -0
- package/__cjs/utilities/internal/isNonEmptyArray.d.cts +7 -0
- package/__cjs/utilities/internal/isNonNullObject.cjs +12 -0
- package/__cjs/utilities/internal/isNonNullObject.cjs.map +1 -0
- package/__cjs/utilities/internal/isNonNullObject.d.cts +7 -0
- package/__cjs/utilities/{common/objects.cjs → internal/isPlainObject.cjs} +6 -5
- package/__cjs/utilities/internal/isPlainObject.cjs.map +1 -0
- package/__cjs/utilities/internal/isPlainObject.d.cts +7 -0
- package/__cjs/utilities/internal/makeReference.cjs +12 -0
- package/__cjs/utilities/internal/makeReference.cjs.map +1 -0
- package/__cjs/utilities/internal/makeReference.d.cts +8 -0
- package/__cjs/utilities/{common → internal}/makeUniqueId.cjs +8 -2
- package/__cjs/utilities/internal/makeUniqueId.cjs.map +1 -0
- package/__cjs/utilities/internal/makeUniqueId.d.cts +10 -0
- package/__cjs/utilities/internal/maybeDeepFreeze.cjs +17 -0
- package/__cjs/utilities/internal/maybeDeepFreeze.cjs.map +1 -0
- package/__cjs/utilities/internal/maybeDeepFreeze.d.cts +7 -0
- package/__cjs/utilities/internal/mergeDeep.cjs +26 -0
- package/__cjs/utilities/internal/mergeDeep.cjs.map +1 -0
- package/__cjs/utilities/internal/mergeDeep.d.cts +8 -0
- package/__cjs/utilities/internal/mergeDeepArray.cjs +27 -0
- package/__cjs/utilities/internal/mergeDeepArray.cjs.map +1 -0
- package/__cjs/utilities/internal/mergeDeepArray.d.cts +7 -0
- package/__cjs/utilities/internal/mergeIncrementalData.cjs +30 -0
- package/__cjs/utilities/internal/mergeIncrementalData.cjs.map +1 -0
- package/__cjs/utilities/internal/mergeIncrementalData.d.cts +8 -0
- package/__cjs/utilities/{common → internal}/mergeOptions.cjs +5 -0
- package/__cjs/utilities/internal/mergeOptions.cjs.map +1 -0
- package/__cjs/utilities/{common → internal}/mergeOptions.d.cts +5 -0
- package/__cjs/utilities/{common → internal}/omitDeep.cjs +7 -2
- package/__cjs/utilities/internal/omitDeep.cjs.map +1 -0
- package/__cjs/utilities/internal/omitDeep.d.cts +8 -0
- package/__cjs/utilities/internal/{observables.cjs → onAnyEvent.cjs} +6 -2
- package/__cjs/utilities/internal/onAnyEvent.cjs.map +1 -0
- package/__cjs/utilities/internal/{observables.d.cts → onAnyEvent.d.cts} +6 -2
- package/__cjs/utilities/{promises → internal}/preventUnhandledRejection.cjs.map +1 -1
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +306 -0
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -0
- package/__cjs/utilities/internal/removeDirectivesFromDocument.d.cts +14 -0
- package/__cjs/utilities/internal/resultKeyNameFromField.cjs +12 -0
- package/__cjs/utilities/internal/resultKeyNameFromField.cjs.map +1 -0
- package/__cjs/utilities/internal/resultKeyNameFromField.d.cts +8 -0
- package/__cjs/utilities/internal/shouldInclude.cjs +50 -0
- package/__cjs/utilities/internal/shouldInclude.cjs.map +1 -0
- package/__cjs/utilities/internal/shouldInclude.d.cts +8 -0
- package/__cjs/utilities/internal/storeKeyNameFromField.cjs +29 -0
- package/__cjs/utilities/internal/storeKeyNameFromField.cjs.map +1 -0
- package/__cjs/utilities/internal/storeKeyNameFromField.d.cts +8 -0
- package/__cjs/utilities/{common → internal}/stringifyForDisplay.cjs +6 -1
- package/__cjs/utilities/internal/stringifyForDisplay.cjs.map +1 -0
- package/__cjs/utilities/internal/stringifyForDisplay.d.cts +7 -0
- package/__cjs/utilities/internal/toQueryResult.cjs +5 -0
- package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -1
- package/__cjs/utilities/internal/toQueryResult.d.cts +5 -0
- package/__cjs/utilities/internal/types/DecoratedPromise.cjs +3 -0
- package/__cjs/utilities/internal/types/DecoratedPromise.cjs.map +1 -0
- package/__cjs/utilities/internal/types/DecoratedPromise.d.cts +10 -0
- package/__cjs/utilities/{types → internal/types}/DeepOmit.d.cts +5 -0
- package/__cjs/utilities/internal/types/DeepPartial.cjs.map +1 -0
- package/__cjs/utilities/{types → internal/types}/DeepPartial.d.cts +5 -0
- package/__cjs/utilities/internal/types/FragmentMap.cjs +3 -0
- package/__cjs/utilities/internal/types/FragmentMap.cjs.map +1 -0
- package/__cjs/utilities/internal/types/FragmentMap.d.cts +12 -0
- package/__cjs/utilities/internal/types/FragmentMapFunction.cjs +3 -0
- package/__cjs/utilities/internal/types/FragmentMapFunction.cjs.map +1 -0
- package/__cjs/utilities/internal/types/FragmentMapFunction.d.cts +8 -0
- package/__cjs/utilities/internal/types/FulfilledPromise.cjs +3 -0
- package/__cjs/utilities/internal/types/FulfilledPromise.cjs.map +1 -0
- package/__cjs/utilities/internal/types/FulfilledPromise.d.cts +10 -0
- package/__cjs/utilities/internal/types/IsAny.cjs +3 -0
- package/__cjs/utilities/internal/types/IsAny.cjs.map +1 -0
- package/__cjs/utilities/internal/types/IsAny.d.cts +7 -0
- package/__cjs/utilities/{types → internal/types}/NoInfer.d.cts +2 -0
- package/__cjs/utilities/{types/IsStrictlyAny.cjs → internal/types/PendingPromise.cjs} +1 -1
- package/__cjs/utilities/internal/types/PendingPromise.cjs.map +1 -0
- package/__cjs/utilities/internal/types/PendingPromise.d.cts +9 -0
- package/__cjs/utilities/internal/types/Prettify.d.cts +9 -0
- package/__cjs/utilities/internal/types/Primitive.d.cts +7 -0
- package/__cjs/utilities/internal/types/RejectedPromise.cjs +3 -0
- package/__cjs/utilities/internal/types/RejectedPromise.cjs.map +1 -0
- package/__cjs/utilities/internal/types/RejectedPromise.d.cts +10 -0
- package/__cjs/utilities/{types → internal/types}/RemoveIndexSignature.d.cts +5 -0
- package/__cjs/utilities/internal/types/TupleToIntersection.cjs +3 -0
- package/__cjs/utilities/internal/types/TupleToIntersection.cjs.map +1 -0
- package/__cjs/utilities/internal/types/TupleToIntersection.d.cts +2 -0
- package/__cjs/utilities/{types → internal/types}/VariablesOption.d.cts +5 -0
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +44 -0
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs.map +1 -0
- package/__cjs/utilities/internal/valueToObjectRepresentation.d.cts +8 -0
- package/__cjs/utilities/invariant/index.cjs +3 -2
- package/__cjs/utilities/invariant/index.cjs.map +1 -1
- package/__cjs/utilities/policies/pagination.cjs +26 -9
- package/__cjs/utilities/policies/pagination.cjs.map +1 -1
- package/__cjs/utilities/policies/pagination.d.cts +23 -0
- package/__cjs/utilities/{common → shared}/canonicalStringify.cjs +7 -4
- package/__cjs/utilities/shared/canonicalStringify.cjs.map +1 -0
- package/__cjs/utilities/subscriptions/relay/index.cjs +3 -3
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +11 -8
- package/cache/core/cache.js +11 -9
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +2 -1
- package/cache/core/types/common.d.ts +2 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/index.d.ts +1 -1
- package/cache/index.js +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +5 -4
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +2 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +3 -3
- package/cache/inmemory/helpers.js +2 -2
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +11 -8
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +3 -3
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/policies.d.ts +2 -1
- package/cache/inmemory/policies.js +7 -6
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +5 -4
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +2 -1
- package/cache/inmemory/writeToStore.js +34 -6
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +10 -23
- package/core/ApolloClient.js +24 -52
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +95 -33
- package/core/ObservableQuery.js +569 -352
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +9 -14
- package/core/QueryInfo.js +110 -182
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +12 -8
- package/core/QueryManager.js +192 -117
- package/core/QueryManager.js.map +1 -1
- package/core/equalByQuery.js +1 -1
- package/core/equalByQuery.js.map +1 -1
- package/core/index.d.ts +4 -5
- package/core/index.js +3 -3
- package/core/index.js.map +1 -1
- package/core/types.d.ts +20 -8
- package/core/watchQueryOptions.d.ts +1 -1
- package/dev/loadErrorMessageHandler.js +1 -1
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/dev/setErrorMessageHandler.js +1 -1
- package/dev/setErrorMessageHandler.js.map +1 -1
- package/errors/CombinedGraphQLErrors.js +1 -1
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/LinkError.d.ts +5 -1
- package/errors/LinkError.js +5 -1
- package/errors/LinkError.js.map +1 -1
- package/errors/LocalStateError.d.ts +20 -0
- package/errors/LocalStateError.js +23 -0
- package/errors/LocalStateError.js.map +1 -0
- package/errors/index.d.ts +2 -0
- package/errors/index.js +2 -0
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +230 -164
- package/legacyEntryPoints/local-state/index.d.ts +1 -0
- package/legacyEntryPoints/local-state/index.js +1 -0
- package/legacyEntryPoints/local-state/local-state.cjs +1 -0
- package/legacyEntryPoints/local-state/local-state.d.cts +1 -0
- package/legacyEntryPoints/utilities/internal/globals/globals.cjs +1 -0
- package/legacyEntryPoints/utilities/internal/globals/globals.d.cts +1 -0
- package/legacyEntryPoints/utilities/internal/globals/index.d.ts +1 -0
- package/legacyEntryPoints/utilities/internal/globals/index.js +1 -0
- package/link/batch-http/batchHttpLink.js +3 -14
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/core/ApolloLink.d.ts +15 -9
- package/link/core/ApolloLink.js +17 -11
- package/link/core/ApolloLink.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +4 -11
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +10 -2
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +4 -4
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js +2 -1
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/subscriptions/index.js +1 -1
- package/link/subscriptions/index.js.map +1 -1
- package/link/utils/transformOperation.js +2 -2
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/local-state/LocalState.d.ts +89 -0
- package/local-state/LocalState.js +527 -0
- package/local-state/LocalState.js.map +1 -0
- package/local-state/index.d.ts +2 -0
- package/local-state/index.js +2 -0
- package/local-state/index.js.map +1 -0
- package/masking/__benches__/types.bench.js.map +1 -1
- package/masking/internal/types.d.ts +1 -2
- package/masking/maskDefinition.d.ts +1 -1
- package/masking/maskDefinition.js +4 -4
- package/masking/maskDefinition.js.map +1 -1
- package/masking/maskFragment.d.ts +5 -1
- package/masking/maskFragment.js +8 -4
- package/masking/maskFragment.js.map +1 -1
- package/masking/maskOperation.d.ts +5 -1
- package/masking/maskOperation.js +7 -3
- package/masking/maskOperation.js.map +1 -1
- package/masking/types.d.ts +2 -2
- package/masking/utils.d.ts +7 -1
- package/masking/utils.js +34 -3
- package/masking/utils.js.map +1 -1
- package/package.json +21 -21
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/__use.js +6 -6
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
- package/react/hooks/internal/wrapHook.d.ts +42 -38
- package/react/hooks/internal/wrapHook.js +36 -34
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +1 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +1 -1
- package/react/hooks/useLazyQuery.js +3 -3
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +1 -1
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +1 -1
- package/react/hooks/useMutation.js +1 -1
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +1 -1
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +1 -1
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +1 -1
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +1 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +21 -2
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/internal/cache/FragmentReference.d.ts +2 -2
- package/react/internal/cache/FragmentReference.js +2 -2
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +27 -9
- package/react/internal/cache/QueryReference.js +9 -13
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/prerenderStatic.js +9 -2
- package/react/ssr/prerenderStatic.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +10 -2
- package/testing/core/mocking/mockLink.js +14 -9
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/internal/ObservableStream.d.ts +12 -1
- package/testing/internal/ObservableStream.js +13 -1
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/disposables/withCleanup.d.ts +5 -1
- package/testing/internal/disposables/withCleanup.js +5 -1
- package/testing/internal/disposables/withCleanup.js.map +1 -1
- package/testing/matchers/index.js +3 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toEmitTypedValue.d.ts +6 -1
- package/testing/matchers/toEmitTypedValue.js +1 -1
- package/testing/matchers/toEmitTypedValue.js.map +1 -1
- package/testing/matchers/toMatchDocument.js +2 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/matchers/toRerenderWithSimilarSnapshot.d.ts +20 -0
- package/testing/matchers/toRerenderWithSimilarSnapshot.js +62 -0
- package/testing/matchers/toRerenderWithSimilarSnapshot.js.map +1 -0
- package/testing/matchers/toStrictEqualTyped.d.ts +4 -0
- package/testing/matchers/toStrictEqualTyped.js +1 -1
- package/testing/matchers/toStrictEqualTyped.js.map +1 -1
- package/testing/matchers/utils/getSerializableProperties.js +15 -3
- package/testing/matchers/utils/getSerializableProperties.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +2 -2
- package/testing/react/MockedProvider.js +2 -2
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/caching/index.d.ts +0 -1
- package/utilities/caching/index.js +0 -1
- package/utilities/caching/index.js.map +1 -1
- package/utilities/caching/sizes.js +1 -1
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/common/stripTypename.d.ts +7 -1
- package/utilities/common/stripTypename.js +7 -1
- package/utilities/common/stripTypename.js.map +1 -1
- package/utilities/graphql/DocumentTransform.d.ts +10 -6
- package/utilities/graphql/DocumentTransform.js +12 -8
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/operations.d.ts +21 -0
- package/utilities/graphql/operations.js +22 -1
- package/utilities/graphql/operations.js.map +1 -1
- package/utilities/graphql/print.d.ts +8 -0
- package/utilities/graphql/print.js +10 -2
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +14 -22
- package/utilities/graphql/storeUtils.js +5 -196
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +6 -24
- package/utilities/graphql/transform.js +7 -443
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +18 -38
- package/utilities/index.js +16 -23
- package/utilities/index.js.map +1 -1
- package/utilities/internal/DeepMerger.d.ts +17 -0
- package/utilities/{common/mergeDeep.js → internal/DeepMerger.js} +7 -22
- package/utilities/internal/DeepMerger.js.map +1 -0
- package/utilities/internal/argumentsObjectFromField.d.ts +8 -0
- package/utilities/internal/argumentsObjectFromField.js +15 -0
- package/utilities/internal/argumentsObjectFromField.js.map +1 -0
- package/utilities/internal/caches.d.ts +42 -0
- package/utilities/{caching → internal}/caches.js +24 -20
- package/utilities/internal/caches.js.map +1 -0
- package/utilities/internal/canUseDOM.d.ts +7 -0
- package/utilities/internal/canUseDOM.js +8 -0
- package/utilities/internal/canUseDOM.js.map +1 -0
- package/utilities/internal/checkDocument.d.ts +10 -0
- package/utilities/internal/checkDocument.js +32 -0
- package/utilities/internal/checkDocument.js.map +1 -0
- package/utilities/internal/cloneDeep.d.ts +9 -0
- package/utilities/{common → internal}/cloneDeep.js +10 -6
- package/utilities/internal/cloneDeep.js.map +1 -0
- package/utilities/internal/compact.d.ts +11 -0
- package/utilities/{common → internal}/compact.js +7 -3
- package/utilities/internal/compact.js.map +1 -0
- package/utilities/internal/createFragmentMap.d.ts +12 -0
- package/utilities/internal/createFragmentMap.js +16 -0
- package/utilities/internal/createFragmentMap.js.map +1 -0
- package/utilities/internal/createFulfilledPromise.d.ts +8 -0
- package/utilities/internal/createFulfilledPromise.js +12 -0
- package/utilities/internal/createFulfilledPromise.js.map +1 -0
- package/utilities/internal/createRejectedPromise.d.ts +8 -0
- package/utilities/internal/createRejectedPromise.js +14 -0
- package/utilities/internal/createRejectedPromise.js.map +1 -0
- package/utilities/internal/dealias.d.ts +5 -0
- package/utilities/internal/dealias.js +18 -0
- package/utilities/internal/dealias.js.map +1 -0
- package/utilities/internal/decoratePromise.d.ts +8 -0
- package/utilities/internal/decoratePromise.js +30 -0
- package/utilities/internal/decoratePromise.js.map +1 -0
- package/utilities/internal/deepFreeze.d.ts +7 -0
- package/utilities/{common/maybeDeepFreeze.js → internal/deepFreeze.js} +7 -9
- package/utilities/internal/deepFreeze.js.map +1 -0
- package/utilities/internal/filterMap.d.ts +4 -0
- package/utilities/internal/filterMap.js +28 -0
- package/utilities/internal/filterMap.js.map +1 -0
- package/utilities/internal/getDefaultValues.d.ts +8 -0
- package/utilities/internal/getDefaultValues.js +19 -0
- package/utilities/internal/getDefaultValues.js.map +1 -0
- package/utilities/internal/getFragmentDefinition.d.ts +8 -0
- package/utilities/internal/getFragmentDefinition.js +14 -0
- package/utilities/internal/getFragmentDefinition.js.map +1 -0
- package/utilities/internal/getFragmentDefinitions.d.ts +8 -0
- package/utilities/internal/getFragmentDefinitions.js +9 -0
- package/utilities/internal/getFragmentDefinitions.js.map +1 -0
- package/utilities/internal/getFragmentFromSelection.d.ts +10 -0
- package/utilities/internal/getFragmentFromSelection.js +24 -0
- package/utilities/internal/getFragmentFromSelection.js.map +1 -0
- package/utilities/internal/getFragmentQueryDocument.d.ts +29 -0
- package/utilities/{graphql/fragments.js → internal/getFragmentQueryDocument.js} +26 -63
- package/utilities/internal/getFragmentQueryDocument.js.map +1 -0
- package/utilities/internal/getGraphQLErrorsFromResult.d.ts +8 -0
- package/utilities/{common/errorHandling.js → internal/getGraphQLErrorsFromResult.js} +8 -7
- package/utilities/internal/getGraphQLErrorsFromResult.js.map +1 -0
- package/utilities/internal/getMainDefinition.d.ts +12 -0
- package/utilities/internal/getMainDefinition.js +35 -0
- package/utilities/internal/getMainDefinition.js.map +1 -0
- package/utilities/internal/getMemoryInternals.d.ts +15 -9
- package/utilities/internal/getMemoryInternals.js +15 -9
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/getOperationDefinition.d.ts +8 -0
- package/utilities/internal/getOperationDefinition.js +11 -0
- package/utilities/internal/getOperationDefinition.js.map +1 -0
- package/utilities/internal/getOperationName.d.ts +8 -0
- package/utilities/internal/getOperationName.js +9 -0
- package/utilities/internal/getOperationName.js.map +1 -0
- package/utilities/internal/getQueryDefinition.d.ts +8 -0
- package/utilities/internal/getQueryDefinition.js +13 -0
- package/utilities/internal/getQueryDefinition.js.map +1 -0
- package/utilities/internal/getStoreKeyName.d.ts +16 -0
- package/utilities/internal/getStoreKeyName.js +70 -0
- package/utilities/internal/getStoreKeyName.js.map +1 -0
- package/utilities/{globals → internal/globals}/global.js +2 -2
- package/utilities/internal/globals/global.js.map +1 -0
- package/utilities/internal/globals/index.js.map +1 -0
- package/utilities/internal/globals/maybe.js.map +1 -0
- package/utilities/internal/graphQLResultHasError.d.ts +8 -0
- package/utilities/internal/graphQLResultHasError.js +12 -0
- package/utilities/internal/graphQLResultHasError.js.map +1 -0
- package/utilities/internal/hasDirectives.d.ts +8 -0
- package/utilities/internal/hasDirectives.js +21 -0
- package/utilities/internal/hasDirectives.js.map +1 -0
- package/utilities/internal/hasForcedResolvers.d.ts +3 -0
- package/utilities/internal/hasForcedResolvers.js +20 -0
- package/utilities/internal/hasForcedResolvers.js.map +1 -0
- package/utilities/internal/index.d.ts +66 -2
- package/utilities/internal/index.js +52 -2
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isArray.d.ts +9 -0
- package/utilities/internal/isArray.js +9 -0
- package/utilities/internal/isArray.js.map +1 -0
- package/utilities/internal/isDocumentNode.d.ts +8 -0
- package/utilities/internal/isDocumentNode.js +12 -0
- package/utilities/internal/isDocumentNode.js.map +1 -0
- package/utilities/internal/isExecutionPatchIncrementalResult.d.ts +8 -0
- package/utilities/internal/isExecutionPatchIncrementalResult.js +9 -0
- package/utilities/internal/isExecutionPatchIncrementalResult.js.map +1 -0
- package/utilities/internal/isExecutionPatchIninitialResult.d.ts +8 -0
- package/utilities/internal/isExecutionPatchIninitialResult.js +9 -0
- package/utilities/internal/isExecutionPatchIninitialResult.js.map +1 -0
- package/utilities/internal/isExecutionPatchResult.d.ts +8 -0
- package/utilities/internal/isExecutionPatchResult.js +12 -0
- package/utilities/internal/isExecutionPatchResult.js.map +1 -0
- package/utilities/internal/isField.d.ts +8 -0
- package/utilities/internal/isField.js +9 -0
- package/utilities/internal/isField.js.map +1 -0
- package/utilities/internal/isNonEmptyArray.d.ts +7 -0
- package/utilities/internal/isNonEmptyArray.js +9 -0
- package/utilities/internal/isNonEmptyArray.js.map +1 -0
- package/utilities/internal/isNonNullObject.d.ts +7 -0
- package/utilities/internal/isNonNullObject.js +9 -0
- package/utilities/internal/isNonNullObject.js.map +1 -0
- package/utilities/internal/isPlainObject.d.ts +7 -0
- package/utilities/{common/objects.js → internal/isPlainObject.js} +6 -4
- package/utilities/internal/isPlainObject.js.map +1 -0
- package/utilities/internal/makeReference.d.ts +8 -0
- package/utilities/internal/makeReference.js +9 -0
- package/utilities/internal/makeReference.js.map +1 -0
- package/utilities/internal/makeUniqueId.d.ts +10 -0
- package/utilities/internal/makeUniqueId.js +15 -0
- package/utilities/internal/makeUniqueId.js.map +1 -0
- package/utilities/internal/maybeDeepFreeze.d.ts +7 -0
- package/utilities/internal/maybeDeepFreeze.js +14 -0
- package/utilities/internal/maybeDeepFreeze.js.map +1 -0
- package/utilities/internal/mergeDeep.d.ts +8 -0
- package/utilities/internal/mergeDeep.js +23 -0
- package/utilities/internal/mergeDeep.js.map +1 -0
- package/utilities/internal/mergeDeepArray.d.ts +7 -0
- package/utilities/internal/mergeDeepArray.js +24 -0
- package/utilities/internal/mergeDeepArray.js.map +1 -0
- package/utilities/internal/mergeIncrementalData.d.ts +8 -0
- package/utilities/internal/mergeIncrementalData.js +27 -0
- package/utilities/internal/mergeIncrementalData.js.map +1 -0
- package/utilities/{common → internal}/mergeOptions.d.ts +5 -0
- package/utilities/{common → internal}/mergeOptions.js +5 -0
- package/utilities/internal/mergeOptions.js.map +1 -0
- package/utilities/internal/omitDeep.d.ts +8 -0
- package/utilities/{common → internal}/omitDeep.js +6 -1
- package/utilities/internal/omitDeep.js.map +1 -0
- package/utilities/internal/{observables.d.ts → onAnyEvent.d.ts} +6 -2
- package/utilities/internal/{observables.js → onAnyEvent.js} +6 -2
- package/utilities/internal/onAnyEvent.js.map +1 -0
- package/utilities/{promises → internal}/preventUnhandledRejection.js.map +1 -1
- package/utilities/internal/removeDirectivesFromDocument.d.ts +14 -0
- package/utilities/internal/removeDirectivesFromDocument.js +300 -0
- package/utilities/internal/removeDirectivesFromDocument.js.map +1 -0
- package/utilities/internal/resultKeyNameFromField.d.ts +8 -0
- package/utilities/internal/resultKeyNameFromField.js +9 -0
- package/utilities/internal/resultKeyNameFromField.js.map +1 -0
- package/utilities/internal/shouldInclude.d.ts +8 -0
- package/utilities/internal/shouldInclude.js +47 -0
- package/utilities/internal/shouldInclude.js.map +1 -0
- package/utilities/internal/storeKeyNameFromField.d.ts +8 -0
- package/utilities/internal/storeKeyNameFromField.js +26 -0
- package/utilities/internal/storeKeyNameFromField.js.map +1 -0
- package/utilities/internal/stringifyForDisplay.d.ts +7 -0
- package/utilities/{common → internal}/stringifyForDisplay.js +6 -1
- package/utilities/internal/stringifyForDisplay.js.map +1 -0
- package/utilities/internal/toQueryResult.d.ts +5 -0
- package/utilities/internal/toQueryResult.js +5 -0
- package/utilities/internal/toQueryResult.js.map +1 -1
- package/utilities/internal/types/DecoratedPromise.d.ts +10 -0
- package/utilities/internal/types/DecoratedPromise.js +2 -0
- package/utilities/internal/types/DecoratedPromise.js.map +1 -0
- package/utilities/{types → internal/types}/DeepOmit.d.ts +5 -0
- package/utilities/{types → internal/types}/DeepPartial.d.ts +5 -0
- package/utilities/internal/types/DeepPartial.js.map +1 -0
- package/utilities/internal/types/FragmentMap.d.ts +12 -0
- package/utilities/internal/types/FragmentMap.js +2 -0
- package/utilities/internal/types/FragmentMap.js.map +1 -0
- package/utilities/internal/types/FragmentMapFunction.d.ts +8 -0
- package/utilities/internal/types/FragmentMapFunction.js +2 -0
- package/utilities/internal/types/FragmentMapFunction.js.map +1 -0
- package/utilities/internal/types/FulfilledPromise.d.ts +10 -0
- package/utilities/internal/types/FulfilledPromise.js +2 -0
- package/utilities/internal/types/FulfilledPromise.js.map +1 -0
- package/utilities/internal/types/IsAny.d.ts +7 -0
- package/utilities/internal/types/IsAny.js +2 -0
- package/utilities/internal/types/IsAny.js.map +1 -0
- package/utilities/{types → internal/types}/NoInfer.d.ts +2 -0
- package/utilities/internal/types/PendingPromise.d.ts +9 -0
- package/utilities/internal/types/PendingPromise.js +2 -0
- package/utilities/internal/types/PendingPromise.js.map +1 -0
- package/utilities/internal/types/Prettify.d.ts +9 -0
- package/utilities/internal/types/Primitive.d.ts +7 -0
- package/utilities/internal/types/RejectedPromise.d.ts +10 -0
- package/utilities/internal/types/RejectedPromise.js +2 -0
- package/utilities/internal/types/RejectedPromise.js.map +1 -0
- package/utilities/{types → internal/types}/RemoveIndexSignature.d.ts +5 -0
- package/utilities/internal/types/TupleToIntersection.d.ts +2 -0
- package/utilities/internal/types/TupleToIntersection.js +2 -0
- package/utilities/internal/types/TupleToIntersection.js.map +1 -0
- package/utilities/{types → internal/types}/VariablesOption.d.ts +5 -0
- package/utilities/internal/valueToObjectRepresentation.d.ts +8 -0
- package/utilities/internal/valueToObjectRepresentation.js +41 -0
- package/utilities/internal/valueToObjectRepresentation.js.map +1 -0
- package/utilities/invariant/index.js +3 -2
- package/utilities/invariant/index.js.map +1 -1
- package/utilities/policies/pagination.d.ts +23 -0
- package/utilities/policies/pagination.js +24 -7
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/{common → shared}/canonicalStringify.js +5 -2
- package/utilities/shared/canonicalStringify.js.map +1 -0
- package/utilities/subscriptions/relay/index.js +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs +0 -21
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs.map +0 -1
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.d.cts +0 -3
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs +0 -19
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs.map +0 -1
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.d.cts +0 -3
- package/__cjs/config/jest/areGraphQlErrorsEqual.cjs +0 -11
- package/__cjs/config/jest/areGraphQlErrorsEqual.cjs.map +0 -1
- package/__cjs/config/jest/areGraphQlErrorsEqual.d.cts +0 -3
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs +0 -20
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs.map +0 -1
- package/__cjs/config/jest/areMissingFieldErrorsEqual.d.cts +0 -3
- package/__cjs/config/jest/areServerErrorsEqual.cjs +0 -22
- package/__cjs/config/jest/areServerErrorsEqual.cjs.map +0 -1
- package/__cjs/config/jest/areServerErrorsEqual.d.cts +0 -3
- package/__cjs/config/jest/resolver.cjs +0 -32
- package/__cjs/config/jest/resolver.cjs.map +0 -1
- package/__cjs/config/jest/resolver.d.cts +0 -3
- package/__cjs/config/jest/setup.cjs +0 -65
- package/__cjs/config/jest/setup.cjs.map +0 -1
- package/__cjs/config/jest/setup.d.cts +0 -3
- package/__cjs/core/LocalState.cjs +0 -332
- package/__cjs/core/LocalState.cjs.map +0 -1
- package/__cjs/core/LocalState.d.cts +0 -52
- package/__cjs/testing/experimental/createSchemaFetch.cjs +0 -92
- package/__cjs/testing/experimental/createSchemaFetch.cjs.map +0 -1
- package/__cjs/testing/experimental/createSchemaFetch.d.cts +0 -43
- package/__cjs/testing/experimental/createTestSchema.cjs +0 -110
- package/__cjs/testing/experimental/createTestSchema.cjs.map +0 -1
- package/__cjs/testing/experimental/createTestSchema.d.cts +0 -57
- package/__cjs/testing/experimental/graphql-tools/utils.cjs +0 -177
- package/__cjs/testing/experimental/graphql-tools/utils.cjs.map +0 -1
- package/__cjs/testing/experimental/graphql-tools/utils.d.cts +0 -26
- package/__cjs/testing/experimental/graphql-tools/utils.test.cjs +0 -200
- package/__cjs/testing/experimental/graphql-tools/utils.test.cjs.map +0 -1
- package/__cjs/testing/experimental/graphql-tools/utils.test.d.cts +0 -2
- package/__cjs/testing/experimental/index.cjs +0 -8
- package/__cjs/testing/experimental/index.cjs.map +0 -1
- package/__cjs/testing/experimental/index.d.cts +0 -3
- package/__cjs/utilities/caching/caches.cjs.map +0 -1
- package/__cjs/utilities/caching/caches.d.cts +0 -34
- package/__cjs/utilities/common/arrays.cjs.map +0 -1
- package/__cjs/utilities/common/arrays.d.cts +0 -3
- package/__cjs/utilities/common/canUse.cjs +0 -24
- package/__cjs/utilities/common/canUse.cjs.map +0 -1
- package/__cjs/utilities/common/canUse.d.cts +0 -3
- package/__cjs/utilities/common/canonicalStringify.cjs.map +0 -1
- package/__cjs/utilities/common/cloneDeep.cjs.map +0 -1
- package/__cjs/utilities/common/cloneDeep.d.cts +0 -5
- package/__cjs/utilities/common/compact.cjs.map +0 -1
- package/__cjs/utilities/common/compact.d.cts +0 -7
- package/__cjs/utilities/common/errorHandling.cjs +0 -23
- package/__cjs/utilities/common/errorHandling.cjs.map +0 -1
- package/__cjs/utilities/common/errorHandling.d.cts +0 -4
- package/__cjs/utilities/common/incrementalResult.cjs +0 -45
- package/__cjs/utilities/common/incrementalResult.cjs.map +0 -1
- package/__cjs/utilities/common/incrementalResult.d.cts +0 -7
- package/__cjs/utilities/common/makeUniqueId.cjs.map +0 -1
- package/__cjs/utilities/common/makeUniqueId.d.cts +0 -2
- package/__cjs/utilities/common/maybeDeepFreeze.cjs.map +0 -1
- package/__cjs/utilities/common/maybeDeepFreeze.d.cts +0 -4
- package/__cjs/utilities/common/mergeDeep.cjs.map +0 -1
- package/__cjs/utilities/common/mergeDeep.d.cts +0 -14
- package/__cjs/utilities/common/mergeOptions.cjs.map +0 -1
- package/__cjs/utilities/common/objects.cjs.map +0 -1
- package/__cjs/utilities/common/objects.d.cts +0 -3
- package/__cjs/utilities/common/omitDeep.cjs.map +0 -1
- package/__cjs/utilities/common/omitDeep.d.cts +0 -3
- package/__cjs/utilities/common/stringifyForDisplay.cjs.map +0 -1
- package/__cjs/utilities/common/stringifyForDisplay.d.cts +0 -2
- package/__cjs/utilities/globals/global.cjs.map +0 -1
- package/__cjs/utilities/globals/index.cjs.map +0 -1
- package/__cjs/utilities/globals/maybe.cjs.map +0 -1
- package/__cjs/utilities/graphql/directives.cjs +0 -114
- package/__cjs/utilities/graphql/directives.cjs.map +0 -1
- package/__cjs/utilities/graphql/directives.d.cts +0 -20
- package/__cjs/utilities/graphql/fragments.cjs.map +0 -1
- package/__cjs/utilities/graphql/fragments.d.cts +0 -35
- package/__cjs/utilities/graphql/getFromAST.cjs +0 -101
- package/__cjs/utilities/graphql/getFromAST.cjs.map +0 -1
- package/__cjs/utilities/graphql/getFromAST.d.cts +0 -15
- package/__cjs/utilities/internal/observables.cjs.map +0 -1
- package/__cjs/utilities/promises/decoration.cjs +0 -45
- package/__cjs/utilities/promises/decoration.cjs.map +0 -1
- package/__cjs/utilities/promises/decoration.d.cts +0 -18
- package/__cjs/utilities/types/DeepPartial.cjs.map +0 -1
- package/__cjs/utilities/types/IsStrictlyAny.cjs.map +0 -1
- package/__cjs/utilities/types/IsStrictlyAny.d.cts +0 -5
- package/__cjs/utilities/types/Prettify.d.cts +0 -4
- package/__cjs/utilities/types/Primitive.d.cts +0 -2
- package/__cjs/utilities/types/UnionToIntersection.cjs +0 -3
- package/__cjs/utilities/types/UnionToIntersection.cjs.map +0 -1
- package/__cjs/utilities/types/UnionToIntersection.d.cts +0 -2
- package/config/jest/areCombinedGraphQLErrorsEqual.d.ts +0 -3
- package/config/jest/areCombinedGraphQLErrorsEqual.js +0 -17
- package/config/jest/areCombinedGraphQLErrorsEqual.js.map +0 -1
- package/config/jest/areCombinedProtocolErrorsEqual.d.ts +0 -3
- package/config/jest/areCombinedProtocolErrorsEqual.js +0 -15
- package/config/jest/areCombinedProtocolErrorsEqual.js.map +0 -1
- package/config/jest/areGraphQlErrorsEqual.d.ts +0 -3
- package/config/jest/areGraphQlErrorsEqual.js +0 -7
- package/config/jest/areGraphQlErrorsEqual.js.map +0 -1
- package/config/jest/areMissingFieldErrorsEqual.d.ts +0 -3
- package/config/jest/areMissingFieldErrorsEqual.js +0 -16
- package/config/jest/areMissingFieldErrorsEqual.js.map +0 -1
- package/config/jest/areServerErrorsEqual.d.ts +0 -3
- package/config/jest/areServerErrorsEqual.js +0 -18
- package/config/jest/areServerErrorsEqual.js.map +0 -1
- package/config/jest/resolver.d.ts +0 -3
- package/config/jest/resolver.js +0 -29
- package/config/jest/resolver.js.map +0 -1
- package/config/jest/setup.d.ts +0 -3
- package/config/jest/setup.js +0 -62
- package/config/jest/setup.js.map +0 -1
- package/core/LocalState.d.ts +0 -52
- package/core/LocalState.js +0 -328
- package/core/LocalState.js.map +0 -1
- package/legacyEntryPoints/testing/experimental/experimental.cjs +0 -1
- package/legacyEntryPoints/testing/experimental/experimental.d.cts +0 -1
- package/legacyEntryPoints/testing/experimental/index.d.ts +0 -1
- package/legacyEntryPoints/testing/experimental/index.js +0 -1
- package/legacyEntryPoints/utilities/globals/globals.cjs +0 -1
- package/legacyEntryPoints/utilities/globals/globals.d.cts +0 -1
- package/legacyEntryPoints/utilities/globals/index.d.ts +0 -1
- package/legacyEntryPoints/utilities/globals/index.js +0 -1
- package/testing/experimental/createSchemaFetch.d.ts +0 -43
- package/testing/experimental/createSchemaFetch.js +0 -89
- package/testing/experimental/createSchemaFetch.js.map +0 -1
- package/testing/experimental/createTestSchema.d.ts +0 -57
- package/testing/experimental/createTestSchema.js +0 -107
- package/testing/experimental/createTestSchema.js.map +0 -1
- package/testing/experimental/graphql-tools/utils.d.ts +0 -26
- package/testing/experimental/graphql-tools/utils.js +0 -174
- package/testing/experimental/graphql-tools/utils.js.map +0 -1
- package/testing/experimental/graphql-tools/utils.test.d.ts +0 -2
- package/testing/experimental/graphql-tools/utils.test.js +0 -198
- package/testing/experimental/graphql-tools/utils.test.js.map +0 -1
- package/testing/experimental/index.d.ts +0 -3
- package/testing/experimental/index.js +0 -3
- package/testing/experimental/index.js.map +0 -1
- package/utilities/caching/caches.d.ts +0 -34
- package/utilities/caching/caches.js.map +0 -1
- package/utilities/common/arrays.d.ts +0 -3
- package/utilities/common/arrays.js +0 -6
- package/utilities/common/arrays.js.map +0 -1
- package/utilities/common/canUse.d.ts +0 -3
- package/utilities/common/canUse.js +0 -21
- package/utilities/common/canUse.js.map +0 -1
- package/utilities/common/canonicalStringify.js.map +0 -1
- package/utilities/common/cloneDeep.d.ts +0 -5
- package/utilities/common/cloneDeep.js.map +0 -1
- package/utilities/common/compact.d.ts +0 -7
- package/utilities/common/compact.js.map +0 -1
- package/utilities/common/errorHandling.d.ts +0 -4
- package/utilities/common/errorHandling.js.map +0 -1
- package/utilities/common/incrementalResult.d.ts +0 -7
- package/utilities/common/incrementalResult.js +0 -38
- package/utilities/common/incrementalResult.js.map +0 -1
- package/utilities/common/makeUniqueId.d.ts +0 -2
- package/utilities/common/makeUniqueId.js +0 -9
- package/utilities/common/makeUniqueId.js.map +0 -1
- package/utilities/common/maybeDeepFreeze.d.ts +0 -4
- package/utilities/common/maybeDeepFreeze.js.map +0 -1
- package/utilities/common/mergeDeep.d.ts +0 -14
- package/utilities/common/mergeDeep.js.map +0 -1
- package/utilities/common/mergeOptions.js.map +0 -1
- package/utilities/common/objects.d.ts +0 -3
- package/utilities/common/objects.js.map +0 -1
- package/utilities/common/omitDeep.d.ts +0 -3
- package/utilities/common/omitDeep.js.map +0 -1
- package/utilities/common/stringifyForDisplay.d.ts +0 -2
- package/utilities/common/stringifyForDisplay.js.map +0 -1
- package/utilities/globals/global.js.map +0 -1
- package/utilities/globals/index.js.map +0 -1
- package/utilities/globals/maybe.js.map +0 -1
- package/utilities/graphql/directives.d.ts +0 -20
- package/utilities/graphql/directives.js +0 -99
- package/utilities/graphql/directives.js.map +0 -1
- package/utilities/graphql/fragments.d.ts +0 -35
- package/utilities/graphql/fragments.js.map +0 -1
- package/utilities/graphql/getFromAST.d.ts +0 -15
- package/utilities/graphql/getFromAST.js +0 -91
- package/utilities/graphql/getFromAST.js.map +0 -1
- package/utilities/internal/observables.js.map +0 -1
- package/utilities/promises/decoration.d.ts +0 -18
- package/utilities/promises/decoration.js.map +0 -1
- package/utilities/types/DeepPartial.js.map +0 -1
- package/utilities/types/IsStrictlyAny.d.ts +0 -5
- package/utilities/types/IsStrictlyAny.js +0 -2
- package/utilities/types/IsStrictlyAny.js.map +0 -1
- package/utilities/types/Prettify.d.ts +0 -4
- package/utilities/types/Primitive.d.ts +0 -2
- package/utilities/types/UnionToIntersection.d.ts +0 -2
- package/utilities/types/UnionToIntersection.js +0 -2
- package/utilities/types/UnionToIntersection.js.map +0 -1
- /package/__cjs/utilities/{globals → internal/globals}/global.cjs +0 -0
- /package/__cjs/utilities/{globals → internal/globals}/global.d.cts +0 -0
- /package/__cjs/utilities/{globals → internal/globals}/index.cjs +0 -0
- /package/__cjs/utilities/{globals → internal/globals}/index.d.cts +0 -0
- /package/__cjs/utilities/{globals → internal/globals}/maybe.cjs +0 -0
- /package/__cjs/utilities/{globals → internal/globals}/maybe.d.cts +0 -0
- /package/__cjs/utilities/{promises → internal}/preventUnhandledRejection.cjs +0 -0
- /package/__cjs/utilities/{promises → internal}/preventUnhandledRejection.d.cts +0 -0
- /package/__cjs/utilities/{types → internal/types}/DeepOmit.cjs +0 -0
- /package/__cjs/utilities/{types → internal/types}/DeepOmit.cjs.map +0 -0
- /package/__cjs/utilities/{types → internal/types}/DeepPartial.cjs +0 -0
- /package/__cjs/utilities/{types → internal/types}/NoInfer.cjs +0 -0
- /package/__cjs/utilities/{types → internal/types}/NoInfer.cjs.map +0 -0
- /package/__cjs/utilities/{types → internal/types}/Prettify.cjs +0 -0
- /package/__cjs/utilities/{types → internal/types}/Prettify.cjs.map +0 -0
- /package/__cjs/utilities/{types → internal/types}/Primitive.cjs +0 -0
- /package/__cjs/utilities/{types → internal/types}/Primitive.cjs.map +0 -0
- /package/__cjs/utilities/{types → internal/types}/RemoveIndexSignature.cjs +0 -0
- /package/__cjs/utilities/{types → internal/types}/RemoveIndexSignature.cjs.map +0 -0
- /package/__cjs/utilities/{types → internal/types}/VariablesOption.cjs +0 -0
- /package/__cjs/utilities/{types → internal/types}/VariablesOption.cjs.map +0 -0
- /package/__cjs/utilities/{common → shared}/canonicalStringify.d.cts +0 -0
- /package/utilities/{globals → internal/globals}/global.d.ts +0 -0
- /package/utilities/{globals → internal/globals}/index.d.ts +0 -0
- /package/utilities/{globals → internal/globals}/index.js +0 -0
- /package/utilities/{globals → internal/globals}/maybe.d.ts +0 -0
- /package/utilities/{globals → internal/globals}/maybe.js +0 -0
- /package/utilities/{promises → internal}/preventUnhandledRejection.d.ts +0 -0
- /package/utilities/{promises → internal}/preventUnhandledRejection.js +0 -0
- /package/utilities/{types → internal/types}/DeepOmit.js +0 -0
- /package/utilities/{types → internal/types}/DeepOmit.js.map +0 -0
- /package/utilities/{types → internal/types}/DeepPartial.js +0 -0
- /package/utilities/{types → internal/types}/NoInfer.js +0 -0
- /package/utilities/{types → internal/types}/NoInfer.js.map +0 -0
- /package/utilities/{types → internal/types}/Prettify.js +0 -0
- /package/utilities/{types → internal/types}/Prettify.js.map +0 -0
- /package/utilities/{types → internal/types}/Primitive.js +0 -0
- /package/utilities/{types → internal/types}/Primitive.js.map +0 -0
- /package/utilities/{types → internal/types}/RemoveIndexSignature.js +0 -0
- /package/utilities/{types → internal/types}/RemoveIndexSignature.js.map +0 -0
- /package/utilities/{types → internal/types}/VariablesOption.js +0 -0
- /package/utilities/{types → internal/types}/VariablesOption.js.map +0 -0
- /package/utilities/{common → shared}/canonicalStringify.d.ts +0 -0
package/core/ObservableQuery.js
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import { equal } from "@wry/equality";
|
|
2
2
|
import { Slot } from "optimism";
|
|
3
|
-
import { BehaviorSubject,
|
|
4
|
-
import { cloneDeep, compact, getOperationDefinition, getQueryDefinition, preventUnhandledRejection, } from "@apollo/client/utilities";
|
|
3
|
+
import { BehaviorSubject, lastValueFrom, Observable, Subject, tap } from "rxjs";
|
|
5
4
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
6
|
-
import { toQueryResult } from "@apollo/client/utilities/internal";
|
|
5
|
+
import { compact, filterMap, getOperationDefinition, getQueryDefinition, preventUnhandledRejection, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
7
6
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
8
7
|
import { equalByQuery } from "./equalByQuery.js";
|
|
9
8
|
import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
|
|
10
9
|
const { assign, hasOwnProperty } = Object;
|
|
11
10
|
const newNetworkStatusSymbol = Symbol();
|
|
12
|
-
const uninitialized = {
|
|
11
|
+
const uninitialized = {
|
|
12
|
+
loading: true,
|
|
13
|
+
networkStatus: NetworkStatus.loading,
|
|
14
|
+
data: undefined,
|
|
15
|
+
partial: true,
|
|
16
|
+
};
|
|
17
|
+
const empty = {
|
|
18
|
+
loading: false,
|
|
19
|
+
networkStatus: NetworkStatus.ready,
|
|
20
|
+
data: undefined,
|
|
21
|
+
partial: true,
|
|
22
|
+
};
|
|
13
23
|
export class ObservableQuery {
|
|
14
24
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
* @internal
|
|
26
|
+
* A slot used by the `useQuery` hook to indicate that `client.watchQuery`
|
|
27
|
+
* should not register the query immediately, but instead wait for the query to
|
|
28
|
+
* be started registered with the `QueryManager` when `useSyncExternalStore`
|
|
29
|
+
* actively subscribes to it.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
32
|
+
*/
|
|
21
33
|
static inactiveOnCreation = new Slot();
|
|
22
34
|
options;
|
|
23
35
|
queryId;
|
|
@@ -35,23 +47,58 @@ export class ObservableQuery {
|
|
|
35
47
|
get variables() {
|
|
36
48
|
return this.options.variables;
|
|
37
49
|
}
|
|
50
|
+
unsubscribeFromCache;
|
|
51
|
+
input;
|
|
38
52
|
subject;
|
|
39
53
|
observable;
|
|
40
54
|
isTornDown;
|
|
41
55
|
queryManager;
|
|
42
56
|
subscriptions = new Set();
|
|
43
|
-
|
|
44
|
-
|
|
57
|
+
/**
|
|
58
|
+
* If an `ObservableQuery` is created with a `network-only` fetch policy,
|
|
59
|
+
* it should actually start receiving cache updates, but not before it has
|
|
60
|
+
* received the first result from the network.
|
|
61
|
+
*/
|
|
62
|
+
waitForNetworkResult;
|
|
45
63
|
lastQuery;
|
|
46
64
|
queryInfo;
|
|
47
65
|
linkSubscription;
|
|
48
|
-
linkObservable;
|
|
49
66
|
pollingInfo;
|
|
50
|
-
networkStatus
|
|
67
|
+
get networkStatus() {
|
|
68
|
+
return this.subject.getValue().result.networkStatus;
|
|
69
|
+
}
|
|
51
70
|
constructor({ queryManager, queryInfo, options, }) {
|
|
52
|
-
this.networkStatus = NetworkStatus.loading;
|
|
53
71
|
let startedInactive = ObservableQuery.inactiveOnCreation.getValue();
|
|
54
|
-
|
|
72
|
+
// related classes
|
|
73
|
+
this.queryInfo = queryInfo;
|
|
74
|
+
this.queryManager = queryManager;
|
|
75
|
+
// active state
|
|
76
|
+
this.waitForNetworkResult = options.fetchPolicy === "network-only";
|
|
77
|
+
this.isTornDown = false;
|
|
78
|
+
this.subscribeToMore = this.subscribeToMore.bind(this);
|
|
79
|
+
this.maskResult = this.maskResult.bind(this);
|
|
80
|
+
const { watchQuery: { fetchPolicy: defaultFetchPolicy = "cache-first" } = {}, } = queryManager.defaultOptions;
|
|
81
|
+
const { fetchPolicy = defaultFetchPolicy,
|
|
82
|
+
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
83
|
+
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
84
|
+
this.lastQuery = options.query;
|
|
85
|
+
this.options = {
|
|
86
|
+
...options,
|
|
87
|
+
// Remember the initial options.fetchPolicy so we can revert back to this
|
|
88
|
+
// policy when variables change. This information can also be specified
|
|
89
|
+
// (or overridden) by providing options.initialFetchPolicy explicitly.
|
|
90
|
+
initialFetchPolicy,
|
|
91
|
+
// This ensures this.options.fetchPolicy always has a string value, in
|
|
92
|
+
// case options.fetchPolicy was not provided.
|
|
93
|
+
fetchPolicy,
|
|
94
|
+
variables: this.getVariablesWithDefaults(options.variables),
|
|
95
|
+
};
|
|
96
|
+
this.subject = new BehaviorSubject({
|
|
97
|
+
query: this.query,
|
|
98
|
+
variables: this.variables,
|
|
99
|
+
result: uninitialized,
|
|
100
|
+
meta: {},
|
|
101
|
+
});
|
|
55
102
|
this.observable = this.subject.pipe(tap({
|
|
56
103
|
subscribe: () => {
|
|
57
104
|
if (startedInactive) {
|
|
@@ -59,22 +106,6 @@ export class ObservableQuery {
|
|
|
59
106
|
startedInactive = false;
|
|
60
107
|
}
|
|
61
108
|
if (!this.subject.observed) {
|
|
62
|
-
if (this.subject.value === uninitialized) {
|
|
63
|
-
// Emitting a value in the `subscribe` callback of `tap` gives
|
|
64
|
-
// the subject a chance to save this initial result without
|
|
65
|
-
// emitting the placeholder value since this callback is executed
|
|
66
|
-
// before `tap` subscribes to the source observable (the subject).
|
|
67
|
-
// `reobserve` also has the chance to update this value if it
|
|
68
|
-
// synchronously emits one (usually due to reporting a cache
|
|
69
|
-
// value).
|
|
70
|
-
//
|
|
71
|
-
// We don't initialize the `BehaviorSubject` with
|
|
72
|
-
// `getInitialResult` because its possible the cache might have
|
|
73
|
-
// updated between when the `ObservableQuery` was instantiated and
|
|
74
|
-
// when it is subscribed to. Updating the value here ensures we
|
|
75
|
-
// report the most up-to-date result from the cache.
|
|
76
|
-
this.subject.next(this.getInitialResult());
|
|
77
|
-
}
|
|
78
109
|
this.reobserve();
|
|
79
110
|
// TODO: See if we can rework updatePolling to better handle this.
|
|
80
111
|
// reobserve calls updatePolling but this `subscribe` callback is
|
|
@@ -89,45 +120,53 @@ export class ObservableQuery {
|
|
|
89
120
|
this.tearDownQuery();
|
|
90
121
|
}
|
|
91
122
|
},
|
|
92
|
-
}),
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
123
|
+
}), filterMap(({ query, variables, result: current, meta }, context) => {
|
|
124
|
+
const { shouldEmit } = meta;
|
|
125
|
+
if (current === uninitialized) {
|
|
126
|
+
// reset internal state after `ObservableQuery.reset()`
|
|
127
|
+
context.previous = undefined;
|
|
128
|
+
context.previousVariables = undefined;
|
|
129
|
+
}
|
|
130
|
+
if (this.options.fetchPolicy === "standby" ||
|
|
131
|
+
shouldEmit === 2 /* EmitBehavior.never */)
|
|
132
|
+
return;
|
|
133
|
+
if (shouldEmit === 1 /* EmitBehavior.force */)
|
|
134
|
+
return emit();
|
|
135
|
+
const { previous, previousVariables } = context;
|
|
136
|
+
if (previous) {
|
|
137
|
+
const documentInfo = this.queryManager.getDocumentInfo(query);
|
|
138
|
+
const dataMasking = this.queryManager.dataMasking;
|
|
139
|
+
const maskedQuery = dataMasking ? documentInfo.nonReactiveQuery : query;
|
|
140
|
+
const resultIsEqual = dataMasking || documentInfo.hasNonreactiveDirective ?
|
|
141
|
+
equalByQuery(maskedQuery, previous, current, variables)
|
|
142
|
+
: equal(previous, current);
|
|
143
|
+
if (resultIsEqual && equal(previousVariables, variables)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (shouldEmit === 3 /* EmitBehavior.networkStatusChange */ &&
|
|
148
|
+
(!this.options.notifyOnNetworkStatusChange ||
|
|
149
|
+
equal(previous, current))) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
return emit();
|
|
153
|
+
function emit() {
|
|
154
|
+
context.previous = current;
|
|
155
|
+
context.previousVariables = variables;
|
|
156
|
+
return current;
|
|
157
|
+
}
|
|
158
|
+
}, () => ({})));
|
|
100
159
|
this["@@observable"] = () => this;
|
|
101
160
|
if (Symbol.observable) {
|
|
102
161
|
this[Symbol.observable] = () => this;
|
|
103
162
|
}
|
|
104
163
|
this.pipe = this.observable.pipe.bind(this.observable);
|
|
105
164
|
this.subscribe = this.observable.subscribe.bind(this.observable);
|
|
106
|
-
|
|
107
|
-
this.
|
|
108
|
-
this.
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
this.isTornDown = false;
|
|
112
|
-
this.subscribe = this.subscribe.bind(this);
|
|
113
|
-
this.subscribeToMore = this.subscribeToMore.bind(this);
|
|
114
|
-
this.maskResult = this.maskResult.bind(this);
|
|
115
|
-
const { watchQuery: { fetchPolicy: defaultFetchPolicy = "cache-first" } = {}, } = queryManager.defaultOptions;
|
|
116
|
-
const { fetchPolicy = defaultFetchPolicy,
|
|
117
|
-
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
118
|
-
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
119
|
-
this.lastQuery = options.query;
|
|
120
|
-
this.options = {
|
|
121
|
-
...options,
|
|
122
|
-
// Remember the initial options.fetchPolicy so we can revert back to this
|
|
123
|
-
// policy when variables change. This information can also be specified
|
|
124
|
-
// (or overridden) by providing options.initialFetchPolicy explicitly.
|
|
125
|
-
initialFetchPolicy,
|
|
126
|
-
// This ensures this.options.fetchPolicy always has a string value, in
|
|
127
|
-
// case options.fetchPolicy was not provided.
|
|
128
|
-
fetchPolicy,
|
|
129
|
-
variables: this.getVariablesWithDefaults(options.variables),
|
|
130
|
-
};
|
|
165
|
+
this.input = new Subject();
|
|
166
|
+
// we want to feed many streams into `this.subject`, but none of them should
|
|
167
|
+
// be able to close `this.input`
|
|
168
|
+
this.input.complete = () => { };
|
|
169
|
+
this.input.pipe(this.operator).subscribe(this.subject);
|
|
131
170
|
this.queryId = queryInfo.queryId || queryManager.generateQueryId();
|
|
132
171
|
const opDef = getOperationDefinition(this.query);
|
|
133
172
|
this.queryName = opDef && opDef.name && opDef.name.value;
|
|
@@ -139,14 +178,26 @@ export class ObservableQuery {
|
|
|
139
178
|
pipe;
|
|
140
179
|
[Symbol.observable];
|
|
141
180
|
["@@observable"];
|
|
142
|
-
/**
|
|
181
|
+
/**
|
|
182
|
+
* @internal
|
|
183
|
+
*
|
|
184
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
185
|
+
*/
|
|
143
186
|
resetDiff() {
|
|
144
187
|
this.queryInfo.resetDiff();
|
|
145
188
|
}
|
|
146
|
-
|
|
189
|
+
getCacheDiff({ optimistic = true } = {}) {
|
|
190
|
+
return this.queryManager.cache.diff({
|
|
191
|
+
query: this.query,
|
|
192
|
+
variables: this.variables,
|
|
193
|
+
returnPartialData: true,
|
|
194
|
+
optimistic,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
getInitialResult(initialFetchPolicy) {
|
|
147
198
|
const fetchPolicy = this.queryManager.prioritizeCacheValues ?
|
|
148
199
|
"cache-first"
|
|
149
|
-
: this.options.fetchPolicy;
|
|
200
|
+
: initialFetchPolicy || this.options.fetchPolicy;
|
|
150
201
|
const defaultResult = {
|
|
151
202
|
data: undefined,
|
|
152
203
|
loading: true,
|
|
@@ -154,7 +205,7 @@ export class ObservableQuery {
|
|
|
154
205
|
partial: true,
|
|
155
206
|
};
|
|
156
207
|
const cacheResult = () => {
|
|
157
|
-
const diff = this.
|
|
208
|
+
const diff = this.getCacheDiff();
|
|
158
209
|
return this.maskResult({
|
|
159
210
|
data:
|
|
160
211
|
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
@@ -177,128 +228,101 @@ export class ObservableQuery {
|
|
|
177
228
|
loading: true,
|
|
178
229
|
networkStatus: NetworkStatus.loading,
|
|
179
230
|
};
|
|
180
|
-
case "standby":
|
|
181
|
-
return {
|
|
182
|
-
...defaultResult,
|
|
183
|
-
loading: false,
|
|
184
|
-
networkStatus: NetworkStatus.ready,
|
|
185
|
-
};
|
|
186
231
|
default:
|
|
187
232
|
return defaultResult;
|
|
188
233
|
}
|
|
189
234
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
};
|
|
201
|
-
let { fetchPolicy = "cache-first" } = this.options;
|
|
202
|
-
const { prioritizeCacheValues } = this.queryManager;
|
|
203
|
-
if (prioritizeCacheValues) {
|
|
204
|
-
fetchPolicy = "cache-first";
|
|
205
|
-
}
|
|
206
|
-
if (
|
|
207
|
-
// These fetch policies should never deliver data from the cache, unless
|
|
208
|
-
// redelivering a previously delivered result.
|
|
209
|
-
skipCacheDataFor(fetchPolicy) ||
|
|
210
|
-
// If this.options.query has @client(always: true) fields, we cannot
|
|
211
|
-
// trust diff.result, since it was read from the cache without running
|
|
212
|
-
// local resolvers (and it's too late to run resolvers now, since we must
|
|
213
|
-
// return a result synchronously).
|
|
214
|
-
this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) {
|
|
215
|
-
// Fall through.
|
|
216
|
-
}
|
|
217
|
-
else if (this.waitForOwnResult && !prioritizeCacheValues) {
|
|
218
|
-
// This would usually be a part of `QueryInfo.getDiff()`.
|
|
219
|
-
// which we skip in the waitForOwnResult case since we are not
|
|
220
|
-
// interested in the diff.
|
|
221
|
-
this.queryInfo["updateWatch"]();
|
|
235
|
+
resubscribeCache() {
|
|
236
|
+
const { variables, fetchPolicy } = this.options;
|
|
237
|
+
const query = this.query;
|
|
238
|
+
const shouldUnsubscribe = fetchPolicy === "standby" ||
|
|
239
|
+
fetchPolicy === "no-cache" ||
|
|
240
|
+
this.waitForNetworkResult;
|
|
241
|
+
const shouldResubscribe = !isEqualQuery({ query, variables }, this.unsubscribeFromCache) &&
|
|
242
|
+
!this.waitForNetworkResult;
|
|
243
|
+
if (shouldUnsubscribe || shouldResubscribe) {
|
|
244
|
+
this.unsubscribeFromCache?.();
|
|
222
245
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
246
|
+
if (shouldUnsubscribe || !shouldResubscribe) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const watch = {
|
|
250
|
+
query,
|
|
251
|
+
variables,
|
|
252
|
+
optimistic: true,
|
|
253
|
+
watcher: this,
|
|
254
|
+
callback: (diff) => {
|
|
255
|
+
const info = this.queryManager.getDocumentInfo(query);
|
|
256
|
+
if (info.hasClientExports || info.hasForcedResolvers) {
|
|
257
|
+
// If this is not set to something different than `diff`, we will
|
|
258
|
+
// not be notified about future cache changes with an equal `diff`.
|
|
259
|
+
// That would be the case if we are working with client-only fields
|
|
260
|
+
// that are forced or with `exports` fields that might change, causing
|
|
261
|
+
// local resovlers to return a new result.
|
|
262
|
+
// This is based on an implementation detail of `InMemoryCache`, which
|
|
263
|
+
// is not optimal - but the only alternative to this would be to
|
|
264
|
+
// resubscribe to the cache asynchonouly, which would bear the risk of
|
|
265
|
+
// missing further synchronous updates.
|
|
266
|
+
watch.lastDiff = undefined;
|
|
241
267
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
268
|
+
if (watch.lastOwnDiff === diff) {
|
|
269
|
+
// skip cache updates that were caused by our own writes
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const { result: previousResult } = this.subject.getValue();
|
|
273
|
+
if (!diff.complete &&
|
|
274
|
+
// If we are trying to deliver an incomplete cache result, we avoid
|
|
275
|
+
// reporting it if the query has errored, otherwise we let the broadcast try
|
|
276
|
+
// and repair the partial result by refetching the query. This check avoids
|
|
277
|
+
// a situation where a query that errors and another succeeds with
|
|
278
|
+
// overlapping data does not report the partial data result to the errored
|
|
279
|
+
// query.
|
|
280
|
+
//
|
|
281
|
+
// See https://github.com/apollographql/apollo-client/issues/11400 for more
|
|
282
|
+
// information on this issue.
|
|
283
|
+
(previousResult.error ||
|
|
284
|
+
// Prevent to schedule a notify directly after the `ObservableQuery`
|
|
285
|
+
// has been `reset` (which will set the `previousResult` to `uninitialized` or `empty`)
|
|
286
|
+
// as in those cases, `resetCache` will manually call `refetch` with more intentional timing.
|
|
287
|
+
previousResult === uninitialized ||
|
|
288
|
+
previousResult === empty)) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (!equal(previousResult.data, diff.result)) {
|
|
292
|
+
this.scheduleNotify();
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
const cancelWatch = this.queryManager.cache.watch(watch);
|
|
297
|
+
this.unsubscribeFromCache = Object.assign(() => {
|
|
298
|
+
this.unsubscribeFromCache = undefined;
|
|
299
|
+
cancelWatch();
|
|
300
|
+
}, { query, variables });
|
|
301
|
+
}
|
|
302
|
+
stableLastResult;
|
|
303
|
+
getCurrentResult() {
|
|
304
|
+
const { result: current } = this.subject.getValue();
|
|
305
|
+
let value = (
|
|
306
|
+
// if the `current` result is in an error state, we will always return that
|
|
307
|
+
// error state, even if we have no observers
|
|
308
|
+
(current.networkStatus === NetworkStatus.error ||
|
|
309
|
+
// if we have observers, we are watching the cache and
|
|
310
|
+
// this.subject.getValue() will always be up to date
|
|
311
|
+
this.hasObservers() || // if we are using a `no-cache` fetch policy in which case this
|
|
312
|
+
// `ObservableQuery` cannot have been updated from the outside - in
|
|
313
|
+
// that case, we prefer to keep the current value
|
|
314
|
+
this.options.fetchPolicy === "no-cache")) ?
|
|
315
|
+
current
|
|
316
|
+
// otherwise, the `current` value might be outdated due to missed
|
|
317
|
+
// external updates - calculate it again
|
|
318
|
+
: this.getInitialResult();
|
|
319
|
+
if (value === uninitialized) {
|
|
320
|
+
value = this.getInitialResult();
|
|
257
321
|
}
|
|
258
|
-
if (
|
|
259
|
-
this.
|
|
260
|
-
}
|
|
261
|
-
return
|
|
262
|
-
}
|
|
263
|
-
getCurrentResult(saveAsLastResult = true) {
|
|
264
|
-
return this.maskResult(this.getCurrentFullResult(saveAsLastResult));
|
|
265
|
-
}
|
|
266
|
-
// Compares newResult to the snapshot we took of this.lastResult when it was
|
|
267
|
-
// first received.
|
|
268
|
-
isDifferentFromLastResult(newResult, variables) {
|
|
269
|
-
if (!this.last) {
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
const documentInfo = this.queryManager.getDocumentInfo(this.query);
|
|
273
|
-
const dataMasking = this.queryManager.dataMasking;
|
|
274
|
-
const query = dataMasking ? documentInfo.nonReactiveQuery : this.query;
|
|
275
|
-
const resultIsDifferent = dataMasking || documentInfo.hasNonreactiveDirective ?
|
|
276
|
-
!equalByQuery(query, this.last.result, newResult, this.variables)
|
|
277
|
-
: !equal(this.last.result, newResult);
|
|
278
|
-
return (resultIsDifferent || (variables && !equal(this.last.variables, variables)));
|
|
279
|
-
}
|
|
280
|
-
getLast(key, variablesMustMatch) {
|
|
281
|
-
const last = this.last;
|
|
282
|
-
if (last &&
|
|
283
|
-
last[key] &&
|
|
284
|
-
(!variablesMustMatch || equal(last.variables, this.variables))) {
|
|
285
|
-
return last[key];
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
// TODO: Consider deprecating this function
|
|
289
|
-
getLastResult(variablesMustMatch) {
|
|
290
|
-
return this.getLast("result", variablesMustMatch);
|
|
291
|
-
}
|
|
292
|
-
// TODO: Consider deprecating this function
|
|
293
|
-
getLastError(variablesMustMatch) {
|
|
294
|
-
return this.getLast("error", variablesMustMatch);
|
|
295
|
-
}
|
|
296
|
-
// TODO: Consider deprecating this function
|
|
297
|
-
resetLastResults() {
|
|
298
|
-
delete this.last;
|
|
299
|
-
// TODO: This will need to be removed when tearing down an ObservableQuery
|
|
300
|
-
// since the observable will terminate.
|
|
301
|
-
this.isTornDown = false;
|
|
322
|
+
if (!equal(this.stableLastResult, value)) {
|
|
323
|
+
this.stableLastResult = value;
|
|
324
|
+
}
|
|
325
|
+
return this.stableLastResult;
|
|
302
326
|
}
|
|
303
327
|
/**
|
|
304
328
|
* Update the variables of this observable query, and fetch the new results.
|
|
@@ -326,7 +350,7 @@ export class ObservableQuery {
|
|
|
326
350
|
const queryDef = getQueryDefinition(this.query);
|
|
327
351
|
const vars = queryDef.variableDefinitions;
|
|
328
352
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
329
|
-
__DEV__ && invariant.warn(
|
|
353
|
+
__DEV__ && invariant.warn(77, variables, queryDef.name?.value || queryDef);
|
|
330
354
|
}
|
|
331
355
|
}
|
|
332
356
|
if (variables && !equal(this.variables, variables)) {
|
|
@@ -373,26 +397,27 @@ export class ObservableQuery {
|
|
|
373
397
|
fetchMoreOptions.query ?
|
|
374
398
|
this.transformDocument(this.options.query)
|
|
375
399
|
: combinedOptions.query;
|
|
376
|
-
|
|
377
|
-
// result.networkStatus === NetworkStatus.fetchMore.
|
|
378
|
-
const originalNetworkStatus = this.networkStatus;
|
|
379
|
-
this.networkStatus = NetworkStatus.fetchMore;
|
|
380
|
-
if (combinedOptions.notifyOnNetworkStatusChange) {
|
|
381
|
-
this.observe();
|
|
382
|
-
}
|
|
383
|
-
const updatedQuerySet = new Set();
|
|
400
|
+
let wasUpdated = false;
|
|
384
401
|
const updateQuery = fetchMoreOptions?.updateQuery;
|
|
385
402
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
386
403
|
if (!isCached) {
|
|
387
|
-
invariant(updateQuery,
|
|
404
|
+
invariant(updateQuery, 78);
|
|
388
405
|
}
|
|
406
|
+
const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
|
|
407
|
+
pushNotification({
|
|
408
|
+
source: "newNetworkStatus",
|
|
409
|
+
kind: "N",
|
|
410
|
+
value: {},
|
|
411
|
+
}, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
|
|
389
412
|
return this.queryManager
|
|
390
413
|
.fetchQuery(qid, combinedOptions, NetworkStatus.fetchMore)
|
|
391
414
|
.then((fetchMoreResult) => {
|
|
392
415
|
this.queryManager.removeQuery(qid);
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
416
|
+
// disable the `fetchMore` override that is currently active
|
|
417
|
+
// the next updates caused by this should not be `fetchMore` anymore,
|
|
418
|
+
// but `ready` or whatever other calculated loading state is currently
|
|
419
|
+
// appropriate
|
|
420
|
+
finalize();
|
|
396
421
|
if (isCached) {
|
|
397
422
|
// Performing this cache update inside a cache.batch transaction ensures
|
|
398
423
|
// any affected cache.watch watchers are notified at most once about any
|
|
@@ -427,9 +452,9 @@ export class ObservableQuery {
|
|
|
427
452
|
}
|
|
428
453
|
},
|
|
429
454
|
onWatchUpdated: (watch) => {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
455
|
+
if (watch.watcher === this) {
|
|
456
|
+
wasUpdated = true;
|
|
457
|
+
}
|
|
433
458
|
},
|
|
434
459
|
});
|
|
435
460
|
}
|
|
@@ -448,28 +473,40 @@ export class ObservableQuery {
|
|
|
448
473
|
// adjustment to the types on `updateQuery` since that function
|
|
449
474
|
// expects that the first argument always contains previous result
|
|
450
475
|
// data, but not `undefined`.
|
|
451
|
-
const lastResult = this.
|
|
476
|
+
const lastResult = this.getCurrentResult();
|
|
452
477
|
const data = updateQuery(lastResult.data, {
|
|
453
478
|
fetchMoreResult: fetchMoreResult.data,
|
|
454
479
|
variables: combinedOptions.variables,
|
|
455
480
|
});
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
481
|
+
// was reportResult
|
|
482
|
+
pushNotification({
|
|
483
|
+
kind: "N",
|
|
484
|
+
value: {
|
|
485
|
+
...lastResult,
|
|
486
|
+
networkStatus: NetworkStatus.ready,
|
|
487
|
+
// will be overwritten anyways, just here for types sake
|
|
488
|
+
loading: false,
|
|
489
|
+
data: data,
|
|
490
|
+
},
|
|
491
|
+
source: "network",
|
|
492
|
+
});
|
|
462
493
|
}
|
|
463
494
|
return this.maskResult(fetchMoreResult);
|
|
464
495
|
})
|
|
465
496
|
.finally(() => {
|
|
497
|
+
// call `finalize` a second time in case the `.then` case above was not reached
|
|
498
|
+
finalize();
|
|
466
499
|
// In case the cache writes above did not generate a broadcast
|
|
467
500
|
// notification (which would have been intercepted by onWatchUpdated),
|
|
468
501
|
// likely because the written data were the same as what was already in
|
|
469
502
|
// the cache, we still want fetchMore to deliver its final loading:false
|
|
470
503
|
// result with the unchanged data.
|
|
471
|
-
if (isCached && !
|
|
472
|
-
|
|
504
|
+
if (isCached && !wasUpdated) {
|
|
505
|
+
pushNotification({
|
|
506
|
+
kind: "N",
|
|
507
|
+
source: "newNetworkStatus",
|
|
508
|
+
value: {},
|
|
509
|
+
}, { shouldEmit: 1 /* EmitBehavior.force */ });
|
|
473
510
|
}
|
|
474
511
|
});
|
|
475
512
|
}
|
|
@@ -497,7 +534,7 @@ export class ObservableQuery {
|
|
|
497
534
|
onError(error);
|
|
498
535
|
}
|
|
499
536
|
else {
|
|
500
|
-
__DEV__ && invariant.error(
|
|
537
|
+
__DEV__ && invariant.error(79, error);
|
|
501
538
|
}
|
|
502
539
|
return;
|
|
503
540
|
}
|
|
@@ -516,7 +553,11 @@ export class ObservableQuery {
|
|
|
516
553
|
}
|
|
517
554
|
};
|
|
518
555
|
}
|
|
519
|
-
/**
|
|
556
|
+
/**
|
|
557
|
+
* @internal
|
|
558
|
+
*
|
|
559
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
560
|
+
*/
|
|
520
561
|
silentSetOptions(newOptions) {
|
|
521
562
|
const mergedOptions = compact(this.options, newOptions || {});
|
|
522
563
|
assign(this.options, mergedOptions);
|
|
@@ -545,12 +586,12 @@ export class ObservableQuery {
|
|
|
545
586
|
// If we have no observers, then we don't actually want to make a network
|
|
546
587
|
// request. As soon as someone observes the query, the request will kick
|
|
547
588
|
// off. For now, we just store any changes. (See #1077)
|
|
548
|
-
return toQueryResult(this.
|
|
589
|
+
return toQueryResult(this.getCurrentResult());
|
|
549
590
|
}
|
|
550
591
|
this.options.variables = variables;
|
|
551
592
|
// See comment above
|
|
552
593
|
if (!this.hasObservers()) {
|
|
553
|
-
return toQueryResult(this.
|
|
594
|
+
return toQueryResult(this.getCurrentResult());
|
|
554
595
|
}
|
|
555
596
|
return this.reobserve({
|
|
556
597
|
// Reset options.fetchPolicy to its original value.
|
|
@@ -566,12 +607,7 @@ export class ObservableQuery {
|
|
|
566
607
|
*/
|
|
567
608
|
updateQuery(mapFn) {
|
|
568
609
|
const { queryManager } = this;
|
|
569
|
-
const { result, complete } =
|
|
570
|
-
query: this.options.query,
|
|
571
|
-
variables: this.variables,
|
|
572
|
-
returnPartialData: true,
|
|
573
|
-
optimistic: false,
|
|
574
|
-
});
|
|
610
|
+
const { result, complete } = this.getCacheDiff({ optimistic: false });
|
|
575
611
|
const newResult = mapFn(result, {
|
|
576
612
|
variables: this.variables,
|
|
577
613
|
complete: !!complete,
|
|
@@ -634,12 +670,95 @@ export class ObservableQuery {
|
|
|
634
670
|
}
|
|
635
671
|
return options.fetchPolicy;
|
|
636
672
|
}
|
|
637
|
-
fetch(options,
|
|
673
|
+
fetch(options, networkStatus, fetchQuery) {
|
|
638
674
|
// TODO Make sure we update the networkStatus (and infer fetchVariables)
|
|
639
675
|
// before actually committing to the fetch.
|
|
676
|
+
const initialFetchPolicy = this.options.fetchPolicy;
|
|
640
677
|
const queryInfo = this.queryManager.getOrCreateQuery(this.queryId);
|
|
641
678
|
queryInfo.setObservableQuery(this);
|
|
642
|
-
|
|
679
|
+
options.context ??= {};
|
|
680
|
+
let synchronouslyEmitted = false;
|
|
681
|
+
const onCacheHit = () => {
|
|
682
|
+
synchronouslyEmitted = true;
|
|
683
|
+
};
|
|
684
|
+
const fetchQueryOperator = // we cannot use `tap` here, since it allows only for a "before subscription"
|
|
685
|
+
|
|
686
|
+
// hook with `subscribe` and we care for "directly before and after subscription"
|
|
687
|
+
(source) => new Observable((subscriber) => {
|
|
688
|
+
try {
|
|
689
|
+
return source.subscribe({
|
|
690
|
+
next(value) {
|
|
691
|
+
synchronouslyEmitted = true;
|
|
692
|
+
subscriber.next(value);
|
|
693
|
+
},
|
|
694
|
+
error: (error) => subscriber.error(error),
|
|
695
|
+
complete: () => subscriber.complete(),
|
|
696
|
+
});
|
|
697
|
+
}
|
|
698
|
+
finally {
|
|
699
|
+
if (!synchronouslyEmitted && this.activeOperations.has(operation)) {
|
|
700
|
+
operation.override = networkStatus;
|
|
701
|
+
this.input.next({
|
|
702
|
+
kind: "N",
|
|
703
|
+
source: "newNetworkStatus",
|
|
704
|
+
value: {
|
|
705
|
+
resetError: true,
|
|
706
|
+
},
|
|
707
|
+
query,
|
|
708
|
+
variables,
|
|
709
|
+
meta: {
|
|
710
|
+
shouldEmit: 3 /* EmitBehavior.networkStatusChange */,
|
|
711
|
+
/*
|
|
712
|
+
* The moment this notification is emitted, `nextFetchPolicy`
|
|
713
|
+
* might already have switched from a `network-only` to a
|
|
714
|
+
* `cache-something` policy, so we want to ensure that the
|
|
715
|
+
* loading state emit doesn't accidentally read from the cache
|
|
716
|
+
* in those cases.
|
|
717
|
+
*/
|
|
718
|
+
fetchPolicy: initialFetchPolicy,
|
|
719
|
+
},
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
});
|
|
724
|
+
const { observable, fromLink } = this.queryManager.fetchObservableWithInfo(queryInfo, options, { networkStatus, query: fetchQuery, onCacheHit, fetchQueryOperator });
|
|
725
|
+
// track query and variables from the start of the operation
|
|
726
|
+
const { query, variables } = this;
|
|
727
|
+
const operation = {
|
|
728
|
+
abort: () => subscription.unsubscribe(),
|
|
729
|
+
query,
|
|
730
|
+
variables,
|
|
731
|
+
};
|
|
732
|
+
this.activeOperations.add(operation);
|
|
733
|
+
let forceFirstValueEmit = networkStatus == NetworkStatus.refetch ||
|
|
734
|
+
networkStatus == NetworkStatus.setVariables;
|
|
735
|
+
const subscription = observable
|
|
736
|
+
.pipe(tap({
|
|
737
|
+
next: (notification) => {
|
|
738
|
+
if (notification.source === "newNetworkStatus" ||
|
|
739
|
+
(notification.kind === "N" && notification.value.loading)) {
|
|
740
|
+
operation.override = networkStatus;
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
delete operation.override;
|
|
744
|
+
}
|
|
745
|
+
},
|
|
746
|
+
finalize: () => this.activeOperations.delete(operation),
|
|
747
|
+
}))
|
|
748
|
+
.subscribe({
|
|
749
|
+
next: (value) => {
|
|
750
|
+
const meta = {};
|
|
751
|
+
if (forceFirstValueEmit &&
|
|
752
|
+
value.kind === "N" &&
|
|
753
|
+
"loading" in value.value &&
|
|
754
|
+
!value.value.loading) {
|
|
755
|
+
forceFirstValueEmit = false;
|
|
756
|
+
meta.shouldEmit = 1 /* EmitBehavior.force */;
|
|
757
|
+
}
|
|
758
|
+
this.input.next({ ...value, query, variables, meta });
|
|
759
|
+
},
|
|
760
|
+
});
|
|
761
|
+
return { fromLink, subscription, observable };
|
|
643
762
|
}
|
|
644
763
|
// Turns polling on or off based on this.options.pollInterval.
|
|
645
764
|
updatePolling() {
|
|
@@ -655,7 +774,7 @@ export class ObservableQuery {
|
|
|
655
774
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
656
775
|
return;
|
|
657
776
|
}
|
|
658
|
-
invariant(pollInterval,
|
|
777
|
+
invariant(pollInterval, 80);
|
|
659
778
|
const info = pollingInfo || (this.pollingInfo = {});
|
|
660
779
|
info.interval = pollInterval;
|
|
661
780
|
const maybeFetch = () => {
|
|
@@ -694,20 +813,6 @@ export class ObservableQuery {
|
|
|
694
813
|
delete this.pollingInfo;
|
|
695
814
|
}
|
|
696
815
|
}
|
|
697
|
-
updateLastResult(newResult, variables = this.variables) {
|
|
698
|
-
let error = this.getLastError();
|
|
699
|
-
// Preserve this.last.error unless the variables have changed.
|
|
700
|
-
if (error && this.last && !equal(variables, this.last.variables)) {
|
|
701
|
-
error = void 0;
|
|
702
|
-
}
|
|
703
|
-
return (this.last = {
|
|
704
|
-
result: this.queryManager.assumeImmutableResults ?
|
|
705
|
-
newResult
|
|
706
|
-
: cloneDeep(newResult),
|
|
707
|
-
variables,
|
|
708
|
-
...(error ? { error } : null),
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
816
|
/**
|
|
712
817
|
* Reevaluate the query, optionally against new options. New options will be
|
|
713
818
|
* merged with the current options when given.
|
|
@@ -722,12 +827,9 @@ export class ObservableQuery {
|
|
|
722
827
|
}
|
|
723
828
|
const useDisposableObservable =
|
|
724
829
|
// Refetching uses a disposable Observable to allow refetches using different
|
|
725
|
-
// options
|
|
830
|
+
// options, without permanently altering the options of the
|
|
726
831
|
// original ObservableQuery.
|
|
727
832
|
newNetworkStatus === NetworkStatus.refetch ||
|
|
728
|
-
// The fetchMore method does not actually call the reobserve method, but,
|
|
729
|
-
// if it did, it would definitely use a disposable Observable.
|
|
730
|
-
newNetworkStatus === NetworkStatus.fetchMore ||
|
|
731
833
|
// Polling uses a disposable Observable so the polling options (which force
|
|
732
834
|
// fetchPolicy to be "network-only" or "no-cache") won't override the original options.
|
|
733
835
|
newNetworkStatus === NetworkStatus.poll;
|
|
@@ -796,47 +898,27 @@ export class ObservableQuery {
|
|
|
796
898
|
if (options.fetchPolicy === "standby") {
|
|
797
899
|
this.cancelPolling();
|
|
798
900
|
}
|
|
799
|
-
this.
|
|
800
|
-
this.
|
|
801
|
-
const finishWaitingForOwnResult = () => {
|
|
802
|
-
if (this.linkObservable === observable) {
|
|
803
|
-
this.waitForOwnResult = false;
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
const variables = { ...options.variables };
|
|
807
|
-
const { notifyOnNetworkStatusChange = true } = options;
|
|
808
|
-
const { observable, fromLink } = this.fetch(options, newNetworkStatus, notifyOnNetworkStatusChange &&
|
|
809
|
-
oldNetworkStatus !== newNetworkStatus &&
|
|
810
|
-
isNetworkRequestInFlight(newNetworkStatus), query);
|
|
811
|
-
const observer = {
|
|
812
|
-
next: (result) => {
|
|
813
|
-
if (equal(this.variables, variables)) {
|
|
814
|
-
finishWaitingForOwnResult();
|
|
815
|
-
this.reportResult(result, variables);
|
|
816
|
-
}
|
|
817
|
-
},
|
|
818
|
-
error: (error) => {
|
|
819
|
-
if (equal(this.variables, variables)) {
|
|
820
|
-
finishWaitingForOwnResult();
|
|
821
|
-
this.reportError(error, variables);
|
|
822
|
-
}
|
|
823
|
-
},
|
|
824
|
-
};
|
|
901
|
+
this.resubscribeCache();
|
|
902
|
+
const { subscription, observable, fromLink } = this.fetch(options, newNetworkStatus, query);
|
|
825
903
|
if (!useDisposableObservable && (fromLink || !this.linkSubscription)) {
|
|
826
904
|
if (this.linkSubscription) {
|
|
827
905
|
this.linkSubscription.unsubscribe();
|
|
828
906
|
}
|
|
829
|
-
this.
|
|
830
|
-
this.linkSubscription = observable.subscribe(observer);
|
|
831
|
-
}
|
|
832
|
-
else {
|
|
833
|
-
observable.subscribe(observer);
|
|
907
|
+
this.linkSubscription = subscription;
|
|
834
908
|
}
|
|
835
909
|
return preventUnhandledRejection(
|
|
836
910
|
// Note: lastValueFrom will create a separate subscription to the
|
|
837
911
|
// observable which means that terminating this ObservableQuery will not
|
|
838
912
|
// cancel the request from the link chain.
|
|
839
|
-
lastValueFrom(observable
|
|
913
|
+
lastValueFrom(observable.pipe(filterMap((value) => {
|
|
914
|
+
switch (value.kind) {
|
|
915
|
+
case "E":
|
|
916
|
+
throw value.error;
|
|
917
|
+
case "N":
|
|
918
|
+
if (value.source !== "newNetworkStatus")
|
|
919
|
+
return value.value;
|
|
920
|
+
}
|
|
921
|
+
})), {
|
|
840
922
|
// This default value should only be used when using a `fetchPolicy` of
|
|
841
923
|
// `standby` since that fetch policy completes without emitting a
|
|
842
924
|
// result. Since we are converting this to a QueryResult type, we
|
|
@@ -844,54 +926,16 @@ export class ObservableQuery {
|
|
|
844
926
|
defaultValue: { data: undefined },
|
|
845
927
|
}).then((result) => toQueryResult(this.maskResult(result))));
|
|
846
928
|
}
|
|
847
|
-
// (Re)deliver the current result to this.observers without applying fetch
|
|
848
|
-
// policies or making network requests.
|
|
849
|
-
observe() {
|
|
850
|
-
this.reportResult(
|
|
851
|
-
// Passing false is important so that this.getCurrentResult doesn't
|
|
852
|
-
// save the fetchMore result as this.lastResult, causing it to be
|
|
853
|
-
// ignored due to the this.isDifferentFromLastResult check in
|
|
854
|
-
// this.reportResult.
|
|
855
|
-
this.getCurrentFullResult(false), this.variables);
|
|
856
|
-
}
|
|
857
|
-
reportResult(result, variables) {
|
|
858
|
-
const lastError = this.getLastError();
|
|
859
|
-
const isDifferent = this.isDifferentFromLastResult(result, variables);
|
|
860
|
-
// Update the last result even when isDifferentFromLastResult returns false,
|
|
861
|
-
// because the query may be using the @nonreactive directive, and we want to
|
|
862
|
-
// save the the latest version of any nonreactive subtrees (in case
|
|
863
|
-
// getCurrentResult is called), even though we skip broadcasting changes.
|
|
864
|
-
this.updateLastResult(result, variables);
|
|
865
|
-
this.networkStatus = result.networkStatus;
|
|
866
|
-
if (lastError || isDifferent) {
|
|
867
|
-
this.subject.next(this.maskResult(result));
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
reportError(error, variables) {
|
|
871
|
-
// Since we don't get the current result on errors, only the error, we
|
|
872
|
-
// must mirror the updates that occur in QueryStore.markQueryError here
|
|
873
|
-
const errorResult = {
|
|
874
|
-
data: undefined,
|
|
875
|
-
partial: true,
|
|
876
|
-
...this.getLastResult(),
|
|
877
|
-
error,
|
|
878
|
-
networkStatus: NetworkStatus.error,
|
|
879
|
-
loading: false,
|
|
880
|
-
};
|
|
881
|
-
this.updateLastResult(errorResult, variables);
|
|
882
|
-
this.networkStatus = NetworkStatus.error;
|
|
883
|
-
this.last.error = error;
|
|
884
|
-
this.subject.next(errorResult);
|
|
885
|
-
}
|
|
886
929
|
hasObservers() {
|
|
887
930
|
return this.subject.observed;
|
|
888
931
|
}
|
|
889
932
|
tearDownQuery() {
|
|
890
933
|
if (this.isTornDown)
|
|
891
934
|
return;
|
|
892
|
-
|
|
935
|
+
this.resetNotifications();
|
|
936
|
+
this.unsubscribeFromCache?.();
|
|
937
|
+
if (this.linkSubscription) {
|
|
893
938
|
this.linkSubscription.unsubscribe();
|
|
894
|
-
delete this.linkObservable;
|
|
895
939
|
delete this.linkSubscription;
|
|
896
940
|
}
|
|
897
941
|
this.stopPolling();
|
|
@@ -900,6 +944,7 @@ export class ObservableQuery {
|
|
|
900
944
|
this.subscriptions.clear();
|
|
901
945
|
this.queryManager.removeQuery(this.queryId);
|
|
902
946
|
this.isTornDown = true;
|
|
947
|
+
this.abortActiveOperations();
|
|
903
948
|
}
|
|
904
949
|
transformDocument(document) {
|
|
905
950
|
return this.queryManager.transform(document);
|
|
@@ -919,57 +964,231 @@ export class ObservableQuery {
|
|
|
919
964
|
}
|
|
920
965
|
dirty = false;
|
|
921
966
|
notifyTimeout;
|
|
922
|
-
/**
|
|
967
|
+
/**
|
|
968
|
+
* @internal
|
|
969
|
+
*
|
|
970
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
971
|
+
*/
|
|
923
972
|
resetNotifications() {
|
|
924
|
-
this.cancelNotifyTimeout();
|
|
925
|
-
this.dirty = false;
|
|
926
|
-
}
|
|
927
|
-
cancelNotifyTimeout() {
|
|
928
973
|
if (this.notifyTimeout) {
|
|
929
974
|
clearTimeout(this.notifyTimeout);
|
|
930
975
|
this.notifyTimeout = void 0;
|
|
931
976
|
}
|
|
977
|
+
this.dirty = false;
|
|
932
978
|
}
|
|
933
|
-
/**
|
|
979
|
+
/**
|
|
980
|
+
* @internal
|
|
981
|
+
*
|
|
982
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
983
|
+
*/
|
|
934
984
|
scheduleNotify() {
|
|
935
985
|
if (this.dirty)
|
|
936
986
|
return;
|
|
937
987
|
this.dirty = true;
|
|
938
988
|
if (!this.notifyTimeout) {
|
|
939
|
-
this.notifyTimeout = setTimeout(() => this.notify(), 0);
|
|
989
|
+
this.notifyTimeout = setTimeout(() => this.notify(true), 0);
|
|
940
990
|
}
|
|
941
991
|
}
|
|
942
|
-
/**
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
992
|
+
/**
|
|
993
|
+
* @internal
|
|
994
|
+
*
|
|
995
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
996
|
+
*/
|
|
997
|
+
notify(scheduled = false) {
|
|
998
|
+
if (!scheduled) {
|
|
999
|
+
// For queries with client exports or forced resolvers, we don't want to
|
|
1000
|
+
// synchronously reobserve the cache on broadcast,
|
|
1001
|
+
// but actually wait for the `scheduleNotify` timeout triggered by the
|
|
1002
|
+
// `cache.watch` callback from `resubscribeCache`.
|
|
1003
|
+
const info = this.queryManager.getDocumentInfo(this.query);
|
|
1004
|
+
if (info.hasClientExports || info.hasForcedResolvers) {
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
const { dirty } = this;
|
|
1009
|
+
this.resetNotifications();
|
|
1010
|
+
if (dirty &&
|
|
1011
|
+
(this.options.fetchPolicy == "cache-only" ||
|
|
947
1012
|
this.options.fetchPolicy == "cache-and-network" ||
|
|
948
|
-
!
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1013
|
+
!this.activeOperations.size)) {
|
|
1014
|
+
const diff = this.getCacheDiff();
|
|
1015
|
+
if (
|
|
1016
|
+
// `fromOptimisticTransaction` is not avaiable through the `cache.diff`
|
|
1017
|
+
// code path, so we need to check it this way
|
|
1018
|
+
equal(diff.result, this.getCacheDiff({ optimistic: false }).result)) {
|
|
1019
|
+
//If this diff did not come from an optimistic transaction
|
|
1020
|
+
// make the ObservableQuery "reobserve" the latest data
|
|
1021
|
+
// using a temporary fetch policy of "cache-first", so complete cache
|
|
1022
|
+
// results have a chance to be delivered without triggering additional
|
|
1023
|
+
// network requests, even when options.fetchPolicy is "network-only"
|
|
1024
|
+
// or "cache-and-network". All other fetch policies are preserved by
|
|
1025
|
+
// this method, and are handled by calling oq.reobserve(). If this
|
|
1026
|
+
// reobservation is spurious, distinctUntilChanged still has a
|
|
1027
|
+
// chance to catch it before delivery to ObservableQuery subscribers.
|
|
1028
|
+
this.reobserveCacheFirst();
|
|
1029
|
+
}
|
|
1030
|
+
else {
|
|
1031
|
+
// If this diff came from an optimistic transaction, deliver the
|
|
1032
|
+
// current cache data to the ObservableQuery, but don't perform a
|
|
1033
|
+
// reobservation, since oq.reobserveCacheFirst might make a network
|
|
1034
|
+
// request, and we never want to trigger network requests in the
|
|
1035
|
+
// middle of optimistic updates.
|
|
1036
|
+
this.input.next({
|
|
1037
|
+
kind: "N",
|
|
1038
|
+
value: {
|
|
1039
|
+
data: diff.result,
|
|
1040
|
+
networkStatus: NetworkStatus.ready,
|
|
1041
|
+
loading: false,
|
|
1042
|
+
error: undefined,
|
|
1043
|
+
partial: !diff.complete,
|
|
1044
|
+
},
|
|
1045
|
+
source: "cache",
|
|
1046
|
+
query: this.query,
|
|
1047
|
+
variables: this.variables,
|
|
1048
|
+
meta: {},
|
|
1049
|
+
});
|
|
969
1050
|
}
|
|
970
1051
|
}
|
|
971
|
-
this.dirty = false;
|
|
972
1052
|
}
|
|
1053
|
+
activeOperations = new Set();
|
|
1054
|
+
pushOperation(networkStatus) {
|
|
1055
|
+
let aborted = false;
|
|
1056
|
+
// track query and variables from the start of the operation
|
|
1057
|
+
const { query, variables } = this;
|
|
1058
|
+
const finalize = () => {
|
|
1059
|
+
this.activeOperations.delete(operation);
|
|
1060
|
+
};
|
|
1061
|
+
const operation = {
|
|
1062
|
+
override: networkStatus,
|
|
1063
|
+
abort: () => {
|
|
1064
|
+
aborted = true;
|
|
1065
|
+
finalize();
|
|
1066
|
+
},
|
|
1067
|
+
query,
|
|
1068
|
+
variables,
|
|
1069
|
+
};
|
|
1070
|
+
this.activeOperations.add(operation);
|
|
1071
|
+
return {
|
|
1072
|
+
finalize,
|
|
1073
|
+
pushNotification: (notification, additionalMeta) => {
|
|
1074
|
+
if (!aborted) {
|
|
1075
|
+
this.input.next({
|
|
1076
|
+
...notification,
|
|
1077
|
+
query,
|
|
1078
|
+
variables,
|
|
1079
|
+
meta: { ...additionalMeta },
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
},
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
calculateNetworkStatus(baseNetworkStatus) {
|
|
1086
|
+
// in the future, this could be more complex logic, e.g. "refetch" and
|
|
1087
|
+
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1088
|
+
// as for now we just take the "latest" operation that is still active,
|
|
1089
|
+
// as that lines up best with previous behavior[]
|
|
1090
|
+
const operation = Array.from(this.activeOperations.values()).findLast((operation) => isEqualQuery(operation, this) && operation.override !== undefined);
|
|
1091
|
+
return operation?.override ?? baseNetworkStatus;
|
|
1092
|
+
}
|
|
1093
|
+
abortActiveOperations() {
|
|
1094
|
+
this.activeOperations.forEach((operation) => operation.abort());
|
|
1095
|
+
}
|
|
1096
|
+
/**
|
|
1097
|
+
* @internal
|
|
1098
|
+
* Called from `clearStore`.
|
|
1099
|
+
* * resets the query to its initial state
|
|
1100
|
+
* * cancels all active operations and their subscriptions
|
|
1101
|
+
*
|
|
1102
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
1103
|
+
*/
|
|
1104
|
+
reset() {
|
|
1105
|
+
// exception for cache-only queries - we reset them into a "ready" state
|
|
1106
|
+
// as we won't trigger a refetch for them
|
|
1107
|
+
const resetToEmpty = this.options.fetchPolicy === "cache-only";
|
|
1108
|
+
this.setResult(resetToEmpty ? empty : uninitialized, {
|
|
1109
|
+
shouldEmit: resetToEmpty ? 1 /* EmitBehavior.force */ : 2 /* EmitBehavior.never */,
|
|
1110
|
+
});
|
|
1111
|
+
this.abortActiveOperations();
|
|
1112
|
+
}
|
|
1113
|
+
/**
|
|
1114
|
+
* @internal
|
|
1115
|
+
*
|
|
1116
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
1117
|
+
*/
|
|
1118
|
+
setResult(result, additionalMeta) {
|
|
1119
|
+
this.input.next({
|
|
1120
|
+
source: "setResult",
|
|
1121
|
+
kind: "N",
|
|
1122
|
+
value: result,
|
|
1123
|
+
query: this.query,
|
|
1124
|
+
variables: this.variables,
|
|
1125
|
+
meta: { ...additionalMeta },
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
operator = filterMap((notification) => {
|
|
1129
|
+
const { query, variables, meta } = notification;
|
|
1130
|
+
if (notification.source === "setResult") {
|
|
1131
|
+
return { query, variables, result: notification.value, meta };
|
|
1132
|
+
}
|
|
1133
|
+
if (notification.kind === "C" || !isEqualQuery(notification, this)) {
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
let result;
|
|
1137
|
+
const previous = this.subject.getValue();
|
|
1138
|
+
if (notification.source === "cache") {
|
|
1139
|
+
result = notification.value;
|
|
1140
|
+
if (result.networkStatus === NetworkStatus.ready &&
|
|
1141
|
+
result.partial &&
|
|
1142
|
+
(!this.options.returnPartialData ||
|
|
1143
|
+
previous.result.networkStatus === NetworkStatus.error) &&
|
|
1144
|
+
this.options.fetchPolicy !== "cache-only") {
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
else if (notification.source === "network") {
|
|
1149
|
+
if (this.waitForNetworkResult) {
|
|
1150
|
+
this.waitForNetworkResult = false;
|
|
1151
|
+
this.resubscribeCache();
|
|
1152
|
+
}
|
|
1153
|
+
result =
|
|
1154
|
+
notification.kind === "E" ?
|
|
1155
|
+
{
|
|
1156
|
+
data: undefined,
|
|
1157
|
+
partial: true,
|
|
1158
|
+
...(isEqualQuery(previous, notification) ? previous.result : {}),
|
|
1159
|
+
error: notification.error,
|
|
1160
|
+
networkStatus: NetworkStatus.error,
|
|
1161
|
+
loading: false,
|
|
1162
|
+
}
|
|
1163
|
+
: notification.value;
|
|
1164
|
+
if (result.error) {
|
|
1165
|
+
meta.shouldEmit = 1 /* EmitBehavior.force */;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
else if (notification.source === "newNetworkStatus") {
|
|
1169
|
+
const baseResult = isEqualQuery(previous, notification) ?
|
|
1170
|
+
previous.result
|
|
1171
|
+
: this.getInitialResult(meta.fetchPolicy);
|
|
1172
|
+
const { resetError } = notification.value;
|
|
1173
|
+
const error = resetError ? undefined : baseResult.error;
|
|
1174
|
+
const networkStatus = error ? NetworkStatus.error : NetworkStatus.ready;
|
|
1175
|
+
result = {
|
|
1176
|
+
...baseResult,
|
|
1177
|
+
error,
|
|
1178
|
+
networkStatus,
|
|
1179
|
+
};
|
|
1180
|
+
}
|
|
1181
|
+
// every code path until here should have either returned or set a result,
|
|
1182
|
+
// but typescript needs a little help
|
|
1183
|
+
invariant(result);
|
|
1184
|
+
// normalize result shape
|
|
1185
|
+
if (!result.error)
|
|
1186
|
+
delete result.error;
|
|
1187
|
+
result.networkStatus = this.calculateNetworkStatus(result.networkStatus);
|
|
1188
|
+
result.loading = isNetworkRequestInFlight(result.networkStatus);
|
|
1189
|
+
result = this.maskResult(result);
|
|
1190
|
+
return { query, variables, result, meta };
|
|
1191
|
+
});
|
|
973
1192
|
// Reobserve with fetchPolicy effectively set to "cache-first", triggering
|
|
974
1193
|
// delivery of any new data from the cache, possibly falling back to the network
|
|
975
1194
|
// if any cache data are missing. This allows _complete_ cache results to be
|
|
@@ -1006,12 +1225,10 @@ export class ObservableQuery {
|
|
|
1006
1225
|
}
|
|
1007
1226
|
export function logMissingFieldErrors(missing) {
|
|
1008
1227
|
if (__DEV__ && missing) {
|
|
1009
|
-
__DEV__ && invariant.debug(
|
|
1228
|
+
__DEV__ && invariant.debug(81, missing);
|
|
1010
1229
|
}
|
|
1011
1230
|
}
|
|
1012
|
-
function
|
|
1013
|
-
return (
|
|
1014
|
-
fetchPolicy === "no-cache" ||
|
|
1015
|
-
fetchPolicy === "standby");
|
|
1231
|
+
function isEqualQuery(a, b) {
|
|
1232
|
+
return !!(a && b && a.query === b.query && equal(a.variables, b.variables));
|
|
1016
1233
|
}
|
|
1017
1234
|
//# sourceMappingURL=ObservableQuery.js.map
|