@apollo/client 4.0.0-alpha.13 → 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/few-crabs-move.md +6 -0
- package/.changeset/funny-boats-wink.md +35 -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 +13 -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 +134 -0
- package/__cjs/cache/core/cache.cjs +9 -7
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +9 -7
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +9 -7
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +23 -45
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +9 -21
- package/__cjs/core/ObservableQuery.cjs +564 -346
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +95 -33
- package/__cjs/core/QueryInfo.cjs +109 -179
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +9 -14
- package/__cjs/core/QueryManager.cjs +168 -108
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +12 -8
- package/__cjs/core/index.cjs +2 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +2 -3
- package/__cjs/core/types.d.cts +18 -6
- 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 +130 -57
- 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 +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/utils/transformOperation.cjs +1 -1
- 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/maskFragment.cjs +5 -1
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/masking/maskFragment.d.cts +5 -1
- package/__cjs/masking/maskOperation.cjs +5 -1
- package/__cjs/masking/maskOperation.cjs.map +1 -1
- package/__cjs/masking/maskOperation.d.cts +5 -1
- package/__cjs/masking/utils.cjs +5 -1
- package/__cjs/masking/utils.cjs.map +1 -1
- package/__cjs/masking/utils.d.cts +5 -1
- 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/internal/cache/QueryReference.cjs +6 -9
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +25 -7
- package/__cjs/react/ssr/prerenderStatic.cjs +7 -0
- package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.cjs +7 -3
- 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 +2 -2
- 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/toRerenderWithSimilarSnapshot.cjs +31 -18
- package/__cjs/testing/matchers/toRerenderWithSimilarSnapshot.cjs.map +1 -1
- package/__cjs/testing/matchers/toRerenderWithSimilarSnapshot.d.cts +13 -6
- 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 +14 -2
- 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/graphql/DocumentTransform.cjs +10 -6
- package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
- package/__cjs/utilities/graphql/DocumentTransform.d.cts +10 -6
- package/__cjs/utilities/internal/DeepMerger.cjs +5 -1
- package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
- package/__cjs/utilities/internal/DeepMerger.d.cts +5 -1
- package/__cjs/utilities/internal/argumentsObjectFromField.cjs +5 -1
- package/__cjs/utilities/internal/argumentsObjectFromField.cjs.map +1 -1
- package/__cjs/utilities/internal/argumentsObjectFromField.d.cts +5 -1
- package/__cjs/utilities/internal/caches.cjs +24 -20
- package/__cjs/utilities/internal/caches.cjs.map +1 -1
- package/__cjs/utilities/internal/caches.d.cts +32 -24
- package/__cjs/utilities/internal/canUseDOM.cjs +5 -1
- package/__cjs/utilities/internal/canUseDOM.cjs.map +1 -1
- package/__cjs/utilities/internal/canUseDOM.d.cts +5 -1
- package/__cjs/utilities/internal/checkDocument.cjs +6 -3
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/checkDocument.d.cts +6 -3
- package/__cjs/utilities/internal/cloneDeep.cjs +6 -4
- package/__cjs/utilities/internal/cloneDeep.cjs.map +1 -1
- package/__cjs/utilities/internal/cloneDeep.d.cts +6 -4
- package/__cjs/utilities/internal/compact.cjs +7 -5
- package/__cjs/utilities/internal/compact.cjs.map +1 -1
- package/__cjs/utilities/internal/compact.d.cts +7 -5
- package/__cjs/utilities/internal/createFragmentMap.cjs +7 -4
- package/__cjs/utilities/internal/createFragmentMap.cjs.map +1 -1
- package/__cjs/utilities/internal/createFragmentMap.d.cts +7 -4
- package/__cjs/utilities/internal/createFulfilledPromise.cjs +5 -1
- package/__cjs/utilities/internal/createFulfilledPromise.cjs.map +1 -1
- package/__cjs/utilities/internal/createFulfilledPromise.d.cts +5 -1
- package/__cjs/utilities/internal/createRejectedPromise.cjs +5 -1
- package/__cjs/utilities/internal/createRejectedPromise.cjs.map +1 -1
- package/__cjs/utilities/internal/createRejectedPromise.d.cts +5 -1
- 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/__cjs/utilities/internal/decoratePromise.cjs +5 -1
- package/__cjs/utilities/internal/decoratePromise.cjs.map +1 -1
- package/__cjs/utilities/internal/decoratePromise.d.cts +5 -1
- package/__cjs/utilities/internal/deepFreeze.cjs +5 -1
- package/__cjs/utilities/internal/deepFreeze.cjs.map +1 -1
- package/__cjs/utilities/internal/deepFreeze.d.cts +5 -1
- 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 +5 -1
- package/__cjs/utilities/internal/getDefaultValues.cjs.map +1 -1
- package/__cjs/utilities/internal/getDefaultValues.d.cts +5 -1
- package/__cjs/utilities/internal/getFragmentDefinition.cjs +5 -1
- package/__cjs/utilities/internal/getFragmentDefinition.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentDefinition.d.cts +5 -1
- package/__cjs/utilities/internal/getFragmentDefinitions.cjs +5 -1
- package/__cjs/utilities/internal/getFragmentDefinitions.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentDefinitions.d.cts +5 -1
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +5 -1
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentFromSelection.d.cts +5 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +25 -23
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.d.cts +25 -23
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs +5 -1
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs.map +1 -1
- package/__cjs/utilities/internal/getGraphQLErrorsFromResult.d.cts +5 -1
- package/__cjs/utilities/internal/getMainDefinition.cjs +8 -6
- package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -1
- package/__cjs/utilities/internal/getMainDefinition.d.cts +8 -6
- 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 +5 -1
- package/__cjs/utilities/internal/getOperationDefinition.cjs.map +1 -1
- package/__cjs/utilities/internal/getOperationDefinition.d.cts +5 -1
- package/__cjs/utilities/internal/getOperationName.cjs +7 -5
- package/__cjs/utilities/internal/getOperationName.cjs.map +1 -1
- package/__cjs/utilities/internal/getOperationName.d.cts +6 -2
- package/__cjs/utilities/internal/getQueryDefinition.cjs +5 -1
- package/__cjs/utilities/internal/getQueryDefinition.cjs.map +1 -1
- package/__cjs/utilities/internal/getQueryDefinition.d.cts +5 -1
- package/__cjs/utilities/internal/getStoreKeyName.cjs +5 -1
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
- package/__cjs/utilities/internal/getStoreKeyName.d.cts +5 -1
- package/__cjs/utilities/internal/graphQLResultHasError.cjs +5 -1
- package/__cjs/utilities/internal/graphQLResultHasError.cjs.map +1 -1
- package/__cjs/utilities/internal/graphQLResultHasError.d.cts +5 -1
- package/__cjs/utilities/internal/hasDirectives.cjs +5 -1
- package/__cjs/utilities/internal/hasDirectives.cjs.map +1 -1
- package/__cjs/utilities/internal/hasDirectives.d.cts +5 -1
- 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 +8 -4
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +3 -1
- package/__cjs/utilities/internal/isArray.cjs +6 -4
- package/__cjs/utilities/internal/isArray.cjs.map +1 -1
- package/__cjs/utilities/internal/isArray.d.cts +6 -4
- package/__cjs/utilities/internal/isDocumentNode.cjs +5 -1
- package/__cjs/utilities/internal/isDocumentNode.cjs.map +1 -1
- package/__cjs/utilities/internal/isDocumentNode.d.cts +5 -1
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs +5 -1
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs.map +1 -1
- package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.d.cts +5 -1
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs +5 -1
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs.map +1 -1
- package/__cjs/utilities/internal/isExecutionPatchIninitialResult.d.cts +5 -1
- package/__cjs/utilities/internal/isExecutionPatchResult.cjs +5 -1
- package/__cjs/utilities/internal/isExecutionPatchResult.cjs.map +1 -1
- package/__cjs/utilities/internal/isExecutionPatchResult.d.cts +5 -1
- package/__cjs/utilities/internal/isField.cjs +5 -1
- package/__cjs/utilities/internal/isField.cjs.map +1 -1
- package/__cjs/utilities/internal/isField.d.cts +5 -1
- package/__cjs/utilities/internal/isNonEmptyArray.cjs +5 -1
- package/__cjs/utilities/internal/isNonEmptyArray.cjs.map +1 -1
- package/__cjs/utilities/internal/isNonEmptyArray.d.cts +5 -1
- package/__cjs/utilities/internal/isNonNullObject.cjs +5 -1
- package/__cjs/utilities/internal/isNonNullObject.cjs.map +1 -1
- package/__cjs/utilities/internal/isNonNullObject.d.cts +5 -1
- package/__cjs/utilities/internal/isPlainObject.cjs +5 -1
- package/__cjs/utilities/internal/isPlainObject.cjs.map +1 -1
- package/__cjs/utilities/internal/isPlainObject.d.cts +5 -1
- package/__cjs/utilities/internal/makeReference.cjs +5 -1
- package/__cjs/utilities/internal/makeReference.cjs.map +1 -1
- package/__cjs/utilities/internal/makeReference.d.cts +5 -1
- package/__cjs/utilities/internal/makeUniqueId.cjs +7 -5
- package/__cjs/utilities/internal/makeUniqueId.cjs.map +1 -1
- package/__cjs/utilities/internal/makeUniqueId.d.cts +7 -5
- package/__cjs/utilities/internal/maybeDeepFreeze.cjs +5 -1
- package/__cjs/utilities/internal/maybeDeepFreeze.cjs.map +1 -1
- package/__cjs/utilities/internal/maybeDeepFreeze.d.cts +5 -1
- package/__cjs/utilities/internal/mergeDeep.cjs +5 -1
- package/__cjs/utilities/internal/mergeDeep.cjs.map +1 -1
- package/__cjs/utilities/internal/mergeDeep.d.cts +5 -1
- package/__cjs/utilities/internal/mergeDeepArray.cjs +5 -1
- package/__cjs/utilities/internal/mergeDeepArray.cjs.map +1 -1
- package/__cjs/utilities/internal/mergeDeepArray.d.cts +5 -1
- package/__cjs/utilities/internal/mergeIncrementalData.cjs +5 -1
- package/__cjs/utilities/internal/mergeIncrementalData.cjs.map +1 -1
- package/__cjs/utilities/internal/mergeIncrementalData.d.cts +5 -1
- package/__cjs/utilities/internal/mergeOptions.cjs +5 -1
- package/__cjs/utilities/internal/mergeOptions.cjs.map +1 -1
- package/__cjs/utilities/internal/mergeOptions.d.cts +5 -1
- package/__cjs/utilities/internal/omitDeep.cjs +5 -1
- package/__cjs/utilities/internal/omitDeep.cjs.map +1 -1
- package/__cjs/utilities/internal/omitDeep.d.cts +5 -1
- package/__cjs/utilities/internal/onAnyEvent.cjs +5 -1
- package/__cjs/utilities/internal/onAnyEvent.cjs.map +1 -1
- package/__cjs/utilities/internal/onAnyEvent.d.cts +5 -1
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +5 -1
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/removeDirectivesFromDocument.d.cts +5 -1
- package/__cjs/utilities/internal/resultKeyNameFromField.cjs +5 -1
- package/__cjs/utilities/internal/resultKeyNameFromField.cjs.map +1 -1
- package/__cjs/utilities/internal/resultKeyNameFromField.d.cts +5 -1
- package/__cjs/utilities/internal/shouldInclude.cjs +5 -1
- package/__cjs/utilities/internal/shouldInclude.cjs.map +1 -1
- package/__cjs/utilities/internal/shouldInclude.d.cts +5 -1
- package/__cjs/utilities/internal/storeKeyNameFromField.cjs +5 -1
- package/__cjs/utilities/internal/storeKeyNameFromField.cjs.map +1 -1
- package/__cjs/utilities/internal/storeKeyNameFromField.d.cts +5 -1
- package/__cjs/utilities/internal/stringifyForDisplay.cjs +5 -1
- package/__cjs/utilities/internal/stringifyForDisplay.cjs.map +1 -1
- package/__cjs/utilities/internal/stringifyForDisplay.d.cts +5 -1
- package/__cjs/utilities/internal/toQueryResult.cjs +5 -1
- package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -1
- package/__cjs/utilities/internal/toQueryResult.d.cts +5 -1
- package/__cjs/utilities/internal/types/DecoratedPromise.d.cts +5 -1
- package/__cjs/utilities/internal/types/DeepOmit.d.cts +5 -1
- package/__cjs/utilities/internal/types/DeepPartial.d.cts +5 -1
- package/__cjs/utilities/internal/types/FragmentMap.d.cts +6 -4
- package/__cjs/utilities/internal/types/FragmentMapFunction.d.cts +5 -1
- package/__cjs/utilities/internal/types/FulfilledPromise.d.cts +5 -1
- package/__cjs/utilities/internal/types/IsAny.d.cts +5 -1
- package/__cjs/utilities/internal/types/PendingPromise.d.cts +5 -1
- package/__cjs/utilities/internal/types/Prettify.d.cts +5 -1
- package/__cjs/utilities/internal/types/Primitive.d.cts +5 -1
- package/__cjs/utilities/internal/types/RejectedPromise.d.cts +5 -1
- package/__cjs/utilities/internal/types/RemoveIndexSignature.d.cts +5 -1
- package/__cjs/utilities/internal/types/VariablesOption.d.cts +5 -1
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +5 -1
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs.map +1 -1
- package/__cjs/utilities/internal/valueToObjectRepresentation.d.cts +5 -1
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +9 -7
- package/cache/core/cache.js +9 -7
- package/cache/core/cache.js.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/inMemoryCache.d.ts +9 -7
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.js +4 -4
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +9 -21
- package/core/ApolloClient.js +23 -45
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +95 -33
- package/core/ObservableQuery.js +569 -351
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +9 -14
- package/core/QueryInfo.js +109 -179
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +12 -8
- package/core/QueryManager.js +151 -110
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +2 -3
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/types.d.ts +18 -6
- 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 +130 -57
- 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/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 +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/utils/transformOperation.js +1 -1
- 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/maskFragment.d.ts +5 -1
- package/masking/maskFragment.js +5 -1
- package/masking/maskFragment.js.map +1 -1
- package/masking/maskOperation.d.ts +5 -1
- package/masking/maskOperation.js +5 -1
- package/masking/maskOperation.js.map +1 -1
- package/masking/utils.d.ts +5 -1
- package/masking/utils.js +5 -1
- package/masking/utils.js.map +1 -1
- package/package.json +11 -1
- 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/internal/cache/QueryReference.d.ts +25 -7
- package/react/internal/cache/QueryReference.js +6 -9
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/ssr/prerenderStatic.js +7 -0
- package/react/ssr/prerenderStatic.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +10 -2
- package/testing/core/mocking/mockLink.js +9 -5
- 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 +2 -2
- 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/toRerenderWithSimilarSnapshot.d.ts +13 -6
- package/testing/matchers/toRerenderWithSimilarSnapshot.js +30 -15
- package/testing/matchers/toRerenderWithSimilarSnapshot.js.map +1 -1
- 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 +14 -2
- 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/graphql/DocumentTransform.d.ts +10 -6
- package/utilities/graphql/DocumentTransform.js +10 -6
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/internal/DeepMerger.d.ts +5 -1
- package/utilities/internal/DeepMerger.js +5 -1
- package/utilities/internal/DeepMerger.js.map +1 -1
- package/utilities/internal/argumentsObjectFromField.d.ts +5 -1
- package/utilities/internal/argumentsObjectFromField.js +5 -1
- package/utilities/internal/argumentsObjectFromField.js.map +1 -1
- package/utilities/internal/caches.d.ts +32 -24
- package/utilities/internal/caches.js +24 -20
- package/utilities/internal/caches.js.map +1 -1
- package/utilities/internal/canUseDOM.d.ts +5 -1
- package/utilities/internal/canUseDOM.js +5 -1
- package/utilities/internal/canUseDOM.js.map +1 -1
- package/utilities/internal/checkDocument.d.ts +6 -3
- package/utilities/internal/checkDocument.js +6 -3
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/cloneDeep.d.ts +6 -4
- package/utilities/internal/cloneDeep.js +6 -4
- package/utilities/internal/cloneDeep.js.map +1 -1
- package/utilities/internal/compact.d.ts +7 -5
- package/utilities/internal/compact.js +7 -5
- package/utilities/internal/compact.js.map +1 -1
- package/utilities/internal/createFragmentMap.d.ts +7 -4
- package/utilities/internal/createFragmentMap.js +7 -4
- package/utilities/internal/createFragmentMap.js.map +1 -1
- package/utilities/internal/createFulfilledPromise.d.ts +5 -1
- package/utilities/internal/createFulfilledPromise.js +5 -1
- package/utilities/internal/createFulfilledPromise.js.map +1 -1
- package/utilities/internal/createRejectedPromise.d.ts +5 -1
- package/utilities/internal/createRejectedPromise.js +5 -1
- package/utilities/internal/createRejectedPromise.js.map +1 -1
- 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 +5 -1
- package/utilities/internal/decoratePromise.js +5 -1
- package/utilities/internal/decoratePromise.js.map +1 -1
- package/utilities/internal/deepFreeze.d.ts +5 -1
- package/utilities/internal/deepFreeze.js +5 -1
- package/utilities/internal/deepFreeze.js.map +1 -1
- 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 +5 -1
- package/utilities/internal/getDefaultValues.js +5 -1
- package/utilities/internal/getDefaultValues.js.map +1 -1
- package/utilities/internal/getFragmentDefinition.d.ts +5 -1
- package/utilities/internal/getFragmentDefinition.js +5 -1
- package/utilities/internal/getFragmentDefinition.js.map +1 -1
- package/utilities/internal/getFragmentDefinitions.d.ts +5 -1
- package/utilities/internal/getFragmentDefinitions.js +5 -1
- package/utilities/internal/getFragmentDefinitions.js.map +1 -1
- package/utilities/internal/getFragmentFromSelection.d.ts +5 -1
- package/utilities/internal/getFragmentFromSelection.js +5 -1
- package/utilities/internal/getFragmentFromSelection.js.map +1 -1
- package/utilities/internal/getFragmentQueryDocument.d.ts +25 -23
- package/utilities/internal/getFragmentQueryDocument.js +25 -23
- package/utilities/internal/getFragmentQueryDocument.js.map +1 -1
- package/utilities/internal/getGraphQLErrorsFromResult.d.ts +5 -1
- package/utilities/internal/getGraphQLErrorsFromResult.js +5 -1
- package/utilities/internal/getGraphQLErrorsFromResult.js.map +1 -1
- package/utilities/internal/getMainDefinition.d.ts +8 -6
- package/utilities/internal/getMainDefinition.js +8 -6
- package/utilities/internal/getMainDefinition.js.map +1 -1
- 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 +5 -1
- package/utilities/internal/getOperationDefinition.js +5 -1
- package/utilities/internal/getOperationDefinition.js.map +1 -1
- package/utilities/internal/getOperationName.d.ts +6 -2
- package/utilities/internal/getOperationName.js +7 -5
- package/utilities/internal/getOperationName.js.map +1 -1
- package/utilities/internal/getQueryDefinition.d.ts +5 -1
- package/utilities/internal/getQueryDefinition.js +5 -1
- package/utilities/internal/getQueryDefinition.js.map +1 -1
- package/utilities/internal/getStoreKeyName.d.ts +5 -1
- package/utilities/internal/getStoreKeyName.js +5 -1
- package/utilities/internal/getStoreKeyName.js.map +1 -1
- package/utilities/internal/globals/global.js +2 -2
- package/utilities/internal/globals/global.js.map +1 -1
- package/utilities/internal/graphQLResultHasError.d.ts +5 -1
- package/utilities/internal/graphQLResultHasError.js +5 -1
- package/utilities/internal/graphQLResultHasError.js.map +1 -1
- package/utilities/internal/hasDirectives.d.ts +5 -1
- package/utilities/internal/hasDirectives.js +5 -1
- package/utilities/internal/hasDirectives.js.map +1 -1
- 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 +3 -1
- package/utilities/internal/index.js +3 -1
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isArray.d.ts +6 -4
- package/utilities/internal/isArray.js +6 -4
- package/utilities/internal/isArray.js.map +1 -1
- package/utilities/internal/isDocumentNode.d.ts +5 -1
- package/utilities/internal/isDocumentNode.js +5 -1
- package/utilities/internal/isDocumentNode.js.map +1 -1
- package/utilities/internal/isExecutionPatchIncrementalResult.d.ts +5 -1
- package/utilities/internal/isExecutionPatchIncrementalResult.js +5 -1
- package/utilities/internal/isExecutionPatchIncrementalResult.js.map +1 -1
- package/utilities/internal/isExecutionPatchIninitialResult.d.ts +5 -1
- package/utilities/internal/isExecutionPatchIninitialResult.js +5 -1
- package/utilities/internal/isExecutionPatchIninitialResult.js.map +1 -1
- package/utilities/internal/isExecutionPatchResult.d.ts +5 -1
- package/utilities/internal/isExecutionPatchResult.js +5 -1
- package/utilities/internal/isExecutionPatchResult.js.map +1 -1
- package/utilities/internal/isField.d.ts +5 -1
- package/utilities/internal/isField.js +5 -1
- package/utilities/internal/isField.js.map +1 -1
- package/utilities/internal/isNonEmptyArray.d.ts +5 -1
- package/utilities/internal/isNonEmptyArray.js +5 -1
- package/utilities/internal/isNonEmptyArray.js.map +1 -1
- package/utilities/internal/isNonNullObject.d.ts +5 -1
- package/utilities/internal/isNonNullObject.js +5 -1
- package/utilities/internal/isNonNullObject.js.map +1 -1
- package/utilities/internal/isPlainObject.d.ts +5 -1
- package/utilities/internal/isPlainObject.js +5 -1
- package/utilities/internal/isPlainObject.js.map +1 -1
- package/utilities/internal/makeReference.d.ts +5 -1
- package/utilities/internal/makeReference.js +5 -1
- package/utilities/internal/makeReference.js.map +1 -1
- package/utilities/internal/makeUniqueId.d.ts +7 -5
- package/utilities/internal/makeUniqueId.js +7 -5
- package/utilities/internal/makeUniqueId.js.map +1 -1
- package/utilities/internal/maybeDeepFreeze.d.ts +5 -1
- package/utilities/internal/maybeDeepFreeze.js +5 -1
- package/utilities/internal/maybeDeepFreeze.js.map +1 -1
- package/utilities/internal/mergeDeep.d.ts +5 -1
- package/utilities/internal/mergeDeep.js +5 -1
- package/utilities/internal/mergeDeep.js.map +1 -1
- package/utilities/internal/mergeDeepArray.d.ts +5 -1
- package/utilities/internal/mergeDeepArray.js +5 -1
- package/utilities/internal/mergeDeepArray.js.map +1 -1
- package/utilities/internal/mergeIncrementalData.d.ts +5 -1
- package/utilities/internal/mergeIncrementalData.js +5 -1
- package/utilities/internal/mergeIncrementalData.js.map +1 -1
- package/utilities/internal/mergeOptions.d.ts +5 -1
- package/utilities/internal/mergeOptions.js +5 -1
- package/utilities/internal/mergeOptions.js.map +1 -1
- package/utilities/internal/omitDeep.d.ts +5 -1
- package/utilities/internal/omitDeep.js +5 -1
- package/utilities/internal/omitDeep.js.map +1 -1
- package/utilities/internal/onAnyEvent.d.ts +5 -1
- package/utilities/internal/onAnyEvent.js +5 -1
- package/utilities/internal/onAnyEvent.js.map +1 -1
- package/utilities/internal/removeDirectivesFromDocument.d.ts +5 -1
- package/utilities/internal/removeDirectivesFromDocument.js +5 -1
- package/utilities/internal/removeDirectivesFromDocument.js.map +1 -1
- package/utilities/internal/resultKeyNameFromField.d.ts +5 -1
- package/utilities/internal/resultKeyNameFromField.js +5 -1
- package/utilities/internal/resultKeyNameFromField.js.map +1 -1
- package/utilities/internal/shouldInclude.d.ts +5 -1
- package/utilities/internal/shouldInclude.js +5 -1
- package/utilities/internal/shouldInclude.js.map +1 -1
- package/utilities/internal/storeKeyNameFromField.d.ts +5 -1
- package/utilities/internal/storeKeyNameFromField.js +5 -1
- package/utilities/internal/storeKeyNameFromField.js.map +1 -1
- package/utilities/internal/stringifyForDisplay.d.ts +5 -1
- package/utilities/internal/stringifyForDisplay.js +5 -1
- package/utilities/internal/stringifyForDisplay.js.map +1 -1
- package/utilities/internal/toQueryResult.d.ts +5 -1
- package/utilities/internal/toQueryResult.js +5 -1
- package/utilities/internal/toQueryResult.js.map +1 -1
- package/utilities/internal/types/DecoratedPromise.d.ts +5 -1
- package/utilities/internal/types/DeepOmit.d.ts +5 -1
- package/utilities/internal/types/DeepPartial.d.ts +5 -1
- package/utilities/internal/types/FragmentMap.d.ts +6 -4
- package/utilities/internal/types/FragmentMapFunction.d.ts +5 -1
- package/utilities/internal/types/FulfilledPromise.d.ts +5 -1
- package/utilities/internal/types/IsAny.d.ts +5 -1
- package/utilities/internal/types/PendingPromise.d.ts +5 -1
- package/utilities/internal/types/Prettify.d.ts +5 -1
- package/utilities/internal/types/Primitive.d.ts +5 -1
- package/utilities/internal/types/RejectedPromise.d.ts +5 -1
- package/utilities/internal/types/RemoveIndexSignature.d.ts +5 -1
- package/utilities/internal/types/VariablesOption.d.ts +5 -1
- package/utilities/internal/valueToObjectRepresentation.d.ts +5 -1
- package/utilities/internal/valueToObjectRepresentation.js +5 -1
- package/utilities/internal/valueToObjectRepresentation.js.map +1 -1
- package/version.js +1 -1
- package/__cjs/core/LocalState.cjs +0 -355
- package/__cjs/core/LocalState.cjs.map +0 -1
- package/__cjs/core/LocalState.d.cts +0 -53
- package/__cjs/utilities/internal/removeClientSetsFromDocument.cjs +0 -21
- package/__cjs/utilities/internal/removeClientSetsFromDocument.cjs.map +0 -1
- package/__cjs/utilities/internal/removeClientSetsFromDocument.d.cts +0 -8
- package/core/LocalState.d.ts +0 -53
- package/core/LocalState.js +0 -351
- package/core/LocalState.js.map +0 -1
- package/utilities/internal/removeClientSetsFromDocument.d.ts +0 -8
- package/utilities/internal/removeClientSetsFromDocument.js +0 -18
- package/utilities/internal/removeClientSetsFromDocument.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { DocumentNode } from "graphql";
|
|
2
2
|
import type { InteropObservable, Observer, Subscribable, Subscription } from "rxjs";
|
|
3
|
-
import
|
|
4
|
-
import type { MissingFieldError } from "@apollo/client/cache";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import type { Cache, MissingFieldError } from "@apollo/client/cache";
|
|
5
5
|
import type { MissingTree } from "@apollo/client/cache";
|
|
6
6
|
import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
|
|
7
7
|
import type { QueryInfo } from "./QueryInfo.cjs";
|
|
8
8
|
import type { QueryManager } from "./QueryManager.cjs";
|
|
9
|
-
import type { ApolloQueryResult, DefaultContext,
|
|
9
|
+
import type { ApolloQueryResult, DefaultContext, OperationVariables, QueryResult, TypedDocumentNode } from "./types.cjs";
|
|
10
10
|
import type { ErrorPolicy, FetchMoreQueryOptions, NextFetchPolicyContext, RefetchWritePolicy, SubscribeToMoreOptions, UpdateQueryMapFn, WatchQueryFetchPolicy, WatchQueryOptions } from "./watchQueryOptions.cjs";
|
|
11
11
|
export interface FetchMoreOptions<TData = unknown, TVariables = OperationVariables> {
|
|
12
12
|
updateQuery?: (previousQueryResult: TData, options: {
|
|
@@ -129,15 +129,40 @@ export declare namespace ObservableQuery {
|
|
|
129
129
|
*/
|
|
130
130
|
variables: TVariables;
|
|
131
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* @internal
|
|
134
|
+
* This describes the `WatchOptions` used by `ObservableQuery` to
|
|
135
|
+
* subscribe to the cache.
|
|
136
|
+
*
|
|
137
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
138
|
+
*/
|
|
139
|
+
interface CacheWatchOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Cache.WatchOptions<TData, TVariables> {
|
|
140
|
+
/**
|
|
141
|
+
* @internal
|
|
142
|
+
* We cannot suppress the broadcast completely, since that would
|
|
143
|
+
* result in external updates to be lost if we go from
|
|
144
|
+
* (external A) -> (own B) -> (external C) when A and C have the same
|
|
145
|
+
* value.
|
|
146
|
+
* Without the `own B` being broadcast, the `cache.watch` would swallow
|
|
147
|
+
* C.
|
|
148
|
+
* So instead we track the last "own diff" and suppress further processing
|
|
149
|
+
* in the callback.
|
|
150
|
+
*
|
|
151
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
152
|
+
*/
|
|
153
|
+
lastOwnDiff?: Cache.DiffResult<TData>;
|
|
154
|
+
}
|
|
132
155
|
}
|
|
133
156
|
export declare class ObservableQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables> implements Subscribable<ApolloQueryResult<MaybeMasked<TData>>>, InteropObservable<ApolloQueryResult<MaybeMasked<TData>>> {
|
|
134
157
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
158
|
+
* @internal
|
|
159
|
+
* A slot used by the `useQuery` hook to indicate that `client.watchQuery`
|
|
160
|
+
* should not register the query immediately, but instead wait for the query to
|
|
161
|
+
* be started registered with the `QueryManager` when `useSyncExternalStore`
|
|
162
|
+
* actively subscribes to it.
|
|
163
|
+
*
|
|
164
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
165
|
+
*/
|
|
141
166
|
private static inactiveOnCreation;
|
|
142
167
|
readonly options: ObservableQuery.Options<TData, TVariables>;
|
|
143
168
|
readonly queryId: string;
|
|
@@ -147,19 +172,24 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
|
|
|
147
172
|
* An object containing the variables that were provided for the query.
|
|
148
173
|
*/
|
|
149
174
|
get variables(): TVariables;
|
|
175
|
+
private unsubscribeFromCache?;
|
|
176
|
+
private input;
|
|
150
177
|
private subject;
|
|
151
178
|
private readonly observable;
|
|
152
179
|
private isTornDown;
|
|
153
180
|
private queryManager;
|
|
154
181
|
private subscriptions;
|
|
155
|
-
|
|
156
|
-
|
|
182
|
+
/**
|
|
183
|
+
* If an `ObservableQuery` is created with a `network-only` fetch policy,
|
|
184
|
+
* it should actually start receiving cache updates, but not before it has
|
|
185
|
+
* received the first result from the network.
|
|
186
|
+
*/
|
|
187
|
+
private waitForNetworkResult;
|
|
157
188
|
private lastQuery;
|
|
158
189
|
private queryInfo;
|
|
159
190
|
private linkSubscription?;
|
|
160
|
-
private linkObservable?;
|
|
161
191
|
private pollingInfo?;
|
|
162
|
-
private networkStatus;
|
|
192
|
+
private get networkStatus();
|
|
163
193
|
constructor({ queryManager, queryInfo, options, }: {
|
|
164
194
|
queryManager: QueryManager;
|
|
165
195
|
queryInfo: QueryInfo;
|
|
@@ -169,16 +199,17 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
|
|
|
169
199
|
pipe: Observable<ApolloQueryResult<MaybeMasked<TData>>>["pipe"];
|
|
170
200
|
[Symbol.observable]: () => Subscribable<ApolloQueryResult<MaybeMasked<TData>>>;
|
|
171
201
|
["@@observable"]: () => Subscribable<ApolloQueryResult<MaybeMasked<TData>>>;
|
|
172
|
-
/**
|
|
202
|
+
/**
|
|
203
|
+
* @internal
|
|
204
|
+
*
|
|
205
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
206
|
+
*/
|
|
173
207
|
resetDiff(): void;
|
|
208
|
+
private getCacheDiff;
|
|
174
209
|
private getInitialResult;
|
|
175
|
-
private
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
private getLast;
|
|
179
|
-
getLastResult(variablesMustMatch?: boolean): ApolloQueryResult<TData> | undefined;
|
|
180
|
-
getLastError(variablesMustMatch?: boolean): ErrorLike | undefined;
|
|
181
|
-
resetLastResults(): void;
|
|
210
|
+
private resubscribeCache;
|
|
211
|
+
private stableLastResult?;
|
|
212
|
+
getCurrentResult(): ApolloQueryResult<MaybeMasked<TData>>;
|
|
182
213
|
/**
|
|
183
214
|
* Update the variables of this observable query, and fetch the new results.
|
|
184
215
|
* This method should be preferred over `setVariables` in most use cases.
|
|
@@ -202,7 +233,11 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
|
|
|
202
233
|
* This function returns _another_ function that you can call to terminate the subscription.
|
|
203
234
|
*/
|
|
204
235
|
subscribeToMore<TSubscriptionData = TData, TSubscriptionVariables extends OperationVariables = TVariables>(options: SubscribeToMoreOptions<TData, TSubscriptionVariables, TSubscriptionData, TVariables>): () => void;
|
|
205
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* @internal
|
|
238
|
+
*
|
|
239
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
240
|
+
*/
|
|
206
241
|
silentSetOptions(newOptions: Partial<ObservableQuery.Options<TData, TVariables>>): void;
|
|
207
242
|
/**
|
|
208
243
|
* Update the variables of this observable query, and fetch the new results
|
|
@@ -241,28 +276,55 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
|
|
|
241
276
|
private fetch;
|
|
242
277
|
private updatePolling;
|
|
243
278
|
private cancelPolling;
|
|
244
|
-
private updateLastResult;
|
|
245
279
|
/**
|
|
246
280
|
* Reevaluate the query, optionally against new options. New options will be
|
|
247
281
|
* merged with the current options when given.
|
|
248
282
|
*/
|
|
249
283
|
reobserve(newOptions?: Partial<ObservableQuery.Options<TData, TVariables>>): Promise<QueryResult<MaybeMasked<TData>>>;
|
|
250
|
-
private observe;
|
|
251
|
-
private reportResult;
|
|
252
|
-
private reportError;
|
|
253
284
|
hasObservers(): boolean;
|
|
254
285
|
private tearDownQuery;
|
|
255
286
|
private transformDocument;
|
|
256
287
|
private maskResult;
|
|
257
288
|
private dirty;
|
|
258
289
|
private notifyTimeout?;
|
|
259
|
-
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
290
|
+
/**
|
|
291
|
+
* @internal
|
|
292
|
+
*
|
|
293
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
294
|
+
*/
|
|
295
|
+
private resetNotifications;
|
|
296
|
+
/**
|
|
297
|
+
* @internal
|
|
298
|
+
*
|
|
299
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
300
|
+
*/
|
|
301
|
+
private scheduleNotify;
|
|
302
|
+
/**
|
|
303
|
+
* @internal
|
|
304
|
+
*
|
|
305
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
306
|
+
*/
|
|
307
|
+
notify(scheduled?: boolean): void;
|
|
308
|
+
private activeOperations;
|
|
309
|
+
private pushOperation;
|
|
310
|
+
private calculateNetworkStatus;
|
|
311
|
+
private abortActiveOperations;
|
|
312
|
+
/**
|
|
313
|
+
* @internal
|
|
314
|
+
* Called from `clearStore`.
|
|
315
|
+
* * resets the query to its initial state
|
|
316
|
+
* * cancels all active operations and their subscriptions
|
|
317
|
+
*
|
|
318
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
319
|
+
*/
|
|
320
|
+
reset(): void;
|
|
321
|
+
/**
|
|
322
|
+
* @internal
|
|
323
|
+
*
|
|
324
|
+
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
325
|
+
*/
|
|
326
|
+
private setResult;
|
|
327
|
+
private operator;
|
|
266
328
|
private reobserveCacheFirst;
|
|
267
329
|
private getVariablesWithDefaults;
|
|
268
330
|
}
|
package/__cjs/core/QueryInfo.cjs
CHANGED
|
@@ -38,8 +38,6 @@ class QueryInfo {
|
|
|
38
38
|
document = null;
|
|
39
39
|
lastRequestId = 1;
|
|
40
40
|
variables;
|
|
41
|
-
stopped = false;
|
|
42
|
-
cancelWatch;
|
|
43
41
|
cache;
|
|
44
42
|
constructor(queryManager, queryId = queryManager.generateQueryId()) {
|
|
45
43
|
this.queryId = queryId;
|
|
@@ -58,9 +56,7 @@ class QueryInfo {
|
|
|
58
56
|
}
|
|
59
57
|
init(query) {
|
|
60
58
|
if (!(0, equality_1.equal)(query.variables, this.variables)) {
|
|
61
|
-
this.
|
|
62
|
-
// Ensure we don't continue to receive cache updates for old variables
|
|
63
|
-
this.cancel();
|
|
59
|
+
this.resetDiff();
|
|
64
60
|
}
|
|
65
61
|
Object.assign(this, {
|
|
66
62
|
document: query.document,
|
|
@@ -68,33 +64,6 @@ class QueryInfo {
|
|
|
68
64
|
});
|
|
69
65
|
return this;
|
|
70
66
|
}
|
|
71
|
-
resetDiff() {
|
|
72
|
-
this.lastDiff = void 0;
|
|
73
|
-
}
|
|
74
|
-
getDiff() {
|
|
75
|
-
const options = this.getDiffOptions();
|
|
76
|
-
if (this.lastDiff && (0, equality_1.equal)(options, this.lastDiff.options)) {
|
|
77
|
-
return this.lastDiff.diff;
|
|
78
|
-
}
|
|
79
|
-
this.updateWatch(this.variables);
|
|
80
|
-
const oq = this.observableQuery;
|
|
81
|
-
if (oq && oq.options.fetchPolicy === "no-cache") {
|
|
82
|
-
return { result: null, complete: false };
|
|
83
|
-
}
|
|
84
|
-
const diff = this.cache.diff(options);
|
|
85
|
-
this.updateLastDiff(diff, options);
|
|
86
|
-
return diff;
|
|
87
|
-
}
|
|
88
|
-
lastDiff;
|
|
89
|
-
updateLastDiff(diff, options) {
|
|
90
|
-
this.lastDiff =
|
|
91
|
-
diff ?
|
|
92
|
-
{
|
|
93
|
-
diff,
|
|
94
|
-
options: options || this.getDiffOptions(),
|
|
95
|
-
}
|
|
96
|
-
: void 0;
|
|
97
|
-
}
|
|
98
67
|
getDiffOptions(variables = this.variables) {
|
|
99
68
|
return {
|
|
100
69
|
query: this.document,
|
|
@@ -103,25 +72,6 @@ class QueryInfo {
|
|
|
103
72
|
optimistic: true,
|
|
104
73
|
};
|
|
105
74
|
}
|
|
106
|
-
setDiff(diff) {
|
|
107
|
-
const oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
108
|
-
// If we are trying to deliver an incomplete cache result, we avoid
|
|
109
|
-
// reporting it if the query has errored, otherwise we let the broadcast try
|
|
110
|
-
// and repair the partial result by refetching the query. This check avoids
|
|
111
|
-
// a situation where a query that errors and another succeeds with
|
|
112
|
-
// overlapping data does not report the partial data result to the errored
|
|
113
|
-
// query.
|
|
114
|
-
//
|
|
115
|
-
// See https://github.com/apollographql/apollo-client/issues/11400 for more
|
|
116
|
-
// information on this issue.
|
|
117
|
-
if (diff && !diff.complete && this.observableQuery?.getLastError()) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
this.updateLastDiff(diff);
|
|
121
|
-
if (!(0, equality_1.equal)(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
122
|
-
this.observableQuery?.["scheduleNotify"]();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
75
|
observableQuery = null;
|
|
126
76
|
setObservableQuery(oq) {
|
|
127
77
|
if (oq === this.observableQuery)
|
|
@@ -131,40 +81,6 @@ class QueryInfo {
|
|
|
131
81
|
oq["queryInfo"] = this;
|
|
132
82
|
}
|
|
133
83
|
}
|
|
134
|
-
stop() {
|
|
135
|
-
if (!this.stopped) {
|
|
136
|
-
this.stopped = true;
|
|
137
|
-
// Cancel the pending notify timeout
|
|
138
|
-
this.observableQuery?.["resetNotifications"]();
|
|
139
|
-
this.cancel();
|
|
140
|
-
const oq = this.observableQuery;
|
|
141
|
-
if (oq)
|
|
142
|
-
oq.stopPolling();
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
cancel() {
|
|
146
|
-
this.cancelWatch?.();
|
|
147
|
-
this.cancelWatch = void 0;
|
|
148
|
-
}
|
|
149
|
-
lastWatch;
|
|
150
|
-
updateWatch(variables = this.variables) {
|
|
151
|
-
const oq = this.observableQuery;
|
|
152
|
-
if (oq && oq.options.fetchPolicy === "no-cache") {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const watchOptions = {
|
|
156
|
-
// Although this.getDiffOptions returns Cache.DiffOptions instead of
|
|
157
|
-
// Cache.WatchOptions, all the overlapping options should be the same, so
|
|
158
|
-
// we can reuse getDiffOptions here, for consistency.
|
|
159
|
-
...this.getDiffOptions(variables),
|
|
160
|
-
watcher: this,
|
|
161
|
-
callback: (diff) => this.setDiff(diff),
|
|
162
|
-
};
|
|
163
|
-
if (!this.lastWatch || !(0, equality_1.equal)(watchOptions, this.lastWatch)) {
|
|
164
|
-
this.cancel();
|
|
165
|
-
this.cancelWatch = this.cache.watch((this.lastWatch = watchOptions));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
84
|
lastWrite;
|
|
169
85
|
resetLastWrite() {
|
|
170
86
|
this.lastWrite = void 0;
|
|
@@ -179,111 +95,110 @@ class QueryInfo {
|
|
|
179
95
|
(0, equality_1.equal)(variables, lastWrite.variables) &&
|
|
180
96
|
(0, equality_1.equal)(result.data, lastWrite.result.data));
|
|
181
97
|
}
|
|
98
|
+
resetDiff() {
|
|
99
|
+
this.lastDiff = void 0;
|
|
100
|
+
}
|
|
101
|
+
lastDiff;
|
|
182
102
|
markResult(result, document, options, cacheWriteBehavior) {
|
|
183
|
-
const merger = new internal_1.DeepMerger();
|
|
184
103
|
// Cancel the pending notify timeout (if it exists) to prevent extraneous network
|
|
185
104
|
// requests. To allow future notify timeouts, diff and dirty are reset as well.
|
|
186
105
|
this.observableQuery?.["resetNotifications"]();
|
|
187
|
-
if (
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
106
|
+
if (cacheWriteBehavior === 0 /* CacheWriteBehavior.FORBID */) {
|
|
107
|
+
const diffOptions = this.getDiffOptions(options.variables);
|
|
108
|
+
const lastDiff = this.lastDiff && (0, equality_1.equal)(diffOptions, this.lastDiff.options) ?
|
|
109
|
+
this.lastDiff.diff
|
|
110
|
+
: { result: null, complete: false };
|
|
111
|
+
handleIncrementalResult(result, lastDiff);
|
|
112
|
+
this.lastDiff = {
|
|
113
|
+
diff: { result: result.data, complete: true },
|
|
114
|
+
options: diffOptions,
|
|
115
|
+
};
|
|
195
116
|
}
|
|
196
|
-
else
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
if (options.fetchPolicy === "no-cache") {
|
|
201
|
-
this.updateLastDiff({ result: result.data, complete: true }, this.getDiffOptions(options.variables));
|
|
202
|
-
}
|
|
203
|
-
else if (cacheWriteBehavior !== 0 /* CacheWriteBehavior.FORBID */) {
|
|
117
|
+
else {
|
|
118
|
+
const lastDiff = this.cache.diff(this.getDiffOptions());
|
|
119
|
+
handleIncrementalResult(result, lastDiff);
|
|
204
120
|
if (shouldWriteResult(result, options.errorPolicy)) {
|
|
205
121
|
// Using a transaction here so we have a chance to read the result
|
|
206
122
|
// back from the cache before the watch callback fires as a result
|
|
207
123
|
// of writeQuery, so we can store the new diff quietly and ignore
|
|
208
124
|
// it when we receive it redundantly from the watch callback.
|
|
209
|
-
this.cache.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
//
|
|
258
|
-
//
|
|
259
|
-
|
|
260
|
-
|
|
125
|
+
this.cache.batch({
|
|
126
|
+
onWatchUpdated: (
|
|
127
|
+
// all additional options on ObservableQuery.CacheWatchOptions are
|
|
128
|
+
// optional so we can use the type here
|
|
129
|
+
watch, diff) => {
|
|
130
|
+
if (watch.watcher === this.observableQuery) {
|
|
131
|
+
// see comment on `lastOwnDiff` for explanation
|
|
132
|
+
watch.lastOwnDiff = diff;
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
update: (cache) => {
|
|
136
|
+
if (this.shouldWrite(result, options.variables)) {
|
|
137
|
+
cache.writeQuery({
|
|
138
|
+
query: document,
|
|
139
|
+
data: result.data,
|
|
140
|
+
variables: options.variables,
|
|
141
|
+
overwrite: cacheWriteBehavior === 1 /* CacheWriteBehavior.OVERWRITE */,
|
|
142
|
+
});
|
|
143
|
+
this.lastWrite = {
|
|
144
|
+
result,
|
|
145
|
+
variables: options.variables,
|
|
146
|
+
dmCount: destructiveMethodCounts.get(this.cache),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// If result is the same as the last result we received from
|
|
151
|
+
// the network (and the variables match too), avoid writing
|
|
152
|
+
// result into the cache again. The wisdom of skipping this
|
|
153
|
+
// cache write is far from obvious, since any cache write
|
|
154
|
+
// could be the one that puts the cache back into a desired
|
|
155
|
+
// state, fixing corruption or missing data. However, if we
|
|
156
|
+
// always write every network result into the cache, we enable
|
|
157
|
+
// feuds between queries competing to update the same data in
|
|
158
|
+
// incompatible ways, which can lead to an endless cycle of
|
|
159
|
+
// cache broadcasts and useless network requests. As with any
|
|
160
|
+
// feud, eventually one side must step back from the brink,
|
|
161
|
+
// letting the other side(s) have the last word(s). There may
|
|
162
|
+
// be other points where we could break this cycle, such as
|
|
163
|
+
// silencing the broadcast for cache.writeQuery (not a good
|
|
164
|
+
// idea, since it just delays the feud a bit) or somehow
|
|
165
|
+
// avoiding the network request that just happened (also bad,
|
|
166
|
+
// because the server could return useful new data). All
|
|
167
|
+
// options considered, skipping this cache write seems to be
|
|
168
|
+
// the least damaging place to break the cycle, because it
|
|
169
|
+
// reflects the intuition that we recently wrote this exact
|
|
170
|
+
// result into the cache, so the cache *should* already/still
|
|
171
|
+
// contain this data. If some other query has clobbered that
|
|
172
|
+
// data in the meantime, that's too bad, but there will be no
|
|
173
|
+
// winners if every query blindly reverts to its own version
|
|
174
|
+
// of the data. This approach also gives the network a chance
|
|
175
|
+
// to return new data, which will be written into the cache as
|
|
176
|
+
// usual, notifying only those queries that are directly
|
|
177
|
+
// affected by the cache updates, as usual. In the future, an
|
|
178
|
+
// even more sophisticated cache could perhaps prevent or
|
|
179
|
+
// mitigate the clobbering somehow, but that would make this
|
|
180
|
+
// particular cache write even less important, and thus
|
|
181
|
+
// skipping it would be even safer than it is today.
|
|
182
|
+
if (lastDiff && lastDiff.complete) {
|
|
183
|
+
// Reuse data from the last good (complete) diff that we
|
|
184
|
+
// received, when possible.
|
|
185
|
+
result.data = lastDiff.result;
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// If the previous this.diff was incomplete, fall through to
|
|
189
|
+
// re-reading the latest data with cache.diff, below.
|
|
261
190
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
if (!this.stopped && (0, equality_1.equal)(this.variables, options.variables)) {
|
|
274
|
-
// Any time we're about to update this.diff, we need to make
|
|
275
|
-
// sure we've started watching the cache.
|
|
276
|
-
this.updateWatch(options.variables);
|
|
277
|
-
}
|
|
278
|
-
// If we're allowed to write to the cache, and we can read a
|
|
279
|
-
// complete result from the cache, update result.data to be the
|
|
280
|
-
// result from the cache, rather than the raw network result.
|
|
281
|
-
// Set without setDiff to avoid triggering a notify call, since
|
|
282
|
-
// we have other ways of notifying for this result.
|
|
283
|
-
this.updateLastDiff(diff, diffOptions);
|
|
284
|
-
if (diff.complete) {
|
|
285
|
-
result.data = diff.result;
|
|
286
|
-
}
|
|
191
|
+
const diffOptions = this.getDiffOptions(options.variables);
|
|
192
|
+
const diff = cache.diff(diffOptions);
|
|
193
|
+
// If we're allowed to write to the cache, and we can read a
|
|
194
|
+
// complete result from the cache, update result.data to be the
|
|
195
|
+
// result from the cache, rather than the raw network result.
|
|
196
|
+
// Set without setDiff to avoid triggering a notify call, since
|
|
197
|
+
// we have other ways of notifying for this result.
|
|
198
|
+
if (diff.complete) {
|
|
199
|
+
result.data = diff.result;
|
|
200
|
+
}
|
|
201
|
+
},
|
|
287
202
|
});
|
|
288
203
|
}
|
|
289
204
|
else {
|
|
@@ -293,6 +208,21 @@ class QueryInfo {
|
|
|
293
208
|
}
|
|
294
209
|
}
|
|
295
210
|
exports.QueryInfo = QueryInfo;
|
|
211
|
+
function handleIncrementalResult(result, lastDiff) {
|
|
212
|
+
if ("incremental" in result && (0, internal_1.isNonEmptyArray)(result.incremental)) {
|
|
213
|
+
const mergedData = (0, internal_1.mergeIncrementalData)(lastDiff.result, result);
|
|
214
|
+
result.data = mergedData;
|
|
215
|
+
// Detect the first chunk of a deferred query and merge it with existing
|
|
216
|
+
// cache data. This ensures a `cache-first` fetch policy that returns
|
|
217
|
+
// partial cache data or a `cache-and-network` fetch policy that already
|
|
218
|
+
// has full data in the cache does not complain when trying to merge the
|
|
219
|
+
// initial deferred server data with existing cache data.
|
|
220
|
+
}
|
|
221
|
+
else if ("hasNext" in result && result.hasNext) {
|
|
222
|
+
const merger = new internal_1.DeepMerger();
|
|
223
|
+
result.data = merger.merge(lastDiff.result, result.data);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
296
226
|
function shouldWriteResult(result, errorPolicy = "none") {
|
|
297
227
|
const ignoreErrors = errorPolicy === "ignore" || errorPolicy === "all";
|
|
298
228
|
let writeWithErrors = !(0, internal_1.graphQLResultHasError)(result);
|