@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
|
@@ -9,7 +9,6 @@ exports.logMissingFieldErrors = logMissingFieldErrors;
|
|
|
9
9
|
const equality_1 = require("@wry/equality");
|
|
10
10
|
const optimism_1 = require("optimism");
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
|
-
const utilities_1 = require("@apollo/client/utilities");
|
|
13
12
|
const environment_1 = require("@apollo/client/utilities/environment");
|
|
14
13
|
const internal_1 = require("@apollo/client/utilities/internal");
|
|
15
14
|
const invariant_1 = require("@apollo/client/utilities/invariant");
|
|
@@ -17,15 +16,28 @@ const equalByQuery_js_1 = require("./equalByQuery.cjs");
|
|
|
17
16
|
const networkStatus_js_1 = require("./networkStatus.cjs");
|
|
18
17
|
const { assign, hasOwnProperty } = Object;
|
|
19
18
|
const newNetworkStatusSymbol = Symbol();
|
|
20
|
-
const uninitialized = {
|
|
19
|
+
const uninitialized = {
|
|
20
|
+
loading: true,
|
|
21
|
+
networkStatus: networkStatus_js_1.NetworkStatus.loading,
|
|
22
|
+
data: undefined,
|
|
23
|
+
partial: true,
|
|
24
|
+
};
|
|
25
|
+
const empty = {
|
|
26
|
+
loading: false,
|
|
27
|
+
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
28
|
+
data: undefined,
|
|
29
|
+
partial: true,
|
|
30
|
+
};
|
|
21
31
|
class ObservableQuery {
|
|
22
32
|
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
* @internal
|
|
34
|
+
* A slot used by the `useQuery` hook to indicate that `client.watchQuery`
|
|
35
|
+
* should not register the query immediately, but instead wait for the query to
|
|
36
|
+
* be started registered with the `QueryManager` when `useSyncExternalStore`
|
|
37
|
+
* actively subscribes to it.
|
|
38
|
+
*
|
|
39
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
40
|
+
*/
|
|
29
41
|
static inactiveOnCreation = new optimism_1.Slot();
|
|
30
42
|
options;
|
|
31
43
|
queryId;
|
|
@@ -43,23 +55,58 @@ class ObservableQuery {
|
|
|
43
55
|
get variables() {
|
|
44
56
|
return this.options.variables;
|
|
45
57
|
}
|
|
58
|
+
unsubscribeFromCache;
|
|
59
|
+
input;
|
|
46
60
|
subject;
|
|
47
61
|
observable;
|
|
48
62
|
isTornDown;
|
|
49
63
|
queryManager;
|
|
50
64
|
subscriptions = new Set();
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
/**
|
|
66
|
+
* If an `ObservableQuery` is created with a `network-only` fetch policy,
|
|
67
|
+
* it should actually start receiving cache updates, but not before it has
|
|
68
|
+
* received the first result from the network.
|
|
69
|
+
*/
|
|
70
|
+
waitForNetworkResult;
|
|
53
71
|
lastQuery;
|
|
54
72
|
queryInfo;
|
|
55
73
|
linkSubscription;
|
|
56
|
-
linkObservable;
|
|
57
74
|
pollingInfo;
|
|
58
|
-
networkStatus
|
|
75
|
+
get networkStatus() {
|
|
76
|
+
return this.subject.getValue().result.networkStatus;
|
|
77
|
+
}
|
|
59
78
|
constructor({ queryManager, queryInfo, options, }) {
|
|
60
|
-
this.networkStatus = networkStatus_js_1.NetworkStatus.loading;
|
|
61
79
|
let startedInactive = ObservableQuery.inactiveOnCreation.getValue();
|
|
62
|
-
|
|
80
|
+
// related classes
|
|
81
|
+
this.queryInfo = queryInfo;
|
|
82
|
+
this.queryManager = queryManager;
|
|
83
|
+
// active state
|
|
84
|
+
this.waitForNetworkResult = options.fetchPolicy === "network-only";
|
|
85
|
+
this.isTornDown = false;
|
|
86
|
+
this.subscribeToMore = this.subscribeToMore.bind(this);
|
|
87
|
+
this.maskResult = this.maskResult.bind(this);
|
|
88
|
+
const { watchQuery: { fetchPolicy: defaultFetchPolicy = "cache-first" } = {}, } = queryManager.defaultOptions;
|
|
89
|
+
const { fetchPolicy = defaultFetchPolicy,
|
|
90
|
+
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
91
|
+
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
92
|
+
this.lastQuery = options.query;
|
|
93
|
+
this.options = {
|
|
94
|
+
...options,
|
|
95
|
+
// Remember the initial options.fetchPolicy so we can revert back to this
|
|
96
|
+
// policy when variables change. This information can also be specified
|
|
97
|
+
// (or overridden) by providing options.initialFetchPolicy explicitly.
|
|
98
|
+
initialFetchPolicy,
|
|
99
|
+
// This ensures this.options.fetchPolicy always has a string value, in
|
|
100
|
+
// case options.fetchPolicy was not provided.
|
|
101
|
+
fetchPolicy,
|
|
102
|
+
variables: this.getVariablesWithDefaults(options.variables),
|
|
103
|
+
};
|
|
104
|
+
this.subject = new rxjs_1.BehaviorSubject({
|
|
105
|
+
query: this.query,
|
|
106
|
+
variables: this.variables,
|
|
107
|
+
result: uninitialized,
|
|
108
|
+
meta: {},
|
|
109
|
+
});
|
|
63
110
|
this.observable = this.subject.pipe((0, rxjs_1.tap)({
|
|
64
111
|
subscribe: () => {
|
|
65
112
|
if (startedInactive) {
|
|
@@ -67,22 +114,6 @@ class ObservableQuery {
|
|
|
67
114
|
startedInactive = false;
|
|
68
115
|
}
|
|
69
116
|
if (!this.subject.observed) {
|
|
70
|
-
if (this.subject.value === uninitialized) {
|
|
71
|
-
// Emitting a value in the `subscribe` callback of `tap` gives
|
|
72
|
-
// the subject a chance to save this initial result without
|
|
73
|
-
// emitting the placeholder value since this callback is executed
|
|
74
|
-
// before `tap` subscribes to the source observable (the subject).
|
|
75
|
-
// `reobserve` also has the chance to update this value if it
|
|
76
|
-
// synchronously emits one (usually due to reporting a cache
|
|
77
|
-
// value).
|
|
78
|
-
//
|
|
79
|
-
// We don't initialize the `BehaviorSubject` with
|
|
80
|
-
// `getInitialResult` because its possible the cache might have
|
|
81
|
-
// updated between when the `ObservableQuery` was instantiated and
|
|
82
|
-
// when it is subscribed to. Updating the value here ensures we
|
|
83
|
-
// report the most up-to-date result from the cache.
|
|
84
|
-
this.subject.next(this.getInitialResult());
|
|
85
|
-
}
|
|
86
117
|
this.reobserve();
|
|
87
118
|
// TODO: See if we can rework updatePolling to better handle this.
|
|
88
119
|
// reobserve calls updatePolling but this `subscribe` callback is
|
|
@@ -97,47 +128,55 @@ class ObservableQuery {
|
|
|
97
128
|
this.tearDownQuery();
|
|
98
129
|
}
|
|
99
130
|
},
|
|
100
|
-
}), (0,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
131
|
+
}), (0, internal_1.filterMap)(({ query, variables, result: current, meta }, context) => {
|
|
132
|
+
const { shouldEmit } = meta;
|
|
133
|
+
if (current === uninitialized) {
|
|
134
|
+
// reset internal state after `ObservableQuery.reset()`
|
|
135
|
+
context.previous = undefined;
|
|
136
|
+
context.previousVariables = undefined;
|
|
137
|
+
}
|
|
138
|
+
if (this.options.fetchPolicy === "standby" ||
|
|
139
|
+
shouldEmit === 2 /* EmitBehavior.never */)
|
|
140
|
+
return;
|
|
141
|
+
if (shouldEmit === 1 /* EmitBehavior.force */)
|
|
142
|
+
return emit();
|
|
143
|
+
const { previous, previousVariables } = context;
|
|
144
|
+
if (previous) {
|
|
145
|
+
const documentInfo = this.queryManager.getDocumentInfo(query);
|
|
146
|
+
const dataMasking = this.queryManager.dataMasking;
|
|
147
|
+
const maskedQuery = dataMasking ? documentInfo.nonReactiveQuery : query;
|
|
148
|
+
const resultIsEqual = dataMasking || documentInfo.hasNonreactiveDirective ?
|
|
149
|
+
(0, equalByQuery_js_1.equalByQuery)(maskedQuery, previous, current, variables)
|
|
150
|
+
: (0, equality_1.equal)(previous, current);
|
|
151
|
+
if (resultIsEqual && (0, equality_1.equal)(previousVariables, variables)) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if (shouldEmit === 3 /* EmitBehavior.networkStatusChange */ &&
|
|
156
|
+
(!this.options.notifyOnNetworkStatusChange ||
|
|
157
|
+
(0, equality_1.equal)(previous, current))) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
return emit();
|
|
161
|
+
function emit() {
|
|
162
|
+
context.previous = current;
|
|
163
|
+
context.previousVariables = variables;
|
|
164
|
+
return current;
|
|
165
|
+
}
|
|
166
|
+
}, () => ({})));
|
|
108
167
|
this["@@observable"] = () => this;
|
|
109
168
|
if (Symbol.observable) {
|
|
110
169
|
this[Symbol.observable] = () => this;
|
|
111
170
|
}
|
|
112
171
|
this.pipe = this.observable.pipe.bind(this.observable);
|
|
113
172
|
this.subscribe = this.observable.subscribe.bind(this.observable);
|
|
114
|
-
|
|
115
|
-
this.
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
this.
|
|
119
|
-
this.isTornDown = false;
|
|
120
|
-
this.subscribe = this.subscribe.bind(this);
|
|
121
|
-
this.subscribeToMore = this.subscribeToMore.bind(this);
|
|
122
|
-
this.maskResult = this.maskResult.bind(this);
|
|
123
|
-
const { watchQuery: { fetchPolicy: defaultFetchPolicy = "cache-first" } = {}, } = queryManager.defaultOptions;
|
|
124
|
-
const { fetchPolicy = defaultFetchPolicy,
|
|
125
|
-
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
126
|
-
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
127
|
-
this.lastQuery = options.query;
|
|
128
|
-
this.options = {
|
|
129
|
-
...options,
|
|
130
|
-
// Remember the initial options.fetchPolicy so we can revert back to this
|
|
131
|
-
// policy when variables change. This information can also be specified
|
|
132
|
-
// (or overridden) by providing options.initialFetchPolicy explicitly.
|
|
133
|
-
initialFetchPolicy,
|
|
134
|
-
// This ensures this.options.fetchPolicy always has a string value, in
|
|
135
|
-
// case options.fetchPolicy was not provided.
|
|
136
|
-
fetchPolicy,
|
|
137
|
-
variables: this.getVariablesWithDefaults(options.variables),
|
|
138
|
-
};
|
|
173
|
+
this.input = new rxjs_1.Subject();
|
|
174
|
+
// we want to feed many streams into `this.subject`, but none of them should
|
|
175
|
+
// be able to close `this.input`
|
|
176
|
+
this.input.complete = () => { };
|
|
177
|
+
this.input.pipe(this.operator).subscribe(this.subject);
|
|
139
178
|
this.queryId = queryInfo.queryId || queryManager.generateQueryId();
|
|
140
|
-
const opDef = (0,
|
|
179
|
+
const opDef = (0, internal_1.getOperationDefinition)(this.query);
|
|
141
180
|
this.queryName = opDef && opDef.name && opDef.name.value;
|
|
142
181
|
}
|
|
143
182
|
// We can't use Observable['subscribe'] here as the type as it conflicts with
|
|
@@ -147,14 +186,26 @@ class ObservableQuery {
|
|
|
147
186
|
pipe;
|
|
148
187
|
[Symbol.observable];
|
|
149
188
|
["@@observable"];
|
|
150
|
-
/**
|
|
189
|
+
/**
|
|
190
|
+
* @internal
|
|
191
|
+
*
|
|
192
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
193
|
+
*/
|
|
151
194
|
resetDiff() {
|
|
152
195
|
this.queryInfo.resetDiff();
|
|
153
196
|
}
|
|
154
|
-
|
|
197
|
+
getCacheDiff({ optimistic = true } = {}) {
|
|
198
|
+
return this.queryManager.cache.diff({
|
|
199
|
+
query: this.query,
|
|
200
|
+
variables: this.variables,
|
|
201
|
+
returnPartialData: true,
|
|
202
|
+
optimistic,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
getInitialResult(initialFetchPolicy) {
|
|
155
206
|
const fetchPolicy = this.queryManager.prioritizeCacheValues ?
|
|
156
207
|
"cache-first"
|
|
157
|
-
: this.options.fetchPolicy;
|
|
208
|
+
: initialFetchPolicy || this.options.fetchPolicy;
|
|
158
209
|
const defaultResult = {
|
|
159
210
|
data: undefined,
|
|
160
211
|
loading: true,
|
|
@@ -162,7 +213,7 @@ class ObservableQuery {
|
|
|
162
213
|
partial: true,
|
|
163
214
|
};
|
|
164
215
|
const cacheResult = () => {
|
|
165
|
-
const diff = this.
|
|
216
|
+
const diff = this.getCacheDiff();
|
|
166
217
|
return this.maskResult({
|
|
167
218
|
data:
|
|
168
219
|
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
@@ -185,128 +236,101 @@ class ObservableQuery {
|
|
|
185
236
|
loading: true,
|
|
186
237
|
networkStatus: networkStatus_js_1.NetworkStatus.loading,
|
|
187
238
|
};
|
|
188
|
-
case "standby":
|
|
189
|
-
return {
|
|
190
|
-
...defaultResult,
|
|
191
|
-
loading: false,
|
|
192
|
-
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
193
|
-
};
|
|
194
239
|
default:
|
|
195
240
|
return defaultResult;
|
|
196
241
|
}
|
|
197
242
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
};
|
|
209
|
-
let { fetchPolicy = "cache-first" } = this.options;
|
|
210
|
-
const { prioritizeCacheValues } = this.queryManager;
|
|
211
|
-
if (prioritizeCacheValues) {
|
|
212
|
-
fetchPolicy = "cache-first";
|
|
213
|
-
}
|
|
214
|
-
if (
|
|
215
|
-
// These fetch policies should never deliver data from the cache, unless
|
|
216
|
-
// redelivering a previously delivered result.
|
|
217
|
-
skipCacheDataFor(fetchPolicy) ||
|
|
218
|
-
// If this.options.query has @client(always: true) fields, we cannot
|
|
219
|
-
// trust diff.result, since it was read from the cache without running
|
|
220
|
-
// local resolvers (and it's too late to run resolvers now, since we must
|
|
221
|
-
// return a result synchronously).
|
|
222
|
-
this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) {
|
|
223
|
-
// Fall through.
|
|
243
|
+
resubscribeCache() {
|
|
244
|
+
const { variables, fetchPolicy } = this.options;
|
|
245
|
+
const query = this.query;
|
|
246
|
+
const shouldUnsubscribe = fetchPolicy === "standby" ||
|
|
247
|
+
fetchPolicy === "no-cache" ||
|
|
248
|
+
this.waitForNetworkResult;
|
|
249
|
+
const shouldResubscribe = !isEqualQuery({ query, variables }, this.unsubscribeFromCache) &&
|
|
250
|
+
!this.waitForNetworkResult;
|
|
251
|
+
if (shouldUnsubscribe || shouldResubscribe) {
|
|
252
|
+
this.unsubscribeFromCache?.();
|
|
224
253
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
// which we skip in the waitForOwnResult case since we are not
|
|
228
|
-
// interested in the diff.
|
|
229
|
-
this.queryInfo["updateWatch"]();
|
|
254
|
+
if (shouldUnsubscribe || !shouldResubscribe) {
|
|
255
|
+
return;
|
|
230
256
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
257
|
+
const watch = {
|
|
258
|
+
query,
|
|
259
|
+
variables,
|
|
260
|
+
optimistic: true,
|
|
261
|
+
watcher: this,
|
|
262
|
+
callback: (diff) => {
|
|
263
|
+
const info = this.queryManager.getDocumentInfo(query);
|
|
264
|
+
if (info.hasClientExports || info.hasForcedResolvers) {
|
|
265
|
+
// If this is not set to something different than `diff`, we will
|
|
266
|
+
// not be notified about future cache changes with an equal `diff`.
|
|
267
|
+
// That would be the case if we are working with client-only fields
|
|
268
|
+
// that are forced or with `exports` fields that might change, causing
|
|
269
|
+
// local resovlers to return a new result.
|
|
270
|
+
// This is based on an implementation detail of `InMemoryCache`, which
|
|
271
|
+
// is not optimal - but the only alternative to this would be to
|
|
272
|
+
// resubscribe to the cache asynchonouly, which would bear the risk of
|
|
273
|
+
// missing further synchronous updates.
|
|
274
|
+
watch.lastDiff = undefined;
|
|
249
275
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
276
|
+
if (watch.lastOwnDiff === diff) {
|
|
277
|
+
// skip cache updates that were caused by our own writes
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const { result: previousResult } = this.subject.getValue();
|
|
281
|
+
if (!diff.complete &&
|
|
282
|
+
// If we are trying to deliver an incomplete cache result, we avoid
|
|
283
|
+
// reporting it if the query has errored, otherwise we let the broadcast try
|
|
284
|
+
// and repair the partial result by refetching the query. This check avoids
|
|
285
|
+
// a situation where a query that errors and another succeeds with
|
|
286
|
+
// overlapping data does not report the partial data result to the errored
|
|
287
|
+
// query.
|
|
288
|
+
//
|
|
289
|
+
// See https://github.com/apollographql/apollo-client/issues/11400 for more
|
|
290
|
+
// information on this issue.
|
|
291
|
+
(previousResult.error ||
|
|
292
|
+
// Prevent to schedule a notify directly after the `ObservableQuery`
|
|
293
|
+
// has been `reset` (which will set the `previousResult` to `uninitialized` or `empty`)
|
|
294
|
+
// as in those cases, `resetCache` will manually call `refetch` with more intentional timing.
|
|
295
|
+
previousResult === uninitialized ||
|
|
296
|
+
previousResult === empty)) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (!(0, equality_1.equal)(previousResult.data, diff.result)) {
|
|
300
|
+
this.scheduleNotify();
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
const cancelWatch = this.queryManager.cache.watch(watch);
|
|
305
|
+
this.unsubscribeFromCache = Object.assign(() => {
|
|
306
|
+
this.unsubscribeFromCache = undefined;
|
|
307
|
+
cancelWatch();
|
|
308
|
+
}, { query, variables });
|
|
273
309
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
310
|
+
stableLastResult;
|
|
311
|
+
getCurrentResult() {
|
|
312
|
+
const { result: current } = this.subject.getValue();
|
|
313
|
+
let value = (
|
|
314
|
+
// if the `current` result is in an error state, we will always return that
|
|
315
|
+
// error state, even if we have no observers
|
|
316
|
+
(current.networkStatus === networkStatus_js_1.NetworkStatus.error ||
|
|
317
|
+
// if we have observers, we are watching the cache and
|
|
318
|
+
// this.subject.getValue() will always be up to date
|
|
319
|
+
this.hasObservers() || // if we are using a `no-cache` fetch policy in which case this
|
|
320
|
+
// `ObservableQuery` cannot have been updated from the outside - in
|
|
321
|
+
// that case, we prefer to keep the current value
|
|
322
|
+
this.options.fetchPolicy === "no-cache")) ?
|
|
323
|
+
current
|
|
324
|
+
// otherwise, the `current` value might be outdated due to missed
|
|
325
|
+
// external updates - calculate it again
|
|
326
|
+
: this.getInitialResult();
|
|
327
|
+
if (value === uninitialized) {
|
|
328
|
+
value = this.getInitialResult();
|
|
279
329
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const query = dataMasking ? documentInfo.nonReactiveQuery : this.query;
|
|
283
|
-
const resultIsDifferent = dataMasking || documentInfo.hasNonreactiveDirective ?
|
|
284
|
-
!(0, equalByQuery_js_1.equalByQuery)(query, this.last.result, newResult, this.variables)
|
|
285
|
-
: !(0, equality_1.equal)(this.last.result, newResult);
|
|
286
|
-
return (resultIsDifferent || (variables && !(0, equality_1.equal)(this.last.variables, variables)));
|
|
287
|
-
}
|
|
288
|
-
getLast(key, variablesMustMatch) {
|
|
289
|
-
const last = this.last;
|
|
290
|
-
if (last &&
|
|
291
|
-
last[key] &&
|
|
292
|
-
(!variablesMustMatch || (0, equality_1.equal)(last.variables, this.variables))) {
|
|
293
|
-
return last[key];
|
|
330
|
+
if (!(0, equality_1.equal)(this.stableLastResult, value)) {
|
|
331
|
+
this.stableLastResult = value;
|
|
294
332
|
}
|
|
295
|
-
|
|
296
|
-
// TODO: Consider deprecating this function
|
|
297
|
-
getLastResult(variablesMustMatch) {
|
|
298
|
-
return this.getLast("result", variablesMustMatch);
|
|
299
|
-
}
|
|
300
|
-
// TODO: Consider deprecating this function
|
|
301
|
-
getLastError(variablesMustMatch) {
|
|
302
|
-
return this.getLast("error", variablesMustMatch);
|
|
303
|
-
}
|
|
304
|
-
// TODO: Consider deprecating this function
|
|
305
|
-
resetLastResults() {
|
|
306
|
-
delete this.last;
|
|
307
|
-
// TODO: This will need to be removed when tearing down an ObservableQuery
|
|
308
|
-
// since the observable will terminate.
|
|
309
|
-
this.isTornDown = false;
|
|
333
|
+
return this.stableLastResult;
|
|
310
334
|
}
|
|
311
335
|
/**
|
|
312
336
|
* Update the variables of this observable query, and fetch the new results.
|
|
@@ -331,10 +355,10 @@ class ObservableQuery {
|
|
|
331
355
|
reobserveOptions.fetchPolicy = "network-only";
|
|
332
356
|
}
|
|
333
357
|
if (environment_1.__DEV__ && variables && hasOwnProperty.call(variables, "variables")) {
|
|
334
|
-
const queryDef = (0,
|
|
358
|
+
const queryDef = (0, internal_1.getQueryDefinition)(this.query);
|
|
335
359
|
const vars = queryDef.variableDefinitions;
|
|
336
360
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
337
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
361
|
+
__DEV__ && invariant_1.invariant.warn(77, variables, queryDef.name?.value || queryDef);
|
|
338
362
|
}
|
|
339
363
|
}
|
|
340
364
|
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
@@ -381,26 +405,27 @@ class ObservableQuery {
|
|
|
381
405
|
fetchMoreOptions.query ?
|
|
382
406
|
this.transformDocument(this.options.query)
|
|
383
407
|
: combinedOptions.query;
|
|
384
|
-
|
|
385
|
-
// result.networkStatus === NetworkStatus.fetchMore.
|
|
386
|
-
const originalNetworkStatus = this.networkStatus;
|
|
387
|
-
this.networkStatus = networkStatus_js_1.NetworkStatus.fetchMore;
|
|
388
|
-
if (combinedOptions.notifyOnNetworkStatusChange) {
|
|
389
|
-
this.observe();
|
|
390
|
-
}
|
|
391
|
-
const updatedQuerySet = new Set();
|
|
408
|
+
let wasUpdated = false;
|
|
392
409
|
const updateQuery = fetchMoreOptions?.updateQuery;
|
|
393
410
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
394
411
|
if (!isCached) {
|
|
395
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
412
|
+
(0, invariant_1.invariant)(updateQuery, 78);
|
|
396
413
|
}
|
|
414
|
+
const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
|
|
415
|
+
pushNotification({
|
|
416
|
+
source: "newNetworkStatus",
|
|
417
|
+
kind: "N",
|
|
418
|
+
value: {},
|
|
419
|
+
}, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
|
|
397
420
|
return this.queryManager
|
|
398
421
|
.fetchQuery(qid, combinedOptions, networkStatus_js_1.NetworkStatus.fetchMore)
|
|
399
422
|
.then((fetchMoreResult) => {
|
|
400
423
|
this.queryManager.removeQuery(qid);
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
424
|
+
// disable the `fetchMore` override that is currently active
|
|
425
|
+
// the next updates caused by this should not be `fetchMore` anymore,
|
|
426
|
+
// but `ready` or whatever other calculated loading state is currently
|
|
427
|
+
// appropriate
|
|
428
|
+
finalize();
|
|
404
429
|
if (isCached) {
|
|
405
430
|
// Performing this cache update inside a cache.batch transaction ensures
|
|
406
431
|
// any affected cache.watch watchers are notified at most once about any
|
|
@@ -435,9 +460,9 @@ class ObservableQuery {
|
|
|
435
460
|
}
|
|
436
461
|
},
|
|
437
462
|
onWatchUpdated: (watch) => {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
463
|
+
if (watch.watcher === this) {
|
|
464
|
+
wasUpdated = true;
|
|
465
|
+
}
|
|
441
466
|
},
|
|
442
467
|
});
|
|
443
468
|
}
|
|
@@ -456,28 +481,40 @@ class ObservableQuery {
|
|
|
456
481
|
// adjustment to the types on `updateQuery` since that function
|
|
457
482
|
// expects that the first argument always contains previous result
|
|
458
483
|
// data, but not `undefined`.
|
|
459
|
-
const lastResult = this.
|
|
484
|
+
const lastResult = this.getCurrentResult();
|
|
460
485
|
const data = updateQuery(lastResult.data, {
|
|
461
486
|
fetchMoreResult: fetchMoreResult.data,
|
|
462
487
|
variables: combinedOptions.variables,
|
|
463
488
|
});
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
489
|
+
// was reportResult
|
|
490
|
+
pushNotification({
|
|
491
|
+
kind: "N",
|
|
492
|
+
value: {
|
|
493
|
+
...lastResult,
|
|
494
|
+
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
495
|
+
// will be overwritten anyways, just here for types sake
|
|
496
|
+
loading: false,
|
|
497
|
+
data: data,
|
|
498
|
+
},
|
|
499
|
+
source: "network",
|
|
500
|
+
});
|
|
470
501
|
}
|
|
471
502
|
return this.maskResult(fetchMoreResult);
|
|
472
503
|
})
|
|
473
504
|
.finally(() => {
|
|
505
|
+
// call `finalize` a second time in case the `.then` case above was not reached
|
|
506
|
+
finalize();
|
|
474
507
|
// In case the cache writes above did not generate a broadcast
|
|
475
508
|
// notification (which would have been intercepted by onWatchUpdated),
|
|
476
509
|
// likely because the written data were the same as what was already in
|
|
477
510
|
// the cache, we still want fetchMore to deliver its final loading:false
|
|
478
511
|
// result with the unchanged data.
|
|
479
|
-
if (isCached && !
|
|
480
|
-
|
|
512
|
+
if (isCached && !wasUpdated) {
|
|
513
|
+
pushNotification({
|
|
514
|
+
kind: "N",
|
|
515
|
+
source: "newNetworkStatus",
|
|
516
|
+
value: {},
|
|
517
|
+
}, { shouldEmit: 1 /* EmitBehavior.force */ });
|
|
481
518
|
}
|
|
482
519
|
});
|
|
483
520
|
}
|
|
@@ -505,7 +542,7 @@ class ObservableQuery {
|
|
|
505
542
|
onError(error);
|
|
506
543
|
}
|
|
507
544
|
else {
|
|
508
|
-
__DEV__ && invariant_1.invariant.error(
|
|
545
|
+
__DEV__ && invariant_1.invariant.error(79, error);
|
|
509
546
|
}
|
|
510
547
|
return;
|
|
511
548
|
}
|
|
@@ -524,9 +561,13 @@ class ObservableQuery {
|
|
|
524
561
|
}
|
|
525
562
|
};
|
|
526
563
|
}
|
|
527
|
-
/**
|
|
564
|
+
/**
|
|
565
|
+
* @internal
|
|
566
|
+
*
|
|
567
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
568
|
+
*/
|
|
528
569
|
silentSetOptions(newOptions) {
|
|
529
|
-
const mergedOptions = (0,
|
|
570
|
+
const mergedOptions = (0, internal_1.compact)(this.options, newOptions || {});
|
|
530
571
|
assign(this.options, mergedOptions);
|
|
531
572
|
}
|
|
532
573
|
/**
|
|
@@ -553,12 +594,12 @@ class ObservableQuery {
|
|
|
553
594
|
// If we have no observers, then we don't actually want to make a network
|
|
554
595
|
// request. As soon as someone observes the query, the request will kick
|
|
555
596
|
// off. For now, we just store any changes. (See #1077)
|
|
556
|
-
return (0, internal_1.toQueryResult)(this.
|
|
597
|
+
return (0, internal_1.toQueryResult)(this.getCurrentResult());
|
|
557
598
|
}
|
|
558
599
|
this.options.variables = variables;
|
|
559
600
|
// See comment above
|
|
560
601
|
if (!this.hasObservers()) {
|
|
561
|
-
return (0, internal_1.toQueryResult)(this.
|
|
602
|
+
return (0, internal_1.toQueryResult)(this.getCurrentResult());
|
|
562
603
|
}
|
|
563
604
|
return this.reobserve({
|
|
564
605
|
// Reset options.fetchPolicy to its original value.
|
|
@@ -574,12 +615,7 @@ class ObservableQuery {
|
|
|
574
615
|
*/
|
|
575
616
|
updateQuery(mapFn) {
|
|
576
617
|
const { queryManager } = this;
|
|
577
|
-
const { result, complete } =
|
|
578
|
-
query: this.options.query,
|
|
579
|
-
variables: this.variables,
|
|
580
|
-
returnPartialData: true,
|
|
581
|
-
optimistic: false,
|
|
582
|
-
});
|
|
618
|
+
const { result, complete } = this.getCacheDiff({ optimistic: false });
|
|
583
619
|
const newResult = mapFn(result, {
|
|
584
620
|
variables: this.variables,
|
|
585
621
|
complete: !!complete,
|
|
@@ -642,12 +678,95 @@ class ObservableQuery {
|
|
|
642
678
|
}
|
|
643
679
|
return options.fetchPolicy;
|
|
644
680
|
}
|
|
645
|
-
fetch(options,
|
|
681
|
+
fetch(options, networkStatus, fetchQuery) {
|
|
646
682
|
// TODO Make sure we update the networkStatus (and infer fetchVariables)
|
|
647
683
|
// before actually committing to the fetch.
|
|
684
|
+
const initialFetchPolicy = this.options.fetchPolicy;
|
|
648
685
|
const queryInfo = this.queryManager.getOrCreateQuery(this.queryId);
|
|
649
686
|
queryInfo.setObservableQuery(this);
|
|
650
|
-
|
|
687
|
+
options.context ??= {};
|
|
688
|
+
let synchronouslyEmitted = false;
|
|
689
|
+
const onCacheHit = () => {
|
|
690
|
+
synchronouslyEmitted = true;
|
|
691
|
+
};
|
|
692
|
+
const fetchQueryOperator = // we cannot use `tap` here, since it allows only for a "before subscription"
|
|
693
|
+
|
|
694
|
+
// hook with `subscribe` and we care for "directly before and after subscription"
|
|
695
|
+
(source) => new rxjs_1.Observable((subscriber) => {
|
|
696
|
+
try {
|
|
697
|
+
return source.subscribe({
|
|
698
|
+
next(value) {
|
|
699
|
+
synchronouslyEmitted = true;
|
|
700
|
+
subscriber.next(value);
|
|
701
|
+
},
|
|
702
|
+
error: (error) => subscriber.error(error),
|
|
703
|
+
complete: () => subscriber.complete(),
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
finally {
|
|
707
|
+
if (!synchronouslyEmitted && this.activeOperations.has(operation)) {
|
|
708
|
+
operation.override = networkStatus;
|
|
709
|
+
this.input.next({
|
|
710
|
+
kind: "N",
|
|
711
|
+
source: "newNetworkStatus",
|
|
712
|
+
value: {
|
|
713
|
+
resetError: true,
|
|
714
|
+
},
|
|
715
|
+
query,
|
|
716
|
+
variables,
|
|
717
|
+
meta: {
|
|
718
|
+
shouldEmit: 3 /* EmitBehavior.networkStatusChange */,
|
|
719
|
+
/*
|
|
720
|
+
* The moment this notification is emitted, `nextFetchPolicy`
|
|
721
|
+
* might already have switched from a `network-only` to a
|
|
722
|
+
* `cache-something` policy, so we want to ensure that the
|
|
723
|
+
* loading state emit doesn't accidentally read from the cache
|
|
724
|
+
* in those cases.
|
|
725
|
+
*/
|
|
726
|
+
fetchPolicy: initialFetchPolicy,
|
|
727
|
+
},
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
const { observable, fromLink } = this.queryManager.fetchObservableWithInfo(queryInfo, options, { networkStatus, query: fetchQuery, onCacheHit, fetchQueryOperator });
|
|
733
|
+
// track query and variables from the start of the operation
|
|
734
|
+
const { query, variables } = this;
|
|
735
|
+
const operation = {
|
|
736
|
+
abort: () => subscription.unsubscribe(),
|
|
737
|
+
query,
|
|
738
|
+
variables,
|
|
739
|
+
};
|
|
740
|
+
this.activeOperations.add(operation);
|
|
741
|
+
let forceFirstValueEmit = networkStatus == networkStatus_js_1.NetworkStatus.refetch ||
|
|
742
|
+
networkStatus == networkStatus_js_1.NetworkStatus.setVariables;
|
|
743
|
+
const subscription = observable
|
|
744
|
+
.pipe((0, rxjs_1.tap)({
|
|
745
|
+
next: (notification) => {
|
|
746
|
+
if (notification.source === "newNetworkStatus" ||
|
|
747
|
+
(notification.kind === "N" && notification.value.loading)) {
|
|
748
|
+
operation.override = networkStatus;
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
delete operation.override;
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
finalize: () => this.activeOperations.delete(operation),
|
|
755
|
+
}))
|
|
756
|
+
.subscribe({
|
|
757
|
+
next: (value) => {
|
|
758
|
+
const meta = {};
|
|
759
|
+
if (forceFirstValueEmit &&
|
|
760
|
+
value.kind === "N" &&
|
|
761
|
+
"loading" in value.value &&
|
|
762
|
+
!value.value.loading) {
|
|
763
|
+
forceFirstValueEmit = false;
|
|
764
|
+
meta.shouldEmit = 1 /* EmitBehavior.force */;
|
|
765
|
+
}
|
|
766
|
+
this.input.next({ ...value, query, variables, meta });
|
|
767
|
+
},
|
|
768
|
+
});
|
|
769
|
+
return { fromLink, subscription, observable };
|
|
651
770
|
}
|
|
652
771
|
// Turns polling on or off based on this.options.pollInterval.
|
|
653
772
|
updatePolling() {
|
|
@@ -663,7 +782,7 @@ class ObservableQuery {
|
|
|
663
782
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
664
783
|
return;
|
|
665
784
|
}
|
|
666
|
-
(0, invariant_1.invariant)(pollInterval,
|
|
785
|
+
(0, invariant_1.invariant)(pollInterval, 80);
|
|
667
786
|
const info = pollingInfo || (this.pollingInfo = {});
|
|
668
787
|
info.interval = pollInterval;
|
|
669
788
|
const maybeFetch = () => {
|
|
@@ -702,20 +821,6 @@ class ObservableQuery {
|
|
|
702
821
|
delete this.pollingInfo;
|
|
703
822
|
}
|
|
704
823
|
}
|
|
705
|
-
updateLastResult(newResult, variables = this.variables) {
|
|
706
|
-
let error = this.getLastError();
|
|
707
|
-
// Preserve this.last.error unless the variables have changed.
|
|
708
|
-
if (error && this.last && !(0, equality_1.equal)(variables, this.last.variables)) {
|
|
709
|
-
error = void 0;
|
|
710
|
-
}
|
|
711
|
-
return (this.last = {
|
|
712
|
-
result: this.queryManager.assumeImmutableResults ?
|
|
713
|
-
newResult
|
|
714
|
-
: (0, utilities_1.cloneDeep)(newResult),
|
|
715
|
-
variables,
|
|
716
|
-
...(error ? { error } : null),
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
824
|
/**
|
|
720
825
|
* Reevaluate the query, optionally against new options. New options will be
|
|
721
826
|
* merged with the current options when given.
|
|
@@ -730,19 +835,16 @@ class ObservableQuery {
|
|
|
730
835
|
}
|
|
731
836
|
const useDisposableObservable =
|
|
732
837
|
// Refetching uses a disposable Observable to allow refetches using different
|
|
733
|
-
// options
|
|
838
|
+
// options, without permanently altering the options of the
|
|
734
839
|
// original ObservableQuery.
|
|
735
840
|
newNetworkStatus === networkStatus_js_1.NetworkStatus.refetch ||
|
|
736
|
-
// The fetchMore method does not actually call the reobserve method, but,
|
|
737
|
-
// if it did, it would definitely use a disposable Observable.
|
|
738
|
-
newNetworkStatus === networkStatus_js_1.NetworkStatus.fetchMore ||
|
|
739
841
|
// Polling uses a disposable Observable so the polling options (which force
|
|
740
842
|
// fetchPolicy to be "network-only" or "no-cache") won't override the original options.
|
|
741
843
|
newNetworkStatus === networkStatus_js_1.NetworkStatus.poll;
|
|
742
844
|
// Save the old variables, since Object.assign may modify them below.
|
|
743
845
|
const oldVariables = this.variables;
|
|
744
846
|
const oldFetchPolicy = this.options.fetchPolicy;
|
|
745
|
-
const mergedOptions = (0,
|
|
847
|
+
const mergedOptions = (0, internal_1.compact)(this.options, newOptions || {});
|
|
746
848
|
const options = useDisposableObservable ?
|
|
747
849
|
// Disposable Observable fetches receive a shallow copy of this.options
|
|
748
850
|
// (merged with newOptions), leaving this.options unmodified.
|
|
@@ -804,47 +906,27 @@ class ObservableQuery {
|
|
|
804
906
|
if (options.fetchPolicy === "standby") {
|
|
805
907
|
this.cancelPolling();
|
|
806
908
|
}
|
|
807
|
-
this.
|
|
808
|
-
this.
|
|
809
|
-
const finishWaitingForOwnResult = () => {
|
|
810
|
-
if (this.linkObservable === observable) {
|
|
811
|
-
this.waitForOwnResult = false;
|
|
812
|
-
}
|
|
813
|
-
};
|
|
814
|
-
const variables = { ...options.variables };
|
|
815
|
-
const { notifyOnNetworkStatusChange = true } = options;
|
|
816
|
-
const { observable, fromLink } = this.fetch(options, newNetworkStatus, notifyOnNetworkStatusChange &&
|
|
817
|
-
oldNetworkStatus !== newNetworkStatus &&
|
|
818
|
-
(0, networkStatus_js_1.isNetworkRequestInFlight)(newNetworkStatus), query);
|
|
819
|
-
const observer = {
|
|
820
|
-
next: (result) => {
|
|
821
|
-
if ((0, equality_1.equal)(this.variables, variables)) {
|
|
822
|
-
finishWaitingForOwnResult();
|
|
823
|
-
this.reportResult(result, variables);
|
|
824
|
-
}
|
|
825
|
-
},
|
|
826
|
-
error: (error) => {
|
|
827
|
-
if ((0, equality_1.equal)(this.variables, variables)) {
|
|
828
|
-
finishWaitingForOwnResult();
|
|
829
|
-
this.reportError(error, variables);
|
|
830
|
-
}
|
|
831
|
-
},
|
|
832
|
-
};
|
|
909
|
+
this.resubscribeCache();
|
|
910
|
+
const { subscription, observable, fromLink } = this.fetch(options, newNetworkStatus, query);
|
|
833
911
|
if (!useDisposableObservable && (fromLink || !this.linkSubscription)) {
|
|
834
912
|
if (this.linkSubscription) {
|
|
835
913
|
this.linkSubscription.unsubscribe();
|
|
836
914
|
}
|
|
837
|
-
this.
|
|
838
|
-
this.linkSubscription = observable.subscribe(observer);
|
|
915
|
+
this.linkSubscription = subscription;
|
|
839
916
|
}
|
|
840
|
-
|
|
841
|
-
observable.subscribe(observer);
|
|
842
|
-
}
|
|
843
|
-
return (0, utilities_1.preventUnhandledRejection)(
|
|
917
|
+
return (0, internal_1.preventUnhandledRejection)(
|
|
844
918
|
// Note: lastValueFrom will create a separate subscription to the
|
|
845
919
|
// observable which means that terminating this ObservableQuery will not
|
|
846
920
|
// cancel the request from the link chain.
|
|
847
|
-
(0, rxjs_1.lastValueFrom)(observable, {
|
|
921
|
+
(0, rxjs_1.lastValueFrom)(observable.pipe((0, internal_1.filterMap)((value) => {
|
|
922
|
+
switch (value.kind) {
|
|
923
|
+
case "E":
|
|
924
|
+
throw value.error;
|
|
925
|
+
case "N":
|
|
926
|
+
if (value.source !== "newNetworkStatus")
|
|
927
|
+
return value.value;
|
|
928
|
+
}
|
|
929
|
+
})), {
|
|
848
930
|
// This default value should only be used when using a `fetchPolicy` of
|
|
849
931
|
// `standby` since that fetch policy completes without emitting a
|
|
850
932
|
// result. Since we are converting this to a QueryResult type, we
|
|
@@ -852,54 +934,16 @@ class ObservableQuery {
|
|
|
852
934
|
defaultValue: { data: undefined },
|
|
853
935
|
}).then((result) => (0, internal_1.toQueryResult)(this.maskResult(result))));
|
|
854
936
|
}
|
|
855
|
-
// (Re)deliver the current result to this.observers without applying fetch
|
|
856
|
-
// policies or making network requests.
|
|
857
|
-
observe() {
|
|
858
|
-
this.reportResult(
|
|
859
|
-
// Passing false is important so that this.getCurrentResult doesn't
|
|
860
|
-
// save the fetchMore result as this.lastResult, causing it to be
|
|
861
|
-
// ignored due to the this.isDifferentFromLastResult check in
|
|
862
|
-
// this.reportResult.
|
|
863
|
-
this.getCurrentFullResult(false), this.variables);
|
|
864
|
-
}
|
|
865
|
-
reportResult(result, variables) {
|
|
866
|
-
const lastError = this.getLastError();
|
|
867
|
-
const isDifferent = this.isDifferentFromLastResult(result, variables);
|
|
868
|
-
// Update the last result even when isDifferentFromLastResult returns false,
|
|
869
|
-
// because the query may be using the @nonreactive directive, and we want to
|
|
870
|
-
// save the the latest version of any nonreactive subtrees (in case
|
|
871
|
-
// getCurrentResult is called), even though we skip broadcasting changes.
|
|
872
|
-
this.updateLastResult(result, variables);
|
|
873
|
-
this.networkStatus = result.networkStatus;
|
|
874
|
-
if (lastError || isDifferent) {
|
|
875
|
-
this.subject.next(this.maskResult(result));
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
reportError(error, variables) {
|
|
879
|
-
// Since we don't get the current result on errors, only the error, we
|
|
880
|
-
// must mirror the updates that occur in QueryStore.markQueryError here
|
|
881
|
-
const errorResult = {
|
|
882
|
-
data: undefined,
|
|
883
|
-
partial: true,
|
|
884
|
-
...this.getLastResult(),
|
|
885
|
-
error,
|
|
886
|
-
networkStatus: networkStatus_js_1.NetworkStatus.error,
|
|
887
|
-
loading: false,
|
|
888
|
-
};
|
|
889
|
-
this.updateLastResult(errorResult, variables);
|
|
890
|
-
this.networkStatus = networkStatus_js_1.NetworkStatus.error;
|
|
891
|
-
this.last.error = error;
|
|
892
|
-
this.subject.next(errorResult);
|
|
893
|
-
}
|
|
894
937
|
hasObservers() {
|
|
895
938
|
return this.subject.observed;
|
|
896
939
|
}
|
|
897
940
|
tearDownQuery() {
|
|
898
941
|
if (this.isTornDown)
|
|
899
942
|
return;
|
|
900
|
-
|
|
943
|
+
this.resetNotifications();
|
|
944
|
+
this.unsubscribeFromCache?.();
|
|
945
|
+
if (this.linkSubscription) {
|
|
901
946
|
this.linkSubscription.unsubscribe();
|
|
902
|
-
delete this.linkObservable;
|
|
903
947
|
delete this.linkSubscription;
|
|
904
948
|
}
|
|
905
949
|
this.stopPolling();
|
|
@@ -908,6 +952,7 @@ class ObservableQuery {
|
|
|
908
952
|
this.subscriptions.clear();
|
|
909
953
|
this.queryManager.removeQuery(this.queryId);
|
|
910
954
|
this.isTornDown = true;
|
|
955
|
+
this.abortActiveOperations();
|
|
911
956
|
}
|
|
912
957
|
transformDocument(document) {
|
|
913
958
|
return this.queryManager.transform(document);
|
|
@@ -927,57 +972,231 @@ class ObservableQuery {
|
|
|
927
972
|
}
|
|
928
973
|
dirty = false;
|
|
929
974
|
notifyTimeout;
|
|
930
|
-
/**
|
|
975
|
+
/**
|
|
976
|
+
* @internal
|
|
977
|
+
*
|
|
978
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
979
|
+
*/
|
|
931
980
|
resetNotifications() {
|
|
932
|
-
this.cancelNotifyTimeout();
|
|
933
|
-
this.dirty = false;
|
|
934
|
-
}
|
|
935
|
-
cancelNotifyTimeout() {
|
|
936
981
|
if (this.notifyTimeout) {
|
|
937
982
|
clearTimeout(this.notifyTimeout);
|
|
938
983
|
this.notifyTimeout = void 0;
|
|
939
984
|
}
|
|
985
|
+
this.dirty = false;
|
|
940
986
|
}
|
|
941
|
-
/**
|
|
987
|
+
/**
|
|
988
|
+
* @internal
|
|
989
|
+
*
|
|
990
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
991
|
+
*/
|
|
942
992
|
scheduleNotify() {
|
|
943
993
|
if (this.dirty)
|
|
944
994
|
return;
|
|
945
995
|
this.dirty = true;
|
|
946
996
|
if (!this.notifyTimeout) {
|
|
947
|
-
this.notifyTimeout = setTimeout(() => this.notify(), 0);
|
|
997
|
+
this.notifyTimeout = setTimeout(() => this.notify(true), 0);
|
|
948
998
|
}
|
|
949
999
|
}
|
|
950
|
-
/**
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1000
|
+
/**
|
|
1001
|
+
* @internal
|
|
1002
|
+
*
|
|
1003
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
1004
|
+
*/
|
|
1005
|
+
notify(scheduled = false) {
|
|
1006
|
+
if (!scheduled) {
|
|
1007
|
+
// For queries with client exports or forced resolvers, we don't want to
|
|
1008
|
+
// synchronously reobserve the cache on broadcast,
|
|
1009
|
+
// but actually wait for the `scheduleNotify` timeout triggered by the
|
|
1010
|
+
// `cache.watch` callback from `resubscribeCache`.
|
|
1011
|
+
const info = this.queryManager.getDocumentInfo(this.query);
|
|
1012
|
+
if (info.hasClientExports || info.hasForcedResolvers) {
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
const { dirty } = this;
|
|
1017
|
+
this.resetNotifications();
|
|
1018
|
+
if (dirty &&
|
|
1019
|
+
(this.options.fetchPolicy == "cache-only" ||
|
|
955
1020
|
this.options.fetchPolicy == "cache-and-network" ||
|
|
956
|
-
!
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1021
|
+
!this.activeOperations.size)) {
|
|
1022
|
+
const diff = this.getCacheDiff();
|
|
1023
|
+
if (
|
|
1024
|
+
// `fromOptimisticTransaction` is not avaiable through the `cache.diff`
|
|
1025
|
+
// code path, so we need to check it this way
|
|
1026
|
+
(0, equality_1.equal)(diff.result, this.getCacheDiff({ optimistic: false }).result)) {
|
|
1027
|
+
//If this diff did not come from an optimistic transaction
|
|
1028
|
+
// make the ObservableQuery "reobserve" the latest data
|
|
1029
|
+
// using a temporary fetch policy of "cache-first", so complete cache
|
|
1030
|
+
// results have a chance to be delivered without triggering additional
|
|
1031
|
+
// network requests, even when options.fetchPolicy is "network-only"
|
|
1032
|
+
// or "cache-and-network". All other fetch policies are preserved by
|
|
1033
|
+
// this method, and are handled by calling oq.reobserve(). If this
|
|
1034
|
+
// reobservation is spurious, distinctUntilChanged still has a
|
|
1035
|
+
// chance to catch it before delivery to ObservableQuery subscribers.
|
|
1036
|
+
this.reobserveCacheFirst();
|
|
1037
|
+
}
|
|
1038
|
+
else {
|
|
1039
|
+
// If this diff came from an optimistic transaction, deliver the
|
|
1040
|
+
// current cache data to the ObservableQuery, but don't perform a
|
|
1041
|
+
// reobservation, since oq.reobserveCacheFirst might make a network
|
|
1042
|
+
// request, and we never want to trigger network requests in the
|
|
1043
|
+
// middle of optimistic updates.
|
|
1044
|
+
this.input.next({
|
|
1045
|
+
kind: "N",
|
|
1046
|
+
value: {
|
|
1047
|
+
data: diff.result,
|
|
1048
|
+
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
1049
|
+
loading: false,
|
|
1050
|
+
error: undefined,
|
|
1051
|
+
partial: !diff.complete,
|
|
1052
|
+
},
|
|
1053
|
+
source: "cache",
|
|
1054
|
+
query: this.query,
|
|
1055
|
+
variables: this.variables,
|
|
1056
|
+
meta: {},
|
|
1057
|
+
});
|
|
977
1058
|
}
|
|
978
1059
|
}
|
|
979
|
-
this.dirty = false;
|
|
980
1060
|
}
|
|
1061
|
+
activeOperations = new Set();
|
|
1062
|
+
pushOperation(networkStatus) {
|
|
1063
|
+
let aborted = false;
|
|
1064
|
+
// track query and variables from the start of the operation
|
|
1065
|
+
const { query, variables } = this;
|
|
1066
|
+
const finalize = () => {
|
|
1067
|
+
this.activeOperations.delete(operation);
|
|
1068
|
+
};
|
|
1069
|
+
const operation = {
|
|
1070
|
+
override: networkStatus,
|
|
1071
|
+
abort: () => {
|
|
1072
|
+
aborted = true;
|
|
1073
|
+
finalize();
|
|
1074
|
+
},
|
|
1075
|
+
query,
|
|
1076
|
+
variables,
|
|
1077
|
+
};
|
|
1078
|
+
this.activeOperations.add(operation);
|
|
1079
|
+
return {
|
|
1080
|
+
finalize,
|
|
1081
|
+
pushNotification: (notification, additionalMeta) => {
|
|
1082
|
+
if (!aborted) {
|
|
1083
|
+
this.input.next({
|
|
1084
|
+
...notification,
|
|
1085
|
+
query,
|
|
1086
|
+
variables,
|
|
1087
|
+
meta: { ...additionalMeta },
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
calculateNetworkStatus(baseNetworkStatus) {
|
|
1094
|
+
// in the future, this could be more complex logic, e.g. "refetch" and
|
|
1095
|
+
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1096
|
+
// as for now we just take the "latest" operation that is still active,
|
|
1097
|
+
// as that lines up best with previous behavior[]
|
|
1098
|
+
const operation = Array.from(this.activeOperations.values()).findLast((operation) => isEqualQuery(operation, this) && operation.override !== undefined);
|
|
1099
|
+
return operation?.override ?? baseNetworkStatus;
|
|
1100
|
+
}
|
|
1101
|
+
abortActiveOperations() {
|
|
1102
|
+
this.activeOperations.forEach((operation) => operation.abort());
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* @internal
|
|
1106
|
+
* Called from `clearStore`.
|
|
1107
|
+
* * resets the query to its initial state
|
|
1108
|
+
* * cancels all active operations and their subscriptions
|
|
1109
|
+
*
|
|
1110
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
1111
|
+
*/
|
|
1112
|
+
reset() {
|
|
1113
|
+
// exception for cache-only queries - we reset them into a "ready" state
|
|
1114
|
+
// as we won't trigger a refetch for them
|
|
1115
|
+
const resetToEmpty = this.options.fetchPolicy === "cache-only";
|
|
1116
|
+
this.setResult(resetToEmpty ? empty : uninitialized, {
|
|
1117
|
+
shouldEmit: resetToEmpty ? 1 /* EmitBehavior.force */ : 2 /* EmitBehavior.never */,
|
|
1118
|
+
});
|
|
1119
|
+
this.abortActiveOperations();
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* @internal
|
|
1123
|
+
*
|
|
1124
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
1125
|
+
*/
|
|
1126
|
+
setResult(result, additionalMeta) {
|
|
1127
|
+
this.input.next({
|
|
1128
|
+
source: "setResult",
|
|
1129
|
+
kind: "N",
|
|
1130
|
+
value: result,
|
|
1131
|
+
query: this.query,
|
|
1132
|
+
variables: this.variables,
|
|
1133
|
+
meta: { ...additionalMeta },
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
operator = (0, internal_1.filterMap)((notification) => {
|
|
1137
|
+
const { query, variables, meta } = notification;
|
|
1138
|
+
if (notification.source === "setResult") {
|
|
1139
|
+
return { query, variables, result: notification.value, meta };
|
|
1140
|
+
}
|
|
1141
|
+
if (notification.kind === "C" || !isEqualQuery(notification, this)) {
|
|
1142
|
+
return;
|
|
1143
|
+
}
|
|
1144
|
+
let result;
|
|
1145
|
+
const previous = this.subject.getValue();
|
|
1146
|
+
if (notification.source === "cache") {
|
|
1147
|
+
result = notification.value;
|
|
1148
|
+
if (result.networkStatus === networkStatus_js_1.NetworkStatus.ready &&
|
|
1149
|
+
result.partial &&
|
|
1150
|
+
(!this.options.returnPartialData ||
|
|
1151
|
+
previous.result.networkStatus === networkStatus_js_1.NetworkStatus.error) &&
|
|
1152
|
+
this.options.fetchPolicy !== "cache-only") {
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
else if (notification.source === "network") {
|
|
1157
|
+
if (this.waitForNetworkResult) {
|
|
1158
|
+
this.waitForNetworkResult = false;
|
|
1159
|
+
this.resubscribeCache();
|
|
1160
|
+
}
|
|
1161
|
+
result =
|
|
1162
|
+
notification.kind === "E" ?
|
|
1163
|
+
{
|
|
1164
|
+
data: undefined,
|
|
1165
|
+
partial: true,
|
|
1166
|
+
...(isEqualQuery(previous, notification) ? previous.result : {}),
|
|
1167
|
+
error: notification.error,
|
|
1168
|
+
networkStatus: networkStatus_js_1.NetworkStatus.error,
|
|
1169
|
+
loading: false,
|
|
1170
|
+
}
|
|
1171
|
+
: notification.value;
|
|
1172
|
+
if (result.error) {
|
|
1173
|
+
meta.shouldEmit = 1 /* EmitBehavior.force */;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
else if (notification.source === "newNetworkStatus") {
|
|
1177
|
+
const baseResult = isEqualQuery(previous, notification) ?
|
|
1178
|
+
previous.result
|
|
1179
|
+
: this.getInitialResult(meta.fetchPolicy);
|
|
1180
|
+
const { resetError } = notification.value;
|
|
1181
|
+
const error = resetError ? undefined : baseResult.error;
|
|
1182
|
+
const networkStatus = error ? networkStatus_js_1.NetworkStatus.error : networkStatus_js_1.NetworkStatus.ready;
|
|
1183
|
+
result = {
|
|
1184
|
+
...baseResult,
|
|
1185
|
+
error,
|
|
1186
|
+
networkStatus,
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
// every code path until here should have either returned or set a result,
|
|
1190
|
+
// but typescript needs a little help
|
|
1191
|
+
(0, invariant_1.invariant)(result);
|
|
1192
|
+
// normalize result shape
|
|
1193
|
+
if (!result.error)
|
|
1194
|
+
delete result.error;
|
|
1195
|
+
result.networkStatus = this.calculateNetworkStatus(result.networkStatus);
|
|
1196
|
+
result.loading = (0, networkStatus_js_1.isNetworkRequestInFlight)(result.networkStatus);
|
|
1197
|
+
result = this.maskResult(result);
|
|
1198
|
+
return { query, variables, result, meta };
|
|
1199
|
+
});
|
|
981
1200
|
// Reobserve with fetchPolicy effectively set to "cache-first", triggering
|
|
982
1201
|
// delivery of any new data from the cache, possibly falling back to the network
|
|
983
1202
|
// if any cache data are missing. This allows _complete_ cache results to be
|
|
@@ -1015,12 +1234,10 @@ class ObservableQuery {
|
|
|
1015
1234
|
exports.ObservableQuery = ObservableQuery;
|
|
1016
1235
|
function logMissingFieldErrors(missing) {
|
|
1017
1236
|
if (environment_1.__DEV__ && missing) {
|
|
1018
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1237
|
+
__DEV__ && invariant_1.invariant.debug(81, missing);
|
|
1019
1238
|
}
|
|
1020
1239
|
}
|
|
1021
|
-
function
|
|
1022
|
-
return (
|
|
1023
|
-
fetchPolicy === "no-cache" ||
|
|
1024
|
-
fetchPolicy === "standby");
|
|
1240
|
+
function isEqualQuery(a, b) {
|
|
1241
|
+
return !!(a && b && a.query === b.query && (0, equality_1.equal)(a.variables, b.variables));
|
|
1025
1242
|
}
|
|
1026
1243
|
//# sourceMappingURL=ObservableQuery.cjs.map
|