@apollo/client 4.0.0-alpha.13 → 4.0.0-alpha.15
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/beige-spiders-hope.md +5 -0
- 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/poor-spiders-hunt.md +23 -0
- package/.changeset/pre.json +20 -0
- package/.changeset/selfish-spoons-approve.md +44 -0
- package/.changeset/serious-items-develop.md +17 -0
- package/.changeset/sixty-bats-cry.md +6 -0
- package/.changeset/slimy-ants-bake.md +5 -0
- package/.changeset/sour-colts-tell.md +5 -0
- package/.changeset/sour-guests-poke.md +5 -0
- package/.changeset/spotty-mugs-poke.md +5 -0
- package/.changeset/strange-walls-march.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 +213 -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 -340
- 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/hooks/useQuery.cjs +10 -25
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +0 -1
- 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/react/ssr/useSSRQuery.cjs +11 -2
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.cjs +7 -9
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +29 -22
- package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs +0 -4
- package/__cjs/testing/core/mocking/mockSubscriptionLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +7 -6
- package/__cjs/testing/core/types/deprecated.cjs +3 -0
- package/__cjs/testing/core/types/deprecated.cjs.map +1 -0
- package/__cjs/testing/core/types/deprecated.d.cts +10 -0
- package/__cjs/testing/index.cjs +6 -13
- package/__cjs/testing/index.cjs.map +1 -1
- package/__cjs/testing/index.d.cts +3 -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/internal/index.cjs +3 -1
- package/__cjs/testing/internal/index.cjs.map +1 -1
- package/__cjs/testing/internal/index.d.cts +1 -0
- package/__cjs/testing/internal/scenarios/index.cjs +4 -4
- package/__cjs/testing/internal/scenarios/index.cjs.map +1 -1
- package/__cjs/testing/internal/scenarios/index.d.cts +8 -8
- package/__cjs/testing/{core → internal}/wait.cjs +0 -4
- package/__cjs/testing/internal/wait.cjs.map +1 -0
- package/__cjs/testing/{core → internal}/wait.d.cts +0 -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 +4 -4
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +4 -5
- 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 -345
- 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 +7 -155
- 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/useQuery.d.ts +0 -1
- package/react/hooks/useQuery.js +10 -25
- package/react/hooks/useQuery.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/react/ssr/useSSRQuery.js +11 -2
- package/react/ssr/useSSRQuery.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +29 -22
- package/testing/core/mocking/mockLink.js +9 -10
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +7 -6
- package/testing/core/mocking/mockSubscriptionLink.js +0 -3
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/types/deprecated.d.ts +10 -0
- package/testing/core/types/deprecated.js +2 -0
- package/testing/core/types/deprecated.js.map +1 -0
- package/testing/index.d.ts +3 -2
- package/testing/index.js +2 -1
- package/testing/index.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/internal/index.d.ts +1 -0
- package/testing/internal/index.js +2 -1
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/scenarios/index.d.ts +8 -8
- package/testing/internal/scenarios/index.js +4 -4
- package/testing/internal/scenarios/index.js.map +1 -1
- package/testing/{core → internal}/wait.d.ts +0 -1
- package/testing/{core → internal}/wait.js +0 -3
- package/testing/internal/wait.js.map +1 -0
- 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 +4 -5
- package/testing/react/MockedProvider.js +3 -3
- 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/testing/core/index.cjs +0 -20
- package/__cjs/testing/core/index.cjs.map +0 -1
- package/__cjs/testing/core/index.d.cts +0 -7
- package/__cjs/testing/core/mocking/mockClient.cjs +0 -17
- package/__cjs/testing/core/mocking/mockClient.cjs.map +0 -1
- package/__cjs/testing/core/mocking/mockClient.d.cts +0 -4
- package/__cjs/testing/core/wait.cjs.map +0 -1
- package/__cjs/testing/core/withConsoleSpy.cjs +0 -33
- package/__cjs/testing/core/withConsoleSpy.cjs.map +0 -1
- package/__cjs/testing/core/withConsoleSpy.d.cts +0 -7
- 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/legacyEntryPoints/testing/core/core.cjs +0 -1
- package/legacyEntryPoints/testing/core/core.d.cts +0 -1
- package/legacyEntryPoints/testing/core/index.d.ts +0 -1
- package/legacyEntryPoints/testing/core/index.js +0 -1
- package/testing/core/index.d.ts +0 -7
- package/testing/core/index.js +0 -6
- package/testing/core/index.js.map +0 -1
- package/testing/core/mocking/mockClient.d.ts +0 -4
- package/testing/core/mocking/mockClient.js +0 -14
- package/testing/core/mocking/mockClient.js.map +0 -1
- package/testing/core/wait.js.map +0 -1
- package/testing/core/withConsoleSpy.d.ts +0 -7
- package/testing/core/withConsoleSpy.js +0 -28
- package/testing/core/withConsoleSpy.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
package/core/QueryManager.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Trie } from "@wry/trie";
|
|
2
2
|
import { BREAK, Kind, OperationTypeNode, visit } from "graphql";
|
|
3
|
-
import { catchError, concat, EMPTY, filter, from, lastValueFrom, map, mergeMap, mergeWith, Observable, of, share, shareReplay, Subject, tap, } from "rxjs";
|
|
3
|
+
import { catchError, concat, EMPTY, filter, from, lastValueFrom, map, materialize, mergeMap, mergeWith, Observable, of, share, shareReplay, Subject, tap, } from "rxjs";
|
|
4
4
|
import { canonicalStringify } from "@apollo/client/cache";
|
|
5
5
|
import { CombinedGraphQLErrors, graphQLResultHasProtocolErrors, registerLinkError, toErrorLike, } from "@apollo/client/errors";
|
|
6
6
|
import { PROTOCOL_ERRORS_SYMBOL } from "@apollo/client/errors";
|
|
@@ -10,7 +10,7 @@ import { print } from "@apollo/client/utilities";
|
|
|
10
10
|
import { cacheSizes } from "@apollo/client/utilities";
|
|
11
11
|
import { DocumentTransform } from "@apollo/client/utilities";
|
|
12
12
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
13
|
-
import { AutoCleanedWeakCache, checkDocument, getDefaultValues, getGraphQLErrorsFromResult, getOperationDefinition, getOperationName, graphQLResultHasError, hasDirectives, isDocumentNode, isExecutionPatchIncrementalResult, isExecutionPatchResult, isNonEmptyArray, isNonNullObject, makeUniqueId, mergeIncrementalData, onAnyEvent, removeDirectivesFromDocument, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
13
|
+
import { AutoCleanedWeakCache, checkDocument, filterMap, getDefaultValues, getGraphQLErrorsFromResult, getOperationDefinition, getOperationName, graphQLResultHasError, hasDirectives, hasForcedResolvers, isDocumentNode, isExecutionPatchIncrementalResult, isExecutionPatchResult, isNonEmptyArray, isNonNullObject, makeUniqueId, mergeIncrementalData, onAnyEvent, removeDirectivesFromDocument, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
14
14
|
import { invariant, newInvariantError, } from "@apollo/client/utilities/invariant";
|
|
15
15
|
import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
|
|
16
16
|
import { logMissingFieldErrors, ObservableQuery } from "./ObservableQuery.js";
|
|
@@ -25,9 +25,9 @@ export class QueryManager {
|
|
|
25
25
|
ssrMode;
|
|
26
26
|
defaultContext;
|
|
27
27
|
dataMasking;
|
|
28
|
+
localState;
|
|
28
29
|
queryDeduplication;
|
|
29
30
|
clientAwareness = {};
|
|
30
|
-
localState;
|
|
31
31
|
/**
|
|
32
32
|
* Whether to prioritize cache values over network results when
|
|
33
33
|
* `fetchObservableWithInfo` is called.
|
|
@@ -57,10 +57,10 @@ export class QueryManager {
|
|
|
57
57
|
this.defaultOptions = options.defaultOptions;
|
|
58
58
|
this.queryDeduplication = options.queryDeduplication;
|
|
59
59
|
this.clientAwareness = options.clientAwareness;
|
|
60
|
-
this.localState = options.localState;
|
|
61
60
|
this.ssrMode = options.ssrMode;
|
|
62
61
|
this.assumeImmutableResults = options.assumeImmutableResults;
|
|
63
62
|
this.dataMasking = options.dataMasking;
|
|
63
|
+
this.localState = options.localState;
|
|
64
64
|
const documentTransform = options.documentTransform;
|
|
65
65
|
this.documentTransform =
|
|
66
66
|
documentTransform ?
|
|
@@ -91,22 +91,30 @@ export class QueryManager {
|
|
|
91
91
|
this.queries.forEach((_info, queryId) => {
|
|
92
92
|
this.removeQuery(queryId);
|
|
93
93
|
});
|
|
94
|
-
this.cancelPendingFetches(newInvariantError(
|
|
94
|
+
this.cancelPendingFetches(newInvariantError(82));
|
|
95
95
|
}
|
|
96
96
|
cancelPendingFetches(error) {
|
|
97
97
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
98
98
|
this.fetchCancelFns.clear();
|
|
99
99
|
}
|
|
100
100
|
async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy = this.defaultOptions.mutate?.fetchPolicy || "network-only", errorPolicy = this.defaultOptions.mutate?.errorPolicy || "none", keepRootFields, context, }) {
|
|
101
|
-
invariant(mutation,
|
|
101
|
+
invariant(mutation, 83);
|
|
102
102
|
checkDocument(mutation, OperationTypeNode.MUTATION);
|
|
103
|
-
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache",
|
|
103
|
+
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 84);
|
|
104
104
|
const mutationId = this.generateMutationId();
|
|
105
105
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
106
106
|
const { hasClientExports } = this.getDocumentInfo(mutation);
|
|
107
107
|
variables = this.getVariables(mutation, variables);
|
|
108
108
|
if (hasClientExports) {
|
|
109
|
-
|
|
109
|
+
if (__DEV__) {
|
|
110
|
+
invariant(this.localState, 85, getOperationName(mutation, "(anonymous)"));
|
|
111
|
+
}
|
|
112
|
+
variables = await this.localState.getExportedVariables({
|
|
113
|
+
client: this.client,
|
|
114
|
+
document: mutation,
|
|
115
|
+
variables,
|
|
116
|
+
context,
|
|
117
|
+
});
|
|
110
118
|
}
|
|
111
119
|
const mutationStoreValue = this.mutationStore &&
|
|
112
120
|
(this.mutationStore[mutationId] = {
|
|
@@ -397,7 +405,18 @@ export class QueryManager {
|
|
|
397
405
|
return true;
|
|
398
406
|
}
|
|
399
407
|
fetchQuery(queryId, options, networkStatus) {
|
|
400
|
-
return lastValueFrom(this.fetchObservableWithInfo(this.getOrCreateQuery(queryId), options,
|
|
408
|
+
return lastValueFrom(this.fetchObservableWithInfo(this.getOrCreateQuery(queryId), options, {
|
|
409
|
+
networkStatus,
|
|
410
|
+
}).observable.pipe(filterMap((value) => {
|
|
411
|
+
switch (value.kind) {
|
|
412
|
+
case "E":
|
|
413
|
+
throw value.error;
|
|
414
|
+
case "N": {
|
|
415
|
+
if (value.source !== "newNetworkStatus")
|
|
416
|
+
return toQueryResult(value.value);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
})), {
|
|
401
420
|
// This default is needed when a `standby` fetch policy is used to avoid
|
|
402
421
|
// an EmptyError from rejecting this promise.
|
|
403
422
|
defaultValue: { data: undefined },
|
|
@@ -418,10 +437,10 @@ export class QueryManager {
|
|
|
418
437
|
// traversals into a single pass in the future, though the work is
|
|
419
438
|
// cached after the first time.
|
|
420
439
|
hasClientExports: hasDirectives(["client", "export"], document, true),
|
|
421
|
-
hasForcedResolvers:
|
|
440
|
+
hasForcedResolvers: hasForcedResolvers(document),
|
|
422
441
|
hasNonreactiveDirective: hasDirectives(["nonreactive"], document),
|
|
423
442
|
nonReactiveQuery: addNonReactiveToNamedFragments(document),
|
|
424
|
-
clientQuery:
|
|
443
|
+
clientQuery: hasDirectives(["client"], document) ? document : null,
|
|
425
444
|
serverQuery: removeDirectivesFromDocument([
|
|
426
445
|
{ name: "client", remove: true },
|
|
427
446
|
{ name: "connection" },
|
|
@@ -483,7 +502,7 @@ export class QueryManager {
|
|
|
483
502
|
queryInfo.setObservableQuery(observable);
|
|
484
503
|
return observable;
|
|
485
504
|
}
|
|
486
|
-
query(options, queryId = this.generateQueryId()) {
|
|
505
|
+
async query(options, queryId = this.generateQueryId()) {
|
|
487
506
|
const query = this.transform(options.query);
|
|
488
507
|
return this.fetchQuery(queryId, {
|
|
489
508
|
...options,
|
|
@@ -520,16 +539,11 @@ export class QueryManager {
|
|
|
520
539
|
// depend on values that previously existed in the data portion of the
|
|
521
540
|
// store. So, we cancel the promises and observers that we have issued
|
|
522
541
|
// so far and not yet resolved (in the case of queries).
|
|
523
|
-
this.cancelPendingFetches(newInvariantError(
|
|
524
|
-
this.queries.forEach((
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
queryInfo.observableQuery["networkStatus"] = NetworkStatus.loading;
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
queryInfo.stop();
|
|
532
|
-
}
|
|
542
|
+
this.cancelPendingFetches(newInvariantError(86));
|
|
543
|
+
this.queries.forEach(({ observableQuery }) => {
|
|
544
|
+
// Set loading to true so listeners don't trigger unless they want
|
|
545
|
+
// results with partial data.
|
|
546
|
+
observableQuery?.reset();
|
|
533
547
|
});
|
|
534
548
|
if (this.mutationStore) {
|
|
535
549
|
this.mutationStore = {};
|
|
@@ -608,26 +622,25 @@ export class QueryManager {
|
|
|
608
622
|
if (!included) {
|
|
609
623
|
const queryName = queryNames.get(nameOrQueryString);
|
|
610
624
|
if (queryName) {
|
|
611
|
-
__DEV__ && invariant.warn(
|
|
625
|
+
__DEV__ && invariant.warn(87, queryName);
|
|
612
626
|
}
|
|
613
627
|
else {
|
|
614
|
-
__DEV__ && invariant.warn(
|
|
628
|
+
__DEV__ && invariant.warn(88);
|
|
615
629
|
}
|
|
616
630
|
}
|
|
617
631
|
});
|
|
618
632
|
}
|
|
619
633
|
return queries;
|
|
620
634
|
}
|
|
621
|
-
|
|
635
|
+
refetchObservableQueries(includeStandby = false) {
|
|
622
636
|
const observableQueryPromises = [];
|
|
623
637
|
this.getObservableQueries(includeStandby ? "all" : "active").forEach((observableQuery, queryId) => {
|
|
624
638
|
const { fetchPolicy } = observableQuery.options;
|
|
625
|
-
observableQuery.resetLastResults();
|
|
626
639
|
if (includeStandby ||
|
|
627
640
|
(fetchPolicy !== "standby" && fetchPolicy !== "cache-only")) {
|
|
628
641
|
observableQueryPromises.push(observableQuery.refetch());
|
|
629
642
|
}
|
|
630
|
-
(this.queries.get(queryId) || observableQuery["queryInfo"]).
|
|
643
|
+
(this.queries.get(queryId) || observableQuery["queryInfo"]).resetDiff();
|
|
631
644
|
});
|
|
632
645
|
this.broadcastQueries();
|
|
633
646
|
return Promise.all(observableQueryPromises);
|
|
@@ -681,9 +694,15 @@ export class QueryManager {
|
|
|
681
694
|
return of({ data: undefined, error });
|
|
682
695
|
}), filter((result) => !!(result.data || result.error)));
|
|
683
696
|
if (this.getDocumentInfo(query).hasClientExports) {
|
|
684
|
-
|
|
685
|
-
.
|
|
686
|
-
|
|
697
|
+
if (__DEV__) {
|
|
698
|
+
invariant(this.localState, 89, getOperationName(query, "(anonymous)"));
|
|
699
|
+
}
|
|
700
|
+
const observablePromise = this.localState.getExportedVariables({
|
|
701
|
+
client: this.client,
|
|
702
|
+
document: query,
|
|
703
|
+
variables,
|
|
704
|
+
context,
|
|
705
|
+
}).then(makeObservable);
|
|
687
706
|
return new Observable((observer) => {
|
|
688
707
|
let sub = null;
|
|
689
708
|
observablePromise.then((observable) => (sub = observable.subscribe(observer)), observer.error);
|
|
@@ -700,17 +719,19 @@ export class QueryManager {
|
|
|
700
719
|
// The same queryId could have two rejection fns for two promises
|
|
701
720
|
this.fetchCancelFns.delete(queryId);
|
|
702
721
|
if (this.queries.has(queryId)) {
|
|
703
|
-
this.queries.get(queryId)
|
|
722
|
+
const oq = this.queries.get(queryId).observableQuery;
|
|
723
|
+
if (oq) {
|
|
724
|
+
oq["resetNotifications"]();
|
|
725
|
+
oq["unsubscribeFromCache"]?.();
|
|
726
|
+
oq.stopPolling();
|
|
727
|
+
}
|
|
704
728
|
this.queries.delete(queryId);
|
|
705
729
|
}
|
|
706
730
|
}
|
|
707
731
|
broadcastQueries() {
|
|
708
732
|
if (this.onBroadcast)
|
|
709
733
|
this.onBroadcast();
|
|
710
|
-
this.queries.forEach((info) => info.observableQuery?.
|
|
711
|
-
}
|
|
712
|
-
getLocalState() {
|
|
713
|
-
return this.localState;
|
|
734
|
+
this.queries.forEach((info) => info.observableQuery?.notify());
|
|
714
735
|
}
|
|
715
736
|
// Use protected instead of private field so
|
|
716
737
|
// @apollo/experimental-nextjs-app-support can access type info.
|
|
@@ -721,15 +742,7 @@ export class QueryManager {
|
|
|
721
742
|
this.queryDeduplication) {
|
|
722
743
|
let observable;
|
|
723
744
|
const { serverQuery, clientQuery } = this.getDocumentInfo(query);
|
|
724
|
-
const
|
|
725
|
-
const newContext = this.localState.prepareContext(context);
|
|
726
|
-
return {
|
|
727
|
-
...this.defaultContext,
|
|
728
|
-
...newContext,
|
|
729
|
-
queryDeduplication: deduplication,
|
|
730
|
-
clientAwareness: this.clientAwareness,
|
|
731
|
-
};
|
|
732
|
-
};
|
|
745
|
+
const operationName = getOperationName(query);
|
|
733
746
|
const executeContext = {
|
|
734
747
|
client: this.client,
|
|
735
748
|
};
|
|
@@ -738,8 +751,13 @@ export class QueryManager {
|
|
|
738
751
|
const operation = {
|
|
739
752
|
query: serverQuery,
|
|
740
753
|
variables,
|
|
741
|
-
operationName
|
|
742
|
-
context:
|
|
754
|
+
operationName,
|
|
755
|
+
context: {
|
|
756
|
+
...this.defaultContext,
|
|
757
|
+
...context,
|
|
758
|
+
queryDeduplication: deduplication,
|
|
759
|
+
clientAwareness: this.clientAwareness,
|
|
760
|
+
},
|
|
743
761
|
extensions,
|
|
744
762
|
};
|
|
745
763
|
context = operation.context;
|
|
@@ -766,11 +784,20 @@ export class QueryManager {
|
|
|
766
784
|
}
|
|
767
785
|
else {
|
|
768
786
|
observable = of({ data: {} });
|
|
769
|
-
context = prepareContext(context);
|
|
770
787
|
}
|
|
771
788
|
if (clientQuery) {
|
|
789
|
+
if (__DEV__) {
|
|
790
|
+
const { operation } = getOperationDefinition(query);
|
|
791
|
+
invariant(
|
|
792
|
+
this.localState,
|
|
793
|
+
90,
|
|
794
|
+
operation[0].toUpperCase() + operation.slice(1),
|
|
795
|
+
operationName ?? "(anonymous)"
|
|
796
|
+
);
|
|
797
|
+
}
|
|
772
798
|
observable = observable.pipe(mergeMap((result) => {
|
|
773
|
-
return from(this.localState.
|
|
799
|
+
return from(this.localState.execute({
|
|
800
|
+
client: this.client,
|
|
774
801
|
document: clientQuery,
|
|
775
802
|
remoteResult: result,
|
|
776
803
|
context,
|
|
@@ -846,11 +873,11 @@ export class QueryManager {
|
|
|
846
873
|
return of(aqr);
|
|
847
874
|
}));
|
|
848
875
|
}
|
|
849
|
-
fetchObservableWithInfo(queryInfo, options,
|
|
876
|
+
fetchObservableWithInfo(queryInfo, options, {
|
|
850
877
|
// The initial networkStatus for this fetch, most often
|
|
851
878
|
// NetworkStatus.loading, but also possibly fetchMore, poll, refetch,
|
|
852
879
|
// or setVariables.
|
|
853
|
-
networkStatus = NetworkStatus.loading, query = options.query,
|
|
880
|
+
networkStatus = NetworkStatus.loading, query = options.query, fetchQueryOperator = (x) => x, onCacheHit = () => { }, }) {
|
|
854
881
|
const variables = this.getVariables(query, options.variables);
|
|
855
882
|
const defaults = this.defaultOptions.watchQuery;
|
|
856
883
|
let { fetchPolicy = (defaults && defaults.fetchPolicy) || "cache-first", errorPolicy = (defaults && defaults.errorPolicy) || "none", returnPartialData = false, notifyOnNetworkStatusChange = true, context = {}, } = options;
|
|
@@ -872,7 +899,16 @@ export class QueryManager {
|
|
|
872
899
|
// modify its properties here, rather than creating yet another new
|
|
873
900
|
// WatchQueryOptions object.
|
|
874
901
|
normalized.variables = variables;
|
|
875
|
-
const
|
|
902
|
+
const cacheWriteBehavior = fetchPolicy === "no-cache" ? 0 /* CacheWriteBehavior.FORBID */
|
|
903
|
+
// Watched queries must opt into overwriting existing data on refetch,
|
|
904
|
+
// by passing refetchWritePolicy: "overwrite" in their WatchQueryOptions.
|
|
905
|
+
: (networkStatus === NetworkStatus.refetch &&
|
|
906
|
+
normalized.refetchWritePolicy !== "merge") ?
|
|
907
|
+
1 /* CacheWriteBehavior.OVERWRITE */
|
|
908
|
+
: 2 /* CacheWriteBehavior.MERGE */;
|
|
909
|
+
const observableWithInfo = this.fetchQueryByPolicy(queryInfo, normalized, cacheWriteBehavior, onCacheHit);
|
|
910
|
+
observableWithInfo.observable =
|
|
911
|
+
observableWithInfo.observable.pipe(fetchQueryOperator);
|
|
876
912
|
if (
|
|
877
913
|
// If we're in standby, postpone advancing options.fetchPolicy using
|
|
878
914
|
// applyNextFetchPolicy.
|
|
@@ -891,8 +927,13 @@ export class QueryManager {
|
|
|
891
927
|
// observables to complete before itself completes.
|
|
892
928
|
fetchCancelSubject.complete();
|
|
893
929
|
};
|
|
894
|
-
this.fetchCancelFns.set(queryInfo.queryId, (
|
|
895
|
-
fetchCancelSubject.
|
|
930
|
+
this.fetchCancelFns.set(queryInfo.queryId, (error) => {
|
|
931
|
+
fetchCancelSubject.next({
|
|
932
|
+
kind: "E",
|
|
933
|
+
error,
|
|
934
|
+
source: "network",
|
|
935
|
+
});
|
|
936
|
+
fetchCancelSubject.complete();
|
|
896
937
|
cleanupCancelFn();
|
|
897
938
|
});
|
|
898
939
|
const fetchCancelSubject = new Subject();
|
|
@@ -905,7 +946,15 @@ export class QueryManager {
|
|
|
905
946
|
// for backwards compatibility. TODO This code could be simpler if
|
|
906
947
|
// we deprecated and removed LocalState.
|
|
907
948
|
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
908
|
-
|
|
949
|
+
if (__DEV__) {
|
|
950
|
+
invariant(this.localState, 91, getOperationName(normalized.query, "(anonymous)"));
|
|
951
|
+
}
|
|
952
|
+
observable = from(this.localState.getExportedVariables({
|
|
953
|
+
client: this.client,
|
|
954
|
+
document: normalized.query,
|
|
955
|
+
variables: normalized.variables,
|
|
956
|
+
context: normalized.context,
|
|
957
|
+
})).pipe(mergeMap((variables) => fromVariables(variables).observable));
|
|
909
958
|
// there is just no way we can synchronously get the *right* value here,
|
|
910
959
|
// so we will assume `true`, which is the behaviour before the bug fix in
|
|
911
960
|
// #10597. This means that bug is not fixed in that case, and is probably
|
|
@@ -927,14 +976,19 @@ export class QueryManager {
|
|
|
927
976
|
const includedQueriesById = new Map();
|
|
928
977
|
if (include) {
|
|
929
978
|
this.getObservableQueries(include).forEach((oq, queryId) => {
|
|
979
|
+
const current = oq.getCurrentResult();
|
|
930
980
|
includedQueriesById.set(queryId, {
|
|
931
981
|
oq,
|
|
932
|
-
lastDiff:
|
|
982
|
+
lastDiff: {
|
|
983
|
+
result: current?.data,
|
|
984
|
+
complete: !current?.partial,
|
|
985
|
+
},
|
|
933
986
|
});
|
|
934
987
|
});
|
|
935
988
|
}
|
|
936
989
|
const results = new Map();
|
|
937
990
|
if (updateCache) {
|
|
991
|
+
const handled = new Set();
|
|
938
992
|
this.cache.batch({
|
|
939
993
|
update: updateCache,
|
|
940
994
|
// Since you can perform any combination of cache reads and/or writes in
|
|
@@ -976,9 +1030,10 @@ export class QueryManager {
|
|
|
976
1030
|
// temporary optimistic layer, in case that ever matters.
|
|
977
1031
|
removeOptimistic,
|
|
978
1032
|
onWatchUpdated(watch, diff, lastDiff) {
|
|
979
|
-
const oq = watch.watcher
|
|
980
|
-
if (oq) {
|
|
981
|
-
if (onQueryUpdated) {
|
|
1033
|
+
const oq = watch.watcher;
|
|
1034
|
+
if (oq instanceof ObservableQuery) {
|
|
1035
|
+
if (onQueryUpdated && !handled.has(oq)) {
|
|
1036
|
+
handled.add(oq);
|
|
982
1037
|
// Since we're about to handle this query now, remove it from
|
|
983
1038
|
// includedQueriesById, in case it was added earlier because of
|
|
984
1039
|
// options.include.
|
|
@@ -1015,7 +1070,7 @@ export class QueryManager {
|
|
|
1015
1070
|
// queries, even the QueryOptions ones.
|
|
1016
1071
|
if (onQueryUpdated) {
|
|
1017
1072
|
if (!diff) {
|
|
1018
|
-
diff = this.cache.diff(oq["queryInfo"]
|
|
1073
|
+
diff = this.cache.diff(oq["queryInfo"].getDiffOptions());
|
|
1019
1074
|
}
|
|
1020
1075
|
result = onQueryUpdated(oq, diff, lastDiff);
|
|
1021
1076
|
}
|
|
@@ -1055,8 +1110,7 @@ export class QueryManager {
|
|
|
1055
1110
|
!isFullyUnmaskedOperation(document) &&
|
|
1056
1111
|
!this.noCacheWarningsByQueryId.has(operationId)) {
|
|
1057
1112
|
this.noCacheWarningsByQueryId.add(operationId);
|
|
1058
|
-
__DEV__ && invariant.warn(
|
|
1059
|
-
`Unnamed ${operationType ?? "operation"}`);
|
|
1113
|
+
__DEV__ && invariant.warn(92, getOperationName(document, `Unnamed ${operationType ?? "operation"}`));
|
|
1060
1114
|
}
|
|
1061
1115
|
}
|
|
1062
1116
|
return (this.dataMasking ?
|
|
@@ -1069,17 +1123,13 @@ export class QueryManager {
|
|
|
1069
1123
|
maskFragment(data, fragment, this.cache, fragmentName)
|
|
1070
1124
|
: data;
|
|
1071
1125
|
}
|
|
1072
|
-
fetchQueryByPolicy(queryInfo, { query, variables, fetchPolicy,
|
|
1073
|
-
// The initial networkStatus for this fetch, most often
|
|
1074
|
-
// NetworkStatus.loading, but also possibly fetchMore, poll, refetch,
|
|
1075
|
-
// or setVariables.
|
|
1076
|
-
newNetworkStatus, emitLoadingState) {
|
|
1126
|
+
fetchQueryByPolicy(queryInfo, { query, variables, fetchPolicy, errorPolicy, returnPartialData, context, }, cacheWriteBehavior, onCacheHit) {
|
|
1077
1127
|
queryInfo.init({
|
|
1078
1128
|
document: query,
|
|
1079
1129
|
variables,
|
|
1080
1130
|
});
|
|
1081
|
-
const readCache = () => queryInfo.
|
|
1082
|
-
const resultsFromCache = (diff, networkStatus
|
|
1131
|
+
const readCache = () => this.cache.diff(queryInfo.getDiffOptions());
|
|
1132
|
+
const resultsFromCache = (diff, networkStatus) => {
|
|
1083
1133
|
const data = diff.result;
|
|
1084
1134
|
if (__DEV__ && !returnPartialData && data !== null) {
|
|
1085
1135
|
logMissingFieldErrors(diff.missing);
|
|
@@ -1101,25 +1151,35 @@ export class QueryManager {
|
|
|
1101
1151
|
};
|
|
1102
1152
|
};
|
|
1103
1153
|
const fromData = (data) => {
|
|
1104
|
-
return of(
|
|
1154
|
+
return of({
|
|
1155
|
+
kind: "N",
|
|
1156
|
+
value: toResult(data),
|
|
1157
|
+
source: "cache",
|
|
1158
|
+
});
|
|
1105
1159
|
};
|
|
1106
|
-
if (
|
|
1107
|
-
|
|
1108
|
-
|
|
1160
|
+
if (
|
|
1161
|
+
// Don't attempt to run forced resolvers if we have incomplete cache
|
|
1162
|
+
// data and partial isn't allowed since this result would get set to
|
|
1163
|
+
// `undefined` anyways in `toResult`.
|
|
1164
|
+
(diff.complete || returnPartialData) &&
|
|
1165
|
+
this.getDocumentInfo(query).hasForcedResolvers) {
|
|
1166
|
+
if (__DEV__) {
|
|
1167
|
+
invariant(this.localState, 93, getOperationName(query, "(anonymous)"));
|
|
1168
|
+
}
|
|
1169
|
+
onCacheHit();
|
|
1170
|
+
return from(this.localState.execute({
|
|
1171
|
+
client: this.client,
|
|
1109
1172
|
document: query,
|
|
1110
|
-
|
|
1111
|
-
// statement contained a check against `data`, but this value was
|
|
1112
|
-
// always `{}` if nothing was in the cache, which meant the check
|
|
1113
|
-
// above always succeeded when there were forced resolvers. Now that
|
|
1114
|
-
// `data` is nullable, this `remoteResult` needs to be an empty
|
|
1115
|
-
// object. Ideally we can pass in `null` here and the resolvers
|
|
1116
|
-
// would be able to handle this the same way.
|
|
1117
|
-
remoteResult: { data: data || {} },
|
|
1173
|
+
remoteResult: data ? { data } : undefined,
|
|
1118
1174
|
context,
|
|
1119
1175
|
variables,
|
|
1120
1176
|
onlyRunForcedResolvers: true,
|
|
1121
|
-
|
|
1122
|
-
|
|
1177
|
+
returnPartialData: true,
|
|
1178
|
+
}).then((resolved) => ({
|
|
1179
|
+
kind: "N",
|
|
1180
|
+
value: toResult(resolved.data || void 0),
|
|
1181
|
+
source: "cache",
|
|
1182
|
+
})));
|
|
1123
1183
|
}
|
|
1124
1184
|
// Resolves https://github.com/apollographql/apollo-client/issues/10317.
|
|
1125
1185
|
// If errorPolicy is 'none' and notifyOnNetworkStatusChange is true,
|
|
@@ -1132,20 +1192,16 @@ export class QueryManager {
|
|
|
1132
1192
|
}
|
|
1133
1193
|
return fromData(data || undefined);
|
|
1134
1194
|
};
|
|
1135
|
-
const cacheWriteBehavior = fetchPolicy === "no-cache" ? 0 /* CacheWriteBehavior.FORBID */
|
|
1136
|
-
// Watched queries must opt into overwriting existing data on refetch,
|
|
1137
|
-
// by passing refetchWritePolicy: "overwrite" in their WatchQueryOptions.
|
|
1138
|
-
: (newNetworkStatus === NetworkStatus.refetch &&
|
|
1139
|
-
refetchWritePolicy !== "merge") ?
|
|
1140
|
-
1 /* CacheWriteBehavior.OVERWRITE */
|
|
1141
|
-
: 2 /* CacheWriteBehavior.MERGE */;
|
|
1142
1195
|
const resultsFromLink = () => this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
|
|
1143
1196
|
query,
|
|
1144
1197
|
variables,
|
|
1145
1198
|
context,
|
|
1146
1199
|
fetchPolicy,
|
|
1147
1200
|
errorPolicy,
|
|
1148
|
-
}).pipe(validateDidEmitValue())
|
|
1201
|
+
}).pipe(validateDidEmitValue(), materialize(), map((result) => ({
|
|
1202
|
+
...result,
|
|
1203
|
+
source: "network",
|
|
1204
|
+
})));
|
|
1149
1205
|
switch (fetchPolicy) {
|
|
1150
1206
|
default:
|
|
1151
1207
|
case "cache-first": {
|
|
@@ -1156,20 +1212,20 @@ export class QueryManager {
|
|
|
1156
1212
|
observable: resultsFromCache(diff, NetworkStatus.ready),
|
|
1157
1213
|
};
|
|
1158
1214
|
}
|
|
1159
|
-
if (returnPartialData
|
|
1215
|
+
if (returnPartialData) {
|
|
1160
1216
|
return {
|
|
1161
1217
|
fromLink: true,
|
|
1162
|
-
observable: concat(resultsFromCache(diff), resultsFromLink()),
|
|
1218
|
+
observable: concat(resultsFromCache(diff, NetworkStatus.loading), resultsFromLink()),
|
|
1163
1219
|
};
|
|
1164
1220
|
}
|
|
1165
1221
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1166
1222
|
}
|
|
1167
1223
|
case "cache-and-network": {
|
|
1168
1224
|
const diff = readCache();
|
|
1169
|
-
if (diff.complete || returnPartialData
|
|
1225
|
+
if (diff.complete || returnPartialData) {
|
|
1170
1226
|
return {
|
|
1171
1227
|
fromLink: true,
|
|
1172
|
-
observable: concat(resultsFromCache(diff), resultsFromLink()),
|
|
1228
|
+
observable: concat(resultsFromCache(diff, NetworkStatus.loading), resultsFromLink()),
|
|
1173
1229
|
};
|
|
1174
1230
|
}
|
|
1175
1231
|
return { fromLink: true, observable: resultsFromLink() };
|
|
@@ -1180,23 +1236,8 @@ export class QueryManager {
|
|
|
1180
1236
|
observable: concat(resultsFromCache(readCache(), NetworkStatus.ready)),
|
|
1181
1237
|
};
|
|
1182
1238
|
case "network-only":
|
|
1183
|
-
if (emitLoadingState) {
|
|
1184
|
-
return {
|
|
1185
|
-
fromLink: true,
|
|
1186
|
-
observable: concat(resultsFromCache(readCache()), resultsFromLink()),
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
1239
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1190
1240
|
case "no-cache":
|
|
1191
|
-
if (emitLoadingState) {
|
|
1192
|
-
return {
|
|
1193
|
-
fromLink: true,
|
|
1194
|
-
// Note that queryInfo.getDiff() for no-cache queries does not call
|
|
1195
|
-
// cache.diff, but instead returns a { complete: false } stub result
|
|
1196
|
-
// when there is no queryInfo.diff already defined.
|
|
1197
|
-
observable: concat(resultsFromCache(queryInfo.getDiff()), resultsFromLink()),
|
|
1198
|
-
};
|
|
1199
|
-
}
|
|
1200
1241
|
return { fromLink: true, observable: resultsFromLink() };
|
|
1201
1242
|
case "standby":
|
|
1202
1243
|
return { fromLink: false, observable: EMPTY };
|
|
@@ -1216,7 +1257,7 @@ function validateDidEmitValue() {
|
|
|
1216
1257
|
didEmitValue = true;
|
|
1217
1258
|
},
|
|
1218
1259
|
complete() {
|
|
1219
|
-
invariant(didEmitValue,
|
|
1260
|
+
invariant(didEmitValue, 94);
|
|
1220
1261
|
},
|
|
1221
1262
|
});
|
|
1222
1263
|
}
|