@apollo/client 4.3.0-alpha.0 → 4.3.0-alpha.10
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/CHANGELOG.md +490 -0
- package/README.md +3 -7
- package/__cjs/cache/core/Scalar.cjs +36 -0
- package/__cjs/cache/core/Scalar.cjs.map +1 -0
- package/__cjs/cache/core/Scalar.d.cts +20 -0
- package/__cjs/cache/core/cache.cjs +32 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +89 -6
- package/__cjs/cache/core/types/Cache.d.cts +25 -0
- package/__cjs/cache/index.cjs +3 -1
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +3 -2
- package/__cjs/cache/inmemory/entityStore.cjs +48 -5
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +3 -0
- package/__cjs/cache/inmemory/helpers.d.cts +9 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +83 -4
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +44 -5
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +35 -6
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +4 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +490 -49
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.d.cts +11 -2
- package/__cjs/cache/inmemory/types.d.cts +29 -4
- package/__cjs/cache/inmemory/writeToStore.cjs +6 -6
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +37 -38
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +44 -10
- package/__cjs/core/ObservableQuery.cjs +228 -76
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +16 -8
- package/__cjs/core/QueryInfo.cjs +178 -190
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +17 -22
- package/__cjs/core/QueryManager.cjs +88 -59
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +1 -3
- package/__cjs/core/RefetchEventManager.cjs +3 -3
- package/__cjs/core/dataStateErrorCache.cjs +12 -0
- package/__cjs/core/dataStateErrorCache.cjs.map +1 -0
- package/__cjs/core/dataStateErrorCache.d.cts +3 -0
- package/__cjs/core/index.cjs +2 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +4 -3
- package/__cjs/core/types.d.cts +12 -6
- package/__cjs/incremental/GraphQLCodegenIncremental.cjs +3 -0
- package/__cjs/incremental/GraphQLCodegenIncremental.cjs.map +1 -0
- package/__cjs/incremental/GraphQLCodegenIncremental.d.cts +55 -0
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +2 -4
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +47 -16
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +29 -6
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/incremental/index.cjs.map +1 -1
- package/__cjs/incremental/index.d.cts +1 -0
- package/__cjs/incremental/internal/types.cjs +3 -0
- package/__cjs/incremental/internal/types.cjs.map +1 -0
- package/__cjs/incremental/internal/types.d.cts +17 -0
- package/__cjs/incremental/types.d.cts +55 -4
- package/__cjs/invariantErrorCodes.cjs +167 -112
- package/__cjs/link/core/ApolloLink.cjs +3 -3
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +2 -2
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/ws/index.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +11 -11
- package/__cjs/masking/internal/types.d.cts +1 -2
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/utils.cjs +3 -3
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +2 -2
- package/__cjs/react/hooks/useApolloClient.cjs +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +100 -47
- package/__cjs/react/hooks/useLazyQuery.cjs +2 -2
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +39 -33
- package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +23 -15
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +10 -7
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +74 -32
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +83 -34
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/types.d.cts +14 -3
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -5
- package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
- package/__cjs/react/types/deprecated.d.cts +5 -4
- package/__cjs/testing/core/mocking/mockLink.cjs +25 -5
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +1 -2
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +39 -1
- package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +1 -0
- package/__cjs/utilities/internal/StreamArrayState.cjs +27 -0
- package/__cjs/utilities/internal/StreamArrayState.cjs.map +1 -0
- package/__cjs/utilities/internal/StreamArrayState.d.cts +12 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.cjs +33 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.cjs.map +1 -0
- package/__cjs/utilities/internal/addDeferFragmentLabels.d.cts +3 -0
- package/__cjs/utilities/internal/capitalize.cjs +12 -0
- package/__cjs/utilities/internal/capitalize.cjs.map +1 -0
- package/__cjs/utilities/internal/capitalize.d.cts +7 -0
- package/__cjs/utilities/internal/coerceScalarFieldsToParsed.cjs +69 -0
- package/__cjs/utilities/internal/coerceScalarFieldsToParsed.cjs.map +1 -0
- package/__cjs/utilities/internal/coerceScalarFieldsToParsed.d.cts +9 -0
- package/__cjs/utilities/internal/constants.cjs +20 -1
- package/__cjs/utilities/internal/constants.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.d.cts +19 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.cjs +19 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.cjs.map +1 -0
- package/__cjs/utilities/internal/getDirectiveArgValue.d.cts +9 -0
- package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs +2 -2
- package/__cjs/utilities/internal/getFragmentFromSelection.cjs.map +1 -1
- package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +2 -2
- package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs +6 -0
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +4 -0
- package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
- package/__cjs/utilities/internal/getUnwrappedType.cjs +20 -0
- package/__cjs/utilities/internal/getUnwrappedType.cjs.map +1 -0
- package/__cjs/utilities/internal/getUnwrappedType.d.cts +8 -0
- package/__cjs/utilities/internal/index.cjs +25 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +16 -1
- package/__cjs/utilities/internal/isDeferredFragment.cjs +38 -0
- package/__cjs/utilities/internal/isDeferredFragment.cjs.map +1 -0
- package/__cjs/utilities/internal/isDeferredFragment.d.cts +9 -0
- package/__cjs/utilities/internal/isStreamField.cjs +37 -0
- package/__cjs/utilities/internal/isStreamField.cjs.map +1 -0
- package/__cjs/utilities/internal/isStreamField.d.cts +9 -0
- package/__cjs/utilities/internal/isTypenameField.cjs +7 -0
- package/__cjs/utilities/internal/isTypenameField.cjs.map +1 -0
- package/__cjs/utilities/internal/isTypenameField.d.cts +3 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.cjs +17 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.cjs.map +1 -0
- package/__cjs/utilities/internal/makeStreamInfoTrie.d.cts +8 -0
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +1 -1
- package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
- package/__cjs/utilities/internal/toDiffWithDataState.cjs +20 -0
- package/__cjs/utilities/internal/toDiffWithDataState.cjs.map +1 -0
- package/__cjs/utilities/internal/toDiffWithDataState.d.cts +8 -0
- package/__cjs/utilities/internal/types/DeferInfo.cjs +3 -0
- package/__cjs/utilities/internal/types/DeferInfo.cjs.map +1 -0
- package/__cjs/utilities/internal/types/DeferInfo.d.cts +10 -0
- package/__cjs/utilities/internal/types/Exact.cjs +3 -0
- package/__cjs/utilities/internal/types/Exact.cjs.map +1 -0
- package/__cjs/utilities/internal/types/Exact.d.cts +2 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.cjs +3 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.cjs.map +1 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.d.cts +10 -0
- package/__cjs/utilities/internal/types/IsNeverish.cjs +3 -0
- package/__cjs/utilities/internal/types/IsNeverish.cjs.map +1 -0
- package/__cjs/utilities/internal/types/IsNeverish.d.cts +4 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.d.cts +2 -0
- package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
- package/__cjs/utilities/policies/pagination.cjs.map +1 -1
- package/__cjs/utilities/policies/pagination.d.cts +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs +1 -0
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/core/Scalar.d.ts +20 -0
- package/cache/core/Scalar.js +32 -0
- package/cache/core/Scalar.js.map +1 -0
- package/cache/core/cache.d.ts +89 -6
- package/cache/core/cache.js +33 -2
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +25 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/index.d.ts +3 -2
- package/cache/index.js +1 -0
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +3 -0
- package/cache/inmemory/entityStore.js +49 -6
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +9 -1
- package/cache/inmemory/inMemoryCache.d.ts +44 -5
- package/cache/inmemory/inMemoryCache.js +84 -5
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.d.ts +4 -1
- package/cache/inmemory/policies.js +35 -6
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +11 -2
- package/cache/inmemory/readFromStore.js +486 -49
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +30 -5
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +7 -7
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +44 -10
- package/core/ApolloClient.js +37 -38
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +16 -8
- package/core/ObservableQuery.js +225 -77
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +18 -23
- package/core/QueryInfo.js +174 -190
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +1 -3
- package/core/QueryManager.js +89 -60
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.js +3 -3
- package/core/dataStateErrorCache.d.ts +3 -0
- package/core/dataStateErrorCache.js +9 -0
- package/core/dataStateErrorCache.js.map +1 -0
- package/core/index.d.ts +4 -3
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/core/types.d.ts +12 -6
- package/core/types.js.map +1 -1
- package/incremental/GraphQLCodegenIncremental.d.ts +55 -0
- package/incremental/GraphQLCodegenIncremental.js +2 -0
- package/incremental/GraphQLCodegenIncremental.js.map +1 -0
- package/incremental/handlers/defer20220824.d.ts +2 -4
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +29 -6
- package/incremental/handlers/graphql17Alpha9.js +48 -17
- package/incremental/handlers/graphql17Alpha9.js.map +1 -1
- package/incremental/handlers/notImplemented.js +1 -1
- package/incremental/index.d.ts +1 -0
- package/incremental/index.js.map +1 -1
- package/incremental/internal/types.d.ts +17 -0
- package/incremental/internal/types.js +2 -0
- package/incremental/internal/types.js.map +1 -0
- package/incremental/types.d.ts +55 -4
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +167 -112
- package/link/core/ApolloLink.js +3 -3
- package/link/http/checkFetcher.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +2 -2
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/ws/index.js +1 -1
- package/local-state/LocalState.js +11 -11
- package/masking/internal/types.d.ts +1 -2
- package/masking/internal/types.js.map +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/utils.js +3 -3
- package/package.json +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +100 -47
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +39 -33
- package/react/hooks/useLazyQuery.js +2 -2
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +23 -15
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +10 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +74 -32
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +83 -34
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/hooks-compiled/internal/validateSuspenseHookOptions.js +2 -2
- package/react/hooks-compiled/useApolloClient.js +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +100 -47
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +39 -33
- package/react/hooks-compiled/useLazyQuery.js +2 -2
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +23 -15
- package/react/hooks-compiled/useLoadableQuery.js +2 -2
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +10 -7
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +74 -32
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useSubscription.js +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +83 -34
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js +1 -1
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/types.d.ts +15 -4
- package/react/internal/types.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +20 -5
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/prerenderStatic.js +2 -2
- package/react/types/deprecated.d.ts +5 -4
- package/react/types/deprecated.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +1 -2
- package/testing/core/mocking/mockLink.js +25 -5
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/utilities/caching/sizes.d.ts +39 -1
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/index.d.ts +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/internal/StreamArrayState.d.ts +12 -0
- package/utilities/internal/StreamArrayState.js +23 -0
- package/utilities/internal/StreamArrayState.js.map +1 -0
- package/utilities/internal/addDeferFragmentLabels.d.ts +3 -0
- package/utilities/internal/addDeferFragmentLabels.js +30 -0
- package/utilities/internal/addDeferFragmentLabels.js.map +1 -0
- package/utilities/internal/capitalize.d.ts +7 -0
- package/utilities/internal/capitalize.js +9 -0
- package/utilities/internal/capitalize.js.map +1 -0
- package/utilities/internal/coerceScalarFieldsToParsed.d.ts +9 -0
- package/utilities/internal/coerceScalarFieldsToParsed.js +66 -0
- package/utilities/internal/coerceScalarFieldsToParsed.js.map +1 -0
- package/utilities/internal/constants.d.ts +19 -0
- package/utilities/internal/constants.js +19 -0
- package/utilities/internal/constants.js.map +1 -1
- package/utilities/internal/getDirectiveArgValue.d.ts +9 -0
- package/utilities/internal/getDirectiveArgValue.js +16 -0
- package/utilities/internal/getDirectiveArgValue.js.map +1 -0
- package/utilities/internal/getFragmentDefinition.js +3 -3
- package/utilities/internal/getFragmentFromSelection.js +2 -2
- package/utilities/internal/getFragmentFromSelection.js.map +1 -1
- package/utilities/internal/getFragmentQueryDocument.js +2 -2
- package/utilities/internal/getMainDefinition.js +1 -1
- package/utilities/internal/getMemoryInternals.d.ts +4 -0
- package/utilities/internal/getMemoryInternals.js +6 -0
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/getQueryDefinition.js +1 -1
- package/utilities/internal/getUnwrappedType.d.ts +8 -0
- package/utilities/internal/getUnwrappedType.js +17 -0
- package/utilities/internal/getUnwrappedType.js.map +1 -0
- package/utilities/internal/index.d.ts +16 -1
- package/utilities/internal/index.js +12 -1
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isDeferredFragment.d.ts +9 -0
- package/utilities/internal/isDeferredFragment.js +35 -0
- package/utilities/internal/isDeferredFragment.js.map +1 -0
- package/utilities/internal/isStreamField.d.ts +9 -0
- package/utilities/internal/isStreamField.js +34 -0
- package/utilities/internal/isStreamField.js.map +1 -0
- package/utilities/internal/isTypenameField.d.ts +3 -0
- package/utilities/internal/isTypenameField.js +4 -0
- package/utilities/internal/isTypenameField.js.map +1 -0
- package/utilities/internal/makeStreamInfoTrie.d.ts +8 -0
- package/utilities/internal/makeStreamInfoTrie.js +14 -0
- package/utilities/internal/makeStreamInfoTrie.js.map +1 -0
- package/utilities/internal/removeDirectivesFromDocument.js +1 -1
- package/utilities/internal/shouldInclude.js +4 -4
- package/utilities/internal/toDiffWithDataState.d.ts +8 -0
- package/utilities/internal/toDiffWithDataState.js +17 -0
- package/utilities/internal/toDiffWithDataState.js.map +1 -0
- package/utilities/internal/types/DeferInfo.d.ts +10 -0
- package/utilities/internal/types/DeferInfo.js +2 -0
- package/utilities/internal/types/DeferInfo.js.map +1 -0
- package/utilities/internal/types/Exact.d.ts +2 -0
- package/utilities/internal/types/Exact.js +2 -0
- package/utilities/internal/types/Exact.js.map +1 -0
- package/utilities/internal/types/IsLooselyEqual.d.ts +10 -0
- package/utilities/internal/types/IsLooselyEqual.js +2 -0
- package/utilities/internal/types/IsLooselyEqual.js.map +1 -0
- package/utilities/internal/types/IsNeverish.d.ts +4 -0
- package/utilities/internal/types/IsNeverish.js +2 -0
- package/utilities/internal/types/IsNeverish.js.map +1 -0
- package/utilities/internal/types/StreamInfoTrie.d.ts +2 -0
- package/utilities/internal/types/StreamInfoTrie.js.map +1 -1
- package/utilities/internal/valueToObjectRepresentation.js +1 -1
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/subscriptions/relay/index.js +1 -0
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
package/core/QueryManager.js
CHANGED
|
@@ -9,8 +9,9 @@ import { execute } from "@apollo/client/link";
|
|
|
9
9
|
import { maskFragment, maskOperation } from "@apollo/client/masking";
|
|
10
10
|
import { cacheSizes, DocumentTransform, isNetworkRequestInFlight, print, } from "@apollo/client/utilities";
|
|
11
11
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
12
|
-
import { AutoCleanedWeakCache, checkDocument, extensionsSymbol, filterMap, getDefaultValues, getOperationDefinition, getOperationName, graphQLResultHasError, hasDirectives, hasForcedResolvers, isDocumentNode, isNonNullObject, makeUniqueId, mergeOptions, removeDirectivesFromDocument, streamInfoSymbol, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
12
|
+
import { AutoCleanedWeakCache, checkDocument, coerceScalarFieldsToParsed, extensionsSymbol, filterMap, getDefaultValues, getOperationDefinition, getOperationName, graphQLResultHasError, hasDirectives, hasForcedResolvers, isDocumentNode, isNonNullObject, makeUniqueId, mergeOptions, removeDirectivesFromDocument, streamInfoSymbol, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
13
13
|
import { invariant, newInvariantError, } from "@apollo/client/utilities/invariant";
|
|
14
|
+
import { dataStateErrorCache } from "./dataStateErrorCache.js";
|
|
14
15
|
import { NetworkStatus } from "./networkStatus.js";
|
|
15
16
|
import { logMissingFieldErrors, ObservableQuery } from "./ObservableQuery.js";
|
|
16
17
|
import { QueryInfo } from "./QueryInfo.js";
|
|
@@ -75,6 +76,12 @@ export class QueryManager {
|
|
|
75
76
|
// selections and fragments from the fragment registry.
|
|
76
77
|
.concat(defaultDocumentTransform)
|
|
77
78
|
: defaultDocumentTransform;
|
|
79
|
+
// Put the incremental transform last so custom document transforms don't
|
|
80
|
+
// revert changes made to the document accidentally. Adding last also
|
|
81
|
+
// ensures `@defer` fragments added by the fragment registry are labeled.
|
|
82
|
+
if (this.incrementalHandler.documentTransform) {
|
|
83
|
+
this.documentTransform = this.documentTransform.concat(this.incrementalHandler.documentTransform);
|
|
84
|
+
}
|
|
78
85
|
this.defaultContext = options.defaultContext || {};
|
|
79
86
|
if ((this.onBroadcast = options.onBroadcast)) {
|
|
80
87
|
this.mutationStore = {};
|
|
@@ -92,7 +99,7 @@ export class QueryManager {
|
|
|
92
99
|
*/
|
|
93
100
|
stop() {
|
|
94
101
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
95
|
-
this.cancelPendingFetches(newInvariantError(
|
|
102
|
+
this.cancelPendingFetches(newInvariantError(92));
|
|
96
103
|
}
|
|
97
104
|
cancelPendingFetches(error) {
|
|
98
105
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
@@ -105,7 +112,7 @@ export class QueryManager {
|
|
|
105
112
|
variables = this.getVariables(mutation, variables);
|
|
106
113
|
if (hasClientExports) {
|
|
107
114
|
if (__DEV__) {
|
|
108
|
-
invariant(this.localState,
|
|
115
|
+
invariant(this.localState, 93, getOperationName(mutation, "(anonymous)"));
|
|
109
116
|
}
|
|
110
117
|
variables = await this.localState.getExportedVariables({
|
|
111
118
|
client: this.client,
|
|
@@ -117,7 +124,7 @@ export class QueryManager {
|
|
|
117
124
|
const mutationStoreValue = this.mutationStore &&
|
|
118
125
|
(this.mutationStore[queryInfo.id] = {
|
|
119
126
|
mutation,
|
|
120
|
-
variables,
|
|
127
|
+
variables: this.cache.serializeVariables(mutation, variables),
|
|
121
128
|
loading: true,
|
|
122
129
|
error: null,
|
|
123
130
|
});
|
|
@@ -330,10 +337,6 @@ export class QueryManager {
|
|
|
330
337
|
}),
|
|
331
338
|
}));
|
|
332
339
|
}
|
|
333
|
-
requestIdCounter = 1;
|
|
334
|
-
generateRequestId() {
|
|
335
|
-
return this.requestIdCounter++;
|
|
336
|
-
}
|
|
337
340
|
clearStore(options = {
|
|
338
341
|
discardWatches: true,
|
|
339
342
|
}) {
|
|
@@ -342,7 +345,7 @@ export class QueryManager {
|
|
|
342
345
|
// depend on values that previously existed in the data portion of the
|
|
343
346
|
// store. So, we cancel the promises and observers that we have issued
|
|
344
347
|
// so far and not yet resolved (in the case of queries).
|
|
345
|
-
this.cancelPendingFetches(newInvariantError(
|
|
348
|
+
this.cancelPendingFetches(newInvariantError(94));
|
|
346
349
|
this.obsQueries.forEach((observableQuery) => {
|
|
347
350
|
// Set loading to true so listeners don't trigger unless they want
|
|
348
351
|
// results with partial data.
|
|
@@ -412,10 +415,10 @@ export class QueryManager {
|
|
|
412
415
|
if (!included) {
|
|
413
416
|
const queryName = queryNames.get(nameOrQueryString);
|
|
414
417
|
if (queryName) {
|
|
415
|
-
__DEV__ && invariant.warn(
|
|
418
|
+
__DEV__ && invariant.warn(95, queryName);
|
|
416
419
|
}
|
|
417
420
|
else {
|
|
418
|
-
__DEV__ && invariant.warn(
|
|
421
|
+
__DEV__ && invariant.warn(96);
|
|
419
422
|
}
|
|
420
423
|
}
|
|
421
424
|
});
|
|
@@ -444,7 +447,7 @@ export class QueryManager {
|
|
|
444
447
|
if (__DEV__) {
|
|
445
448
|
invariant(
|
|
446
449
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
447
|
-
|
|
450
|
+
97,
|
|
448
451
|
getOperationName(query, "(anonymous)")
|
|
449
452
|
);
|
|
450
453
|
}
|
|
@@ -519,6 +522,7 @@ export class QueryManager {
|
|
|
519
522
|
const executeContext = {
|
|
520
523
|
client: this.client,
|
|
521
524
|
};
|
|
525
|
+
variables = this.cache.serializeVariables(query, variables);
|
|
522
526
|
if (serverQuery) {
|
|
523
527
|
const { inFlightLinkObservables, link } = this;
|
|
524
528
|
try {
|
|
@@ -588,14 +592,14 @@ export class QueryManager {
|
|
|
588
592
|
if (__DEV__) {
|
|
589
593
|
invariant(
|
|
590
594
|
this.localState,
|
|
591
|
-
|
|
595
|
+
98,
|
|
592
596
|
operation[0].toUpperCase() + operation.slice(1),
|
|
593
597
|
operationName ?? "(anonymous)"
|
|
594
598
|
);
|
|
595
599
|
}
|
|
596
600
|
invariant(
|
|
597
601
|
!hasIncrementalDirective,
|
|
598
|
-
|
|
602
|
+
99,
|
|
599
603
|
operation[0].toUpperCase() + operation.slice(1),
|
|
600
604
|
operationName ?? "(anonymous)"
|
|
601
605
|
);
|
|
@@ -619,8 +623,7 @@ export class QueryManager {
|
|
|
619
623
|
})),
|
|
620
624
|
};
|
|
621
625
|
}
|
|
622
|
-
getResultsFromLink(options, { queryInfo, cacheWriteBehavior, observableQuery, exposeExtensions, }) {
|
|
623
|
-
const requestId = (queryInfo.lastRequestId = this.generateRequestId());
|
|
626
|
+
getResultsFromLink(options, { queryInfo, cacheWriteBehavior, observableQuery, exposeExtensions, prunePendingDeferFragments, }) {
|
|
624
627
|
const { errorPolicy } = options;
|
|
625
628
|
// Performing transformForLink here gives this.cache a chance to fill in
|
|
626
629
|
// missing fragment definitions (for example) before sending this document
|
|
@@ -630,57 +633,49 @@ export class QueryManager {
|
|
|
630
633
|
// Use linkDocument rather than queryInfo.document so the
|
|
631
634
|
// operation/fragments used to write the result are the same as the
|
|
632
635
|
// ones used to obtain it from the link.
|
|
633
|
-
const result = queryInfo.markQueryResult(incoming, {
|
|
636
|
+
const { dataState, ...result } = queryInfo.markQueryResult(incoming, {
|
|
634
637
|
...options,
|
|
635
638
|
document: linkDocument,
|
|
636
639
|
cacheWriteBehavior,
|
|
640
|
+
returnPartialData: options.returnPartialData,
|
|
641
|
+
prunePendingDeferFragments,
|
|
637
642
|
});
|
|
638
643
|
const hasErrors = graphQLResultHasError(result);
|
|
639
644
|
if (hasErrors && errorPolicy === "none") {
|
|
640
|
-
queryInfo.resetLastWrite();
|
|
641
645
|
observableQuery?.["resetNotifications"]();
|
|
642
|
-
|
|
646
|
+
const error = new CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
647
|
+
dataStateErrorCache.set(error, dataState);
|
|
648
|
+
throw error;
|
|
643
649
|
}
|
|
650
|
+
const partial = dataState !== "complete";
|
|
644
651
|
const aqr = {
|
|
645
652
|
data: result.data,
|
|
646
653
|
...(queryInfo.hasNext ?
|
|
647
654
|
{
|
|
648
655
|
loading: true,
|
|
649
656
|
networkStatus: NetworkStatus.streaming,
|
|
650
|
-
dataState
|
|
651
|
-
partial
|
|
657
|
+
dataState,
|
|
658
|
+
partial,
|
|
652
659
|
}
|
|
653
660
|
: {
|
|
654
|
-
dataState
|
|
661
|
+
dataState,
|
|
655
662
|
loading: false,
|
|
656
663
|
networkStatus: NetworkStatus.ready,
|
|
657
|
-
partial
|
|
664
|
+
partial,
|
|
658
665
|
}),
|
|
659
666
|
};
|
|
660
667
|
if (exposeExtensions && "extensions" in result) {
|
|
661
668
|
aqr[extensionsSymbol] = result.extensions;
|
|
662
669
|
}
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
if (hasErrors) {
|
|
668
|
-
if (errorPolicy === "none") {
|
|
669
|
-
aqr.data = void 0;
|
|
670
|
-
aqr.dataState = "empty";
|
|
671
|
-
}
|
|
672
|
-
if (errorPolicy !== "ignore") {
|
|
673
|
-
aqr.error = new CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
674
|
-
if (aqr.dataState !== "streaming") {
|
|
675
|
-
aqr.networkStatus = NetworkStatus.error;
|
|
676
|
-
}
|
|
670
|
+
if (hasErrors && errorPolicy !== "ignore") {
|
|
671
|
+
aqr.error = new CombinedGraphQLErrors(removeStreamDetailsFromExtensions(result));
|
|
672
|
+
if (aqr.networkStatus !== NetworkStatus.streaming) {
|
|
673
|
+
aqr.networkStatus = NetworkStatus.error;
|
|
677
674
|
}
|
|
678
675
|
}
|
|
679
676
|
return aqr;
|
|
680
677
|
}), catchError((error) => {
|
|
681
|
-
|
|
682
|
-
if (requestId >= queryInfo.lastRequestId && errorPolicy === "none") {
|
|
683
|
-
queryInfo.resetLastWrite();
|
|
678
|
+
if (errorPolicy === "none") {
|
|
684
679
|
observableQuery?.["resetNotifications"]();
|
|
685
680
|
throw error;
|
|
686
681
|
}
|
|
@@ -715,6 +710,7 @@ export class QueryManager {
|
|
|
715
710
|
fetchPolicy,
|
|
716
711
|
errorPolicy,
|
|
717
712
|
returnPartialData,
|
|
713
|
+
networkStatus,
|
|
718
714
|
notifyOnNetworkStatusChange,
|
|
719
715
|
context,
|
|
720
716
|
});
|
|
@@ -771,7 +767,7 @@ export class QueryManager {
|
|
|
771
767
|
// we deprecated and removed LocalState.
|
|
772
768
|
if (this.getDocumentInfo(normalized.query).hasClientExports) {
|
|
773
769
|
if (__DEV__) {
|
|
774
|
-
invariant(this.localState,
|
|
770
|
+
invariant(this.localState, 100, getOperationName(normalized.query, "(anonymous)"));
|
|
775
771
|
}
|
|
776
772
|
observable = from(this.localState.getExportedVariables({
|
|
777
773
|
client: this.client,
|
|
@@ -944,7 +940,7 @@ export class QueryManager {
|
|
|
944
940
|
!isFullyUnmaskedOperation(document) &&
|
|
945
941
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
946
942
|
this.noCacheWarningsByCause.add(cause);
|
|
947
|
-
__DEV__ && invariant.warn(
|
|
943
|
+
__DEV__ && invariant.warn(101, getOperationName(document, `Unnamed ${operationType ?? "operation"}`));
|
|
948
944
|
}
|
|
949
945
|
}
|
|
950
946
|
return (this.dataMasking ?
|
|
@@ -957,32 +953,33 @@ export class QueryManager {
|
|
|
957
953
|
maskFragment(data, fragment, this.cache, fragmentName)
|
|
958
954
|
: data;
|
|
959
955
|
}
|
|
960
|
-
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
961
|
-
const readCache = () =>
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
956
|
+
fetchQueryByPolicy({ query, variables, fetchPolicy, errorPolicy, returnPartialData, context, networkStatus, }, { cacheWriteBehavior, onCacheHit, queryInfo, observableQuery, exposeExtensions, }) {
|
|
957
|
+
const readCache = () => {
|
|
958
|
+
return queryInfo.getDiff({
|
|
959
|
+
query,
|
|
960
|
+
variables,
|
|
961
|
+
returnPartialData: true,
|
|
962
|
+
optimistic: true,
|
|
963
|
+
});
|
|
964
|
+
};
|
|
967
965
|
const resultsFromCache = (diff, networkStatus) => {
|
|
968
966
|
const data = diff.result;
|
|
969
967
|
if (__DEV__ && !returnPartialData && data !== null) {
|
|
970
968
|
logMissingFieldErrors(diff.missing);
|
|
971
969
|
}
|
|
972
|
-
const toResult = (data) => {
|
|
970
|
+
const toResult = (data, dataState = diff.dataState) => {
|
|
973
971
|
// TODO: Eventually we should move this handling into
|
|
974
972
|
// queryInfo.getDiff() directly. Since getDiff is updated to return null
|
|
975
973
|
// on returnPartialData: false, we should take advantage of that instead
|
|
976
974
|
// of having to patch it elsewhere.
|
|
977
975
|
if (!diff.complete && !returnPartialData) {
|
|
978
976
|
data = undefined;
|
|
977
|
+
dataState = "empty";
|
|
979
978
|
}
|
|
980
979
|
return {
|
|
981
980
|
// TODO: Handle partial data
|
|
982
981
|
data: data,
|
|
983
|
-
dataState
|
|
984
|
-
: data ? "partial"
|
|
985
|
-
: "empty",
|
|
982
|
+
dataState,
|
|
986
983
|
loading: isNetworkRequestInFlight(networkStatus),
|
|
987
984
|
networkStatus,
|
|
988
985
|
partial: !diff.complete,
|
|
@@ -992,6 +989,10 @@ export class QueryManager {
|
|
|
992
989
|
return of({
|
|
993
990
|
kind: "N",
|
|
994
991
|
value: toResult(data),
|
|
992
|
+
// Always attach the variables used for this fetch so @export
|
|
993
|
+
// resolution can update ObservableQuery.options.variables and
|
|
994
|
+
// resubscribe the cache watch under the correct variable set.
|
|
995
|
+
resolvedVariables: variables,
|
|
995
996
|
source: "cache",
|
|
996
997
|
});
|
|
997
998
|
};
|
|
@@ -1002,7 +1003,7 @@ export class QueryManager {
|
|
|
1002
1003
|
(diff.complete || returnPartialData) &&
|
|
1003
1004
|
this.getDocumentInfo(query).hasForcedResolvers) {
|
|
1004
1005
|
if (__DEV__) {
|
|
1005
|
-
invariant(this.localState,
|
|
1006
|
+
invariant(this.localState, 102, getOperationName(query, "(anonymous)"));
|
|
1006
1007
|
}
|
|
1007
1008
|
onCacheHit();
|
|
1008
1009
|
return from(this.localState.execute({
|
|
@@ -1016,7 +1017,13 @@ export class QueryManager {
|
|
|
1016
1017
|
fetchPolicy,
|
|
1017
1018
|
}).then((resolved) => ({
|
|
1018
1019
|
kind: "N",
|
|
1019
|
-
value: toResult(resolved.data || void 0
|
|
1020
|
+
value: toResult(resolved.data || void 0, diff.complete ? "complete"
|
|
1021
|
+
: resolved.data ? "partial"
|
|
1022
|
+
: "empty"),
|
|
1023
|
+
// Always attach the variables used for this fetch so @export
|
|
1024
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1025
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1026
|
+
resolvedVariables: variables,
|
|
1020
1027
|
source: "cache",
|
|
1021
1028
|
})));
|
|
1022
1029
|
}
|
|
@@ -1031,19 +1038,26 @@ export class QueryManager {
|
|
|
1031
1038
|
}
|
|
1032
1039
|
return fromData(data || undefined);
|
|
1033
1040
|
};
|
|
1034
|
-
const resultsFromLink = () => this.getResultsFromLink({
|
|
1041
|
+
const resultsFromLink = ({ prunePendingDeferFragments = true, } = {}) => this.getResultsFromLink({
|
|
1035
1042
|
query,
|
|
1036
1043
|
variables,
|
|
1037
1044
|
context,
|
|
1038
1045
|
fetchPolicy,
|
|
1039
1046
|
errorPolicy,
|
|
1047
|
+
returnPartialData,
|
|
1048
|
+
networkStatus,
|
|
1040
1049
|
}, {
|
|
1041
1050
|
cacheWriteBehavior,
|
|
1042
1051
|
queryInfo,
|
|
1043
1052
|
observableQuery,
|
|
1044
1053
|
exposeExtensions,
|
|
1054
|
+
prunePendingDeferFragments,
|
|
1045
1055
|
}).pipe(validateDidEmitValue(), materialize(), map((result) => ({
|
|
1046
1056
|
...result,
|
|
1057
|
+
// Always attach the variables used for this fetch so @export
|
|
1058
|
+
// resolution can update ObservableQuery.options.variables and
|
|
1059
|
+
// resubscribe the cache watch under the correct variable set.
|
|
1060
|
+
resolvedVariables: variables,
|
|
1047
1061
|
source: "network",
|
|
1048
1062
|
})));
|
|
1049
1063
|
switch (fetchPolicy) {
|
|
@@ -1069,7 +1083,7 @@ export class QueryManager {
|
|
|
1069
1083
|
if (diff.complete || returnPartialData) {
|
|
1070
1084
|
return {
|
|
1071
1085
|
fromLink: true,
|
|
1072
|
-
observable: concat(resultsFromCache(diff, NetworkStatus.loading), resultsFromLink()),
|
|
1086
|
+
observable: concat(resultsFromCache(diff, NetworkStatus.loading), resultsFromLink({ prunePendingDeferFragments: false })),
|
|
1073
1087
|
};
|
|
1074
1088
|
}
|
|
1075
1089
|
return { fromLink: true, observable: resultsFromLink() };
|
|
@@ -1080,9 +1094,24 @@ export class QueryManager {
|
|
|
1080
1094
|
observable: concat(resultsFromCache(readCache(), NetworkStatus.ready)),
|
|
1081
1095
|
};
|
|
1082
1096
|
case "network-only":
|
|
1083
|
-
return {
|
|
1097
|
+
return {
|
|
1098
|
+
fromLink: true,
|
|
1099
|
+
observable: resultsFromLink({
|
|
1100
|
+
prunePendingDeferFragments: networkStatus !== NetworkStatus.refetch,
|
|
1101
|
+
}),
|
|
1102
|
+
};
|
|
1084
1103
|
case "no-cache":
|
|
1085
|
-
return {
|
|
1104
|
+
return {
|
|
1105
|
+
fromLink: true,
|
|
1106
|
+
observable: resultsFromLink().pipe(map((notification) => {
|
|
1107
|
+
if (notification.kind === "N" &&
|
|
1108
|
+
notification.value.data != null &&
|
|
1109
|
+
this.cache.configuresScalars()) {
|
|
1110
|
+
notification.value.data = coerceScalarFieldsToParsed(notification.value.data, query, this.cache);
|
|
1111
|
+
}
|
|
1112
|
+
return notification;
|
|
1113
|
+
})),
|
|
1114
|
+
};
|
|
1086
1115
|
case "standby":
|
|
1087
1116
|
return { fromLink: false, observable: EMPTY };
|
|
1088
1117
|
}
|
|
@@ -1095,7 +1124,7 @@ function validateDidEmitValue() {
|
|
|
1095
1124
|
didEmitValue = true;
|
|
1096
1125
|
},
|
|
1097
1126
|
complete() {
|
|
1098
|
-
invariant(didEmitValue,
|
|
1127
|
+
invariant(didEmitValue, 103);
|
|
1099
1128
|
},
|
|
1100
1129
|
});
|
|
1101
1130
|
}
|