@apollo/client 4.0.0-alpha.7 → 4.0.0-alpha.9
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/afraid-moons-arrive.md +5 -0
- package/.changeset/beige-mirrors-talk.md +15 -0
- package/.changeset/early-eggs-develop.md +22 -0
- package/.changeset/forty-tomatoes-punch.md +5 -0
- package/.changeset/fuzzy-tips-sit.md +5 -0
- package/.changeset/giant-apes-thank.md +5 -0
- package/.changeset/khaki-keys-deliver.md +5 -0
- package/.changeset/large-plants-know.md +5 -0
- package/.changeset/mean-lizards-think.md +5 -0
- package/.changeset/ninety-bags-bake.md +17 -0
- package/.changeset/perfect-vans-give.md +7 -0
- package/.changeset/pre.json +16 -0
- package/.changeset/shaggy-pugs-add.md +52 -0
- package/.changeset/short-months-complain.md +5 -0
- package/.changeset/swift-rivers-share.md +13 -0
- package/.changeset/thin-peas-hear.md +16 -0
- package/.changeset/wicked-forks-double.md +33 -0
- package/CHANGELOG.md +195 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +1 -1
- package/__cjs/cache/core/types/Cache.cjs.map +1 -1
- package/__cjs/cache/core/types/Cache.d.cts +1 -1
- package/__cjs/cache/core/types/DataProxy.d.cts +1 -1
- package/__cjs/cache/core/types/common.cjs +1 -0
- package/__cjs/cache/core/types/common.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +7 -4
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +1 -0
- package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +1 -1
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/reactiveVars.cjs.map +1 -1
- package/__cjs/cache/inmemory/reactiveVars.d.cts +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +1 -1
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs +2 -3
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs +2 -3
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs +2 -3
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areServerErrorsEqual.cjs +21 -0
- package/__cjs/config/jest/areServerErrorsEqual.cjs.map +1 -0
- package/__cjs/config/jest/areServerErrorsEqual.d.cts +3 -0
- package/__cjs/config/jest/resolver.cjs +11 -0
- package/__cjs/config/jest/resolver.cjs.map +1 -1
- package/__cjs/config/jest/setup.cjs +12 -1
- package/__cjs/config/jest/setup.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +7 -7
- package/__cjs/core/LocalState.cjs +2 -2
- package/__cjs/core/ObservableQuery.cjs +196 -66
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +20 -2
- package/__cjs/core/QueryInfo.cjs +4 -71
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +0 -8
- package/__cjs/core/QueryManager.cjs +29 -50
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +3 -3
- package/__cjs/core/index.cjs +3 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +1 -0
- package/__cjs/core/watchQueryOptions.d.cts +2 -2
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +1 -1
- package/__cjs/errors/index.cjs +21 -2
- package/__cjs/errors/index.cjs.map +1 -1
- package/__cjs/errors/index.d.cts +2 -0
- package/__cjs/invariantErrorCodes.cjs +82 -70
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +1 -1
- package/__cjs/link/core/ApolloLink.cjs +2 -20
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +1 -3
- package/__cjs/link/core/types.d.cts +1 -1
- package/__cjs/link/error/index.cjs +13 -28
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +4 -15
- 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/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/masking/maskFragment.d.cts +1 -1
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/maskOperation.cjs.map +1 -1
- package/__cjs/masking/maskOperation.d.cts +1 -1
- package/__cjs/masking/utils.cjs +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs.map +1 -1
- package/__cjs/react/context/ApolloConsumer.d.cts +1 -1
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs.map +1 -1
- package/__cjs/react/context/ApolloContext.d.cts +1 -1
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs.map +1 -1
- package/__cjs/react/context/ApolloProvider.d.cts +1 -1
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +2 -2
- package/__cjs/react/hooks/useApolloClient.cjs +1 -1
- package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.d.cts +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +2 -2
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +21 -24
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +3 -3
- package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +2 -2
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +2 -2
- package/__cjs/react/hooks/useQuery.cjs +4 -4
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +3 -4
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +2 -2
- package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
- package/__cjs/react/hooks/useReactiveVar.d.cts +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs +4 -4
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +3 -3
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +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/cache/QueryReference.d.cts +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.d.cts +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.d.cts +2 -2
- package/__cjs/react/internal/types.d.cts +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -0
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
- package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
- package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -1
- package/__cjs/react/ssr/prerenderStatic.d.cts +1 -1
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
- package/__cjs/react/types/deprecated.d.cts +1 -1
- package/__cjs/react/types/types.documentation.d.cts +2 -2
- package/__cjs/testing/core/index.cjs +2 -1
- package/__cjs/testing/core/index.cjs.map +1 -1
- package/__cjs/testing/core/index.d.cts +2 -2
- package/__cjs/testing/core/mocking/mockClient.cjs +3 -4
- package/__cjs/testing/core/mocking/mockClient.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockClient.d.cts +1 -1
- package/__cjs/testing/core/mocking/mockLink.cjs +118 -112
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +26 -7
- package/__cjs/testing/experimental/createSchemaFetch.cjs +2 -2
- package/__cjs/testing/experimental/createSchemaFetch.cjs.map +1 -1
- package/__cjs/testing/experimental/createTestSchema.cjs.map +1 -1
- package/__cjs/testing/experimental/createTestSchema.d.cts +1 -1
- package/__cjs/testing/index.cjs +2 -1
- package/__cjs/testing/index.cjs.map +1 -1
- package/__cjs/testing/index.d.cts +1 -1
- package/__cjs/testing/internal/incremental.cjs.map +1 -1
- package/__cjs/testing/internal/incremental.d.cts +1 -1
- package/__cjs/testing/internal/renderHelpers.cjs.map +1 -1
- package/__cjs/testing/internal/renderHelpers.d.cts +1 -1
- package/__cjs/testing/internal/scenarios/index.cjs +9 -7
- package/__cjs/testing/internal/scenarios/index.cjs.map +1 -1
- package/__cjs/testing/internal/scenarios/index.d.cts +6 -8
- package/__cjs/testing/matchers/arrayWithLength.cjs +15 -0
- package/__cjs/testing/matchers/arrayWithLength.cjs.map +1 -0
- package/__cjs/testing/matchers/arrayWithLength.d.cts +3 -0
- package/__cjs/testing/matchers/index.cjs +2 -0
- package/__cjs/testing/matchers/index.cjs.map +1 -1
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs +2 -2
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs.map +1 -1
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.d.cts +1 -1
- package/__cjs/testing/matchers/toMatchDocument.cjs.map +1 -1
- package/__cjs/testing/matchers/toMatchDocument.d.cts +1 -1
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +2 -2
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.cjs +9 -5
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +5 -3
- package/__cjs/utilities/common/mergeOptions.cjs.map +1 -1
- package/__cjs/utilities/common/mergeOptions.d.cts +1 -1
- package/__cjs/utilities/graphql/operations.cjs.map +1 -1
- package/__cjs/utilities/graphql/operations.d.cts +1 -1
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -1
- package/__cjs/utilities/internal/toQueryResult.d.cts +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs +2 -2
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/utilities/subscriptions/relay/index.d.cts +1 -1
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/__cjs/version.d.cts +1 -1
- package/cache/core/cache.d.ts +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +1 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +1 -1
- package/cache/core/types/common.js +1 -0
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -0
- package/cache/inmemory/entityStore.js +7 -4
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +1 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +1 -1
- 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/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.js +4 -4
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/areCombinedGraphQLErrorsEqual.js +2 -3
- package/config/jest/areCombinedGraphQLErrorsEqual.js.map +1 -1
- package/config/jest/areCombinedProtocolErrorsEqual.js +2 -3
- package/config/jest/areCombinedProtocolErrorsEqual.js.map +1 -1
- package/config/jest/areMissingFieldErrorsEqual.js +2 -3
- package/config/jest/areMissingFieldErrorsEqual.js.map +1 -1
- package/config/jest/areServerErrorsEqual.d.ts +3 -0
- package/config/jest/areServerErrorsEqual.js +17 -0
- package/config/jest/areServerErrorsEqual.js.map +1 -0
- package/config/jest/resolver.js +12 -1
- package/config/jest/resolver.js.map +1 -1
- package/config/jest/setup.js +13 -2
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.js +7 -7
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.d.ts +20 -2
- package/core/ObservableQuery.js +195 -64
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +0 -8
- package/core/QueryInfo.js +4 -71
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +3 -3
- package/core/QueryManager.js +30 -51
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +1 -0
- package/core/index.js +2 -1
- package/core/index.js.map +1 -1
- package/core/watchQueryOptions.d.ts +2 -2
- package/errors/CombinedGraphQLErrors.d.ts +1 -1
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/index.d.ts +2 -0
- package/errors/index.js +18 -0
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +82 -70
- package/link/context/index.d.ts +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +1 -3
- package/link/core/ApolloLink.js +2 -20
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/types.d.ts +1 -1
- package/link/error/index.d.ts +4 -15
- package/link/error/index.js +14 -29
- package/link/error/index.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 +3 -3
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskFragment.d.ts +1 -1
- package/masking/maskFragment.js +2 -2
- package/masking/maskFragment.js.map +1 -1
- package/masking/maskOperation.d.ts +1 -1
- package/masking/maskOperation.js +1 -1
- package/masking/maskOperation.js.map +1 -1
- package/masking/utils.js +1 -1
- package/package.json +10 -10
- package/react/context/ApolloConsumer.d.ts +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/hooks/internal/wrapHook.d.ts +2 -2
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useApolloClient.d.ts +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +2 -2
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +3 -3
- package/react/hooks/useLazyQuery.js +20 -23
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +2 -2
- package/react/hooks/useLoadableQuery.js +2 -2
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +2 -2
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +3 -4
- package/react/hooks/useQuery.js +2 -2
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +2 -2
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +1 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +1 -1
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +1 -1
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +3 -3
- package/react/hooks/useSuspenseQuery.js +3 -3
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/internal/cache/FragmentReference.d.ts +1 -1
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +1 -1
- package/react/internal/cache/QueryReference.js +1 -1
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +1 -1
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/cache/getSuspenseCache.d.ts +2 -2
- package/react/internal/cache/getSuspenseCache.js.map +1 -1
- package/react/internal/types.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.js +1 -0
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/prerenderStatic.d.ts +1 -1
- package/react/ssr/prerenderStatic.js +2 -2
- package/react/ssr/prerenderStatic.js.map +1 -1
- package/react/ssr/useSSRQuery.js.map +1 -1
- package/react/types/deprecated.d.ts +1 -1
- package/react/types/types.documentation.d.ts +2 -2
- package/testing/core/index.d.ts +2 -2
- package/testing/core/index.js +1 -1
- package/testing/core/index.js.map +1 -1
- package/testing/core/mocking/mockClient.d.ts +1 -1
- package/testing/core/mocking/mockClient.js +2 -3
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +26 -7
- package/testing/core/mocking/mockLink.js +117 -113
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/experimental/createSchemaFetch.js +1 -1
- package/testing/experimental/createSchemaFetch.js.map +1 -1
- package/testing/experimental/createTestSchema.d.ts +1 -1
- package/testing/experimental/createTestSchema.js.map +1 -1
- package/testing/index.d.ts +1 -1
- package/testing/index.js +1 -1
- package/testing/index.js.map +1 -1
- package/testing/internal/incremental.d.ts +1 -1
- package/testing/internal/incremental.js.map +1 -1
- package/testing/internal/renderHelpers.d.ts +1 -1
- package/testing/internal/renderHelpers.js.map +1 -1
- package/testing/internal/scenarios/index.d.ts +6 -8
- package/testing/internal/scenarios/index.js +4 -2
- package/testing/internal/scenarios/index.js.map +1 -1
- package/testing/matchers/arrayWithLength.d.ts +3 -0
- package/testing/matchers/arrayWithLength.js +11 -0
- package/testing/matchers/arrayWithLength.js.map +1 -0
- package/testing/matchers/index.js +2 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.d.ts +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/matchers/utils/getSerializableProperties.js +1 -1
- package/testing/matchers/utils/getSerializableProperties.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +5 -3
- package/testing/react/MockedProvider.js +7 -3
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/graphql/operations.d.ts +1 -1
- package/utilities/graphql/operations.js.map +1 -1
- package/utilities/index.d.ts +1 -1
- package/utilities/index.js.map +1 -1
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/toQueryResult.d.ts +1 -1
- package/utilities/internal/toQueryResult.js.map +1 -1
- package/utilities/subscriptions/relay/index.d.ts +1 -1
- package/utilities/subscriptions/relay/index.js +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/__cjs/index.cjs +0 -9
- package/__cjs/index.cjs.map +0 -1
- package/__cjs/index.d.cts +0 -3
- package/index.d.ts +0 -3
- package/index.js +0 -4
- package/index.js.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
`onError` link now uses a single `error` property to report the error that caused the link callback to be called. This will be an instance of `CombinedGraphQLErrors` in the event GraphQL errors were emitted from the terminating link, `CombinedProtocolErrors` if the terminating link emitted protocol errors, or the unwrapped error type if any other non-GraphQL error was thrown or emitted.
|
|
6
|
+
|
|
7
|
+
```diff
|
|
8
|
+
- const errorLink = onError(({ graphQLErrors, networkError, protocolErrors }) => {
|
|
9
|
+
- graphQLErrors.forEach(error => console.log(error.message));
|
|
10
|
+
+ const errorLink = onError(({ error }) => {
|
|
11
|
+
+ if (error.name === 'CombinedGraphQLErrors') {
|
|
12
|
+
+ error.errors.forEach(rawError => console.log(rawError.message));
|
|
13
|
+
+ }
|
|
14
|
+
});
|
|
15
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Introduce a new `realisticDelay` helper function for use with the `delay` callback for mocked responses used with `MockLink`. `realisticDelay` will generate a random value between 20 and 50ms to provide an experience closer to unpredictable network latency. `realisticDelay` can be configured with a `min` and `max` to set different thresholds if the defaults are not sufficient.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { realisticDelay } from '@apollo/client/testing';
|
|
9
|
+
|
|
10
|
+
new MockLink([
|
|
11
|
+
{
|
|
12
|
+
request: { query },
|
|
13
|
+
result: { data: { greeting: 'Hello' }},
|
|
14
|
+
delay: realisticDelay()
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
request: { query },
|
|
18
|
+
result: { data: { greeting: 'Hello' }},
|
|
19
|
+
delay: realisticDelay({ min: 10, max: 100 })
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Mocked responses passed to `MockLink` now accept a callback for the `request.variables` option. This is used to determine if the mock should be matched for a set of request variables. With this change, the `variableMatcher` option has been removed in favor of passing a callback to `variables`. Update by moving the callback function from `variableMatcher` to `request.variables`.
|
|
6
|
+
|
|
7
|
+
```diff
|
|
8
|
+
new MockLink([
|
|
9
|
+
{
|
|
10
|
+
request: {
|
|
11
|
+
query,
|
|
12
|
+
+ variables: (requestVariables) => true
|
|
13
|
+
},
|
|
14
|
+
- variableMatcher: (requestVariables) => true
|
|
15
|
+
}
|
|
16
|
+
]);
|
|
17
|
+
```
|
package/.changeset/pre.json
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
"@apollo/client": "3.12.2"
|
|
6
6
|
},
|
|
7
7
|
"changesets": [
|
|
8
|
+
"afraid-moons-arrive",
|
|
9
|
+
"beige-mirrors-talk",
|
|
8
10
|
"brave-radios-wait",
|
|
9
11
|
"bright-ads-share",
|
|
10
12
|
"calm-frogs-remain",
|
|
@@ -17,15 +19,19 @@
|
|
|
17
19
|
"curvy-pianos-count",
|
|
18
20
|
"dirty-eagles-poke",
|
|
19
21
|
"dirty-trees-pump",
|
|
22
|
+
"early-eggs-develop",
|
|
20
23
|
"eighty-squids-fix",
|
|
21
24
|
"eleven-kangaroos-jump",
|
|
22
25
|
"empty-rabbits-move",
|
|
23
26
|
"fluffy-shoes-applaud",
|
|
24
27
|
"forty-hairs-occur",
|
|
25
28
|
"forty-shrimps-fry",
|
|
29
|
+
"forty-tomatoes-punch",
|
|
26
30
|
"four-ghosts-watch",
|
|
27
31
|
"fresh-moose-hope",
|
|
28
32
|
"funny-jeans-invent",
|
|
33
|
+
"fuzzy-tips-sit",
|
|
34
|
+
"giant-apes-thank",
|
|
29
35
|
"giant-bags-share",
|
|
30
36
|
"good-dolphins-peel",
|
|
31
37
|
"gorgeous-chefs-tap",
|
|
@@ -35,8 +41,10 @@
|
|
|
35
41
|
"hot-cycles-notice",
|
|
36
42
|
"itchy-drinks-refuse",
|
|
37
43
|
"itchy-roses-accept",
|
|
44
|
+
"khaki-keys-deliver",
|
|
38
45
|
"khaki-spies-work",
|
|
39
46
|
"kind-fishes-develop",
|
|
47
|
+
"large-plants-know",
|
|
40
48
|
"late-trainers-peel",
|
|
41
49
|
"light-apes-rescue",
|
|
42
50
|
"light-dolphins-taste",
|
|
@@ -46,6 +54,7 @@
|
|
|
46
54
|
"lucky-hats-push",
|
|
47
55
|
"many-buses-allow",
|
|
48
56
|
"many-papayas-hide",
|
|
57
|
+
"mean-lizards-think",
|
|
49
58
|
"metal-needles-search",
|
|
50
59
|
"mighty-penguins-wink",
|
|
51
60
|
"modern-feet-do",
|
|
@@ -55,7 +64,9 @@
|
|
|
55
64
|
"nice-donkeys-reflect",
|
|
56
65
|
"nice-dots-matter",
|
|
57
66
|
"nice-waves-work",
|
|
67
|
+
"ninety-bags-bake",
|
|
58
68
|
"odd-lemons-relax",
|
|
69
|
+
"perfect-vans-give",
|
|
59
70
|
"polite-bees-care",
|
|
60
71
|
"poor-eels-punch",
|
|
61
72
|
"popular-games-sleep",
|
|
@@ -68,8 +79,10 @@
|
|
|
68
79
|
"rich-kids-carry",
|
|
69
80
|
"rude-fans-study",
|
|
70
81
|
"seven-foxes-melt",
|
|
82
|
+
"shaggy-pugs-add",
|
|
71
83
|
"shiny-carrots-invent",
|
|
72
84
|
"short-jokes-jam",
|
|
85
|
+
"short-months-complain",
|
|
73
86
|
"silly-knives-exist",
|
|
74
87
|
"slimy-chicken-melt",
|
|
75
88
|
"slimy-maps-press",
|
|
@@ -83,12 +96,14 @@
|
|
|
83
96
|
"soft-mails-clean",
|
|
84
97
|
"sour-pillows-guess",
|
|
85
98
|
"strange-seahorses-impress",
|
|
99
|
+
"swift-rivers-share",
|
|
86
100
|
"tall-bikes-develop",
|
|
87
101
|
"tall-cups-suffer",
|
|
88
102
|
"tame-doors-shop",
|
|
89
103
|
"tame-points-work",
|
|
90
104
|
"tender-swans-flash",
|
|
91
105
|
"thick-books-grin",
|
|
106
|
+
"thin-peas-hear",
|
|
92
107
|
"tidy-squids-poke",
|
|
93
108
|
"tough-rockets-allow",
|
|
94
109
|
"tough-taxis-smoke",
|
|
@@ -98,6 +113,7 @@
|
|
|
98
113
|
"unlucky-kiwis-sell",
|
|
99
114
|
"unlucky-sheep-change",
|
|
100
115
|
"warm-ties-sit",
|
|
116
|
+
"wicked-forks-double",
|
|
101
117
|
"yellow-cats-judge",
|
|
102
118
|
"young-phones-fold",
|
|
103
119
|
"young-turtles-explode"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": minor
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Add ability to specify a default `delay` for all mocked responses passed to `MockLink`. This `delay` can be configured globally (all instances of `MockLink` will use the global defaults), or per-instance (all mocks in a single instance will use the defaults). A `delay` defined on a single mock will supercede all default delays. Per-instance defaults supercede global defaults.
|
|
6
|
+
|
|
7
|
+
**Global defaults**
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
MockLink.defaultOptions = {
|
|
11
|
+
// Use a default delay of 20ms for all mocks in all instances without a specified delay
|
|
12
|
+
delay: 20,
|
|
13
|
+
|
|
14
|
+
// altenatively use a callback which will be executed for each mock
|
|
15
|
+
delay: () => getRandomNumber(),
|
|
16
|
+
|
|
17
|
+
// or use the built-in `realisticDelay`. This is the default
|
|
18
|
+
delay: realisticDelay(),
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Per-instance defaults**
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
new MockLink(
|
|
26
|
+
[
|
|
27
|
+
// Use the default delay
|
|
28
|
+
{
|
|
29
|
+
request: { query },
|
|
30
|
+
result: { data: { greeting: 'Hello' }},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
request: { query },
|
|
34
|
+
result: { data: { greeting: 'Hello' }},
|
|
35
|
+
// Override the default for this mock
|
|
36
|
+
delay: 10
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
{
|
|
40
|
+
defaultOptions: {
|
|
41
|
+
// Use a default delay of 20ms for all mocks without a specified delay
|
|
42
|
+
delay: 20,
|
|
43
|
+
|
|
44
|
+
// altenatively use a callback which will be executed for each mock
|
|
45
|
+
delay: () => getRandomNumber(),
|
|
46
|
+
|
|
47
|
+
// or use the built-in `realisticDelay`. This is the default
|
|
48
|
+
delay: realisticDelay(),
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Default the `delay` for all mocked responses passed to `MockLink` using `realisticDelay`. This ensures your test handles loading states by default and is not reliant on a specific timing.
|
|
6
|
+
|
|
7
|
+
If you would like to restore the old behavior, use a global default delay of `0`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
MockLink.defaultOptions = {
|
|
11
|
+
delay: 0
|
|
12
|
+
}
|
|
13
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
`notifyOnNetworkStatusChange` now defaults to `true`. This means that loading states will be emitted (core API) or rendered (React) by default when calling `refetch`, `fetchMore`, etc. To maintain the old behavior, set `notifyOnNetworkStatusChange` to `false` in `defaultOptions`.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
new ApolloClient({
|
|
9
|
+
defaultOptions: {
|
|
10
|
+
watchQuery: {
|
|
11
|
+
// Use the v3 default
|
|
12
|
+
notifyOnNetworkStatusChange: false
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
"@apollo/client": major
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Remove `newData` option for mocked responses passed to `MockLink` or the `mocks` option on `MockedProvider`. This option was undocumented and was nearly identical to using the `result` option as a callback.
|
|
6
|
+
|
|
7
|
+
To replicate the old behavior of `newData`, use `result` as a callback and add the `maxUsageCount` option with a value set to `Number.POSITIVE_INFINITY`.
|
|
8
|
+
|
|
9
|
+
**with `MockLink`**
|
|
10
|
+
```diff
|
|
11
|
+
new MockLink([
|
|
12
|
+
{
|
|
13
|
+
request: { query, variables },
|
|
14
|
+
- newData: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
15
|
+
+ result: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
16
|
+
+ maxUsageCount: Number.POSITIVE_INFINITY,
|
|
17
|
+
}
|
|
18
|
+
])
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**with `MockedProvider`**
|
|
22
|
+
```diff
|
|
23
|
+
<MockedProvider
|
|
24
|
+
mocks={[
|
|
25
|
+
{
|
|
26
|
+
request: { query, variables },
|
|
27
|
+
- newData: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
28
|
+
+ result: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
29
|
+
+ maxUsageCount: Number.POSITIVE_INFINITY,
|
|
30
|
+
}
|
|
31
|
+
]}
|
|
32
|
+
/>
|
|
33
|
+
```
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,186 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 4.0.0-alpha.9
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#12536](https://github.com/apollographql/apollo-client/pull/12536) [`e14205a`](https://github.com/apollographql/apollo-client/commit/e14205ad5909f95aa04684acd0ca2f25956ee50c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - An initial loading state is now emitted from `ObservableQuery` when subscribing if `notifyOnNetworkStatusChange` is set to `true`.
|
|
8
|
+
|
|
9
|
+
- [#12512](https://github.com/apollographql/apollo-client/pull/12512) [`e809b71`](https://github.com/apollographql/apollo-client/commit/e809b71aa9a02917a286afdbb03d5be8e5947c53) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `notifyOnNetworkStatusChange` now defaults to `true`. This means that loading states will be emitted (core API) or rendered (React) by default when calling `refetch`, `fetchMore`, etc. To maintain the old behavior, set `notifyOnNetworkStatusChange` to `false` in `defaultOptions`.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
new ApolloClient({
|
|
13
|
+
defaultOptions: {
|
|
14
|
+
watchQuery: {
|
|
15
|
+
// Use the v3 default
|
|
16
|
+
notifyOnNetworkStatusChange: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- [#12536](https://github.com/apollographql/apollo-client/pull/12536) [`e14205a`](https://github.com/apollographql/apollo-client/commit/e14205ad5909f95aa04684acd0ca2f25956ee50c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The returned `networkStatus` in `useLazyQuery` is now set to `setVariables` when calling the `useLazyQuery` `execute` function for the first time with variables.
|
|
25
|
+
|
|
26
|
+
- [#12536](https://github.com/apollographql/apollo-client/pull/12536) [`e14205a`](https://github.com/apollographql/apollo-client/commit/e14205ad5909f95aa04684acd0ca2f25956ee50c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `ObservableQuery` stops polling if switching to a `standby` `fetchPolicy`. When switching back to a non-`standby` `fetchPolicy`, polling will resume.
|
|
27
|
+
|
|
28
|
+
- [#12536](https://github.com/apollographql/apollo-client/pull/12536) [`e14205a`](https://github.com/apollographql/apollo-client/commit/e14205ad5909f95aa04684acd0ca2f25956ee50c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure a loading state is emitted when calling the `execute` function after changing clients in `useLazyQuery`.
|
|
29
|
+
|
|
30
|
+
- [#12542](https://github.com/apollographql/apollo-client/pull/12542) [`afb4fce`](https://github.com/apollographql/apollo-client/commit/afb4fce08859b2c6eebf288230a7c35b7acf2da6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `useLazyQuery` does not return a `partial` property which is not specified by the result type.
|
|
31
|
+
|
|
32
|
+
## 4.0.0-alpha.8
|
|
33
|
+
|
|
34
|
+
### Major Changes
|
|
35
|
+
|
|
36
|
+
- [#12539](https://github.com/apollographql/apollo-client/pull/12539) [`dd0d6d6`](https://github.com/apollographql/apollo-client/commit/dd0d6d6d96d8b810e30dc2fdee2ac8a2477d0017) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `onError` link now uses a single `error` property to report the error that caused the link callback to be called. This will be an instance of `CombinedGraphQLErrors` in the event GraphQL errors were emitted from the terminating link, `CombinedProtocolErrors` if the terminating link emitted protocol errors, or the unwrapped error type if any other non-GraphQL error was thrown or emitted.
|
|
37
|
+
|
|
38
|
+
```diff
|
|
39
|
+
- const errorLink = onError(({ graphQLErrors, networkError, protocolErrors }) => {
|
|
40
|
+
- graphQLErrors.forEach(error => console.log(error.message));
|
|
41
|
+
+ const errorLink = onError(({ error }) => {
|
|
42
|
+
+ if (error.name === 'CombinedGraphQLErrors') {
|
|
43
|
+
+ error.errors.forEach(rawError => console.log(rawError.message));
|
|
44
|
+
+ }
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- [#12533](https://github.com/apollographql/apollo-client/pull/12533) [`73221d8`](https://github.com/apollographql/apollo-client/commit/73221d87bd5640986f86fe3ee50c63ed49834cbb) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `onError` and `setOnError` methods from `ApolloLink`. `onError` was only used by `MockLink` to rewrite errors if `setOnError` was used.
|
|
49
|
+
|
|
50
|
+
- [#12531](https://github.com/apollographql/apollo-client/pull/12531) [`7784b46`](https://github.com/apollographql/apollo-client/commit/7784b46117a4f91a270a020ed1a24f042cb9ee17) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Mocked responses passed to `MockLink` now accept a callback for the `request.variables` option. This is used to determine if the mock should be matched for a set of request variables. With this change, the `variableMatcher` option has been removed in favor of passing a callback to `variables`. Update by moving the callback function from `variableMatcher` to `request.variables`.
|
|
51
|
+
|
|
52
|
+
```diff
|
|
53
|
+
new MockLink([
|
|
54
|
+
{
|
|
55
|
+
request: {
|
|
56
|
+
query,
|
|
57
|
+
+ variables: (requestVariables) => true
|
|
58
|
+
},
|
|
59
|
+
- variableMatcher: (requestVariables) => true
|
|
60
|
+
}
|
|
61
|
+
]);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- [#12526](https://github.com/apollographql/apollo-client/pull/12526) [`391af1d`](https://github.com/apollographql/apollo-client/commit/391af1dd733219b7e1e14cfff9d5e3ce3967242f) Thanks [@phryneas](https://github.com/phryneas)! - The `@apollo/client` and `@apollo/client/core` entry points are now equal.
|
|
65
|
+
In the next major, the `@apollo/client/core` entry point will be removed.
|
|
66
|
+
Please change imports over from `@apollo/client/core` to `@apollo/client`.
|
|
67
|
+
|
|
68
|
+
- [#12525](https://github.com/apollographql/apollo-client/pull/12525) [`8785186`](https://github.com/apollographql/apollo-client/commit/87851863b94eebbc208671b17aeca73748ac41f6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Throw an error when a client-only query is used in a mocked response passed to `MockLink`.
|
|
69
|
+
|
|
70
|
+
- [#12532](https://github.com/apollographql/apollo-client/pull/12532) [`ae0dcad`](https://github.com/apollographql/apollo-client/commit/ae0dcad89924e6b8090ca3182df30e528589b562) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Default the `delay` for all mocked responses passed to `MockLink` using `realisticDelay`. This ensures your test handles loading states by default and is not reliant on a specific timing.
|
|
71
|
+
|
|
72
|
+
If you would like to restore the old behavior, use a global default delay of `0`.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
MockLink.defaultOptions = {
|
|
76
|
+
delay: 0,
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- [#12530](https://github.com/apollographql/apollo-client/pull/12530) [`2973e2a`](https://github.com/apollographql/apollo-client/commit/2973e2a6e6fd81fa59b769d84c252c98ca69440d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `newData` option for mocked responses passed to `MockLink` or the `mocks` option on `MockedProvider`. This option was undocumented and was nearly identical to using the `result` option as a callback.
|
|
81
|
+
|
|
82
|
+
To replicate the old behavior of `newData`, use `result` as a callback and add the `maxUsageCount` option with a value set to `Number.POSITIVE_INFINITY`.
|
|
83
|
+
|
|
84
|
+
**with `MockLink`**
|
|
85
|
+
|
|
86
|
+
```diff
|
|
87
|
+
new MockLink([
|
|
88
|
+
{
|
|
89
|
+
request: { query, variables },
|
|
90
|
+
- newData: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
91
|
+
+ result: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
92
|
+
+ maxUsageCount: Number.POSITIVE_INFINITY,
|
|
93
|
+
}
|
|
94
|
+
])
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**with `MockedProvider`**
|
|
98
|
+
|
|
99
|
+
```diff
|
|
100
|
+
<MockedProvider
|
|
101
|
+
mocks={[
|
|
102
|
+
{
|
|
103
|
+
request: { query, variables },
|
|
104
|
+
- newData: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
105
|
+
+ result: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
106
|
+
+ maxUsageCount: Number.POSITIVE_INFINITY,
|
|
107
|
+
}
|
|
108
|
+
]}
|
|
109
|
+
/>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Minor Changes
|
|
113
|
+
|
|
114
|
+
- [#12532](https://github.com/apollographql/apollo-client/pull/12532) [`ae0dcad`](https://github.com/apollographql/apollo-client/commit/ae0dcad89924e6b8090ca3182df30e528589b562) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Allow mocked responses passed to `MockLink` to accept a callback for the `delay` option. The `delay` callback will be given the current operation which can be used to determine what delay should be used for the mock.
|
|
115
|
+
|
|
116
|
+
- [#12532](https://github.com/apollographql/apollo-client/pull/12532) [`ae0dcad`](https://github.com/apollographql/apollo-client/commit/ae0dcad89924e6b8090ca3182df30e528589b562) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Introduce a new `realisticDelay` helper function for use with the `delay` callback for mocked responses used with `MockLink`. `realisticDelay` will generate a random value between 20 and 50ms to provide an experience closer to unpredictable network latency. `realisticDelay` can be configured with a `min` and `max` to set different thresholds if the defaults are not sufficient.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import { realisticDelay } from "@apollo/client/testing";
|
|
120
|
+
|
|
121
|
+
new MockLink([
|
|
122
|
+
{
|
|
123
|
+
request: { query },
|
|
124
|
+
result: { data: { greeting: "Hello" } },
|
|
125
|
+
delay: realisticDelay(),
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
request: { query },
|
|
129
|
+
result: { data: { greeting: "Hello" } },
|
|
130
|
+
delay: realisticDelay({ min: 10, max: 100 }),
|
|
131
|
+
},
|
|
132
|
+
]);
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
- [#12532](https://github.com/apollographql/apollo-client/pull/12532) [`ae0dcad`](https://github.com/apollographql/apollo-client/commit/ae0dcad89924e6b8090ca3182df30e528589b562) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add ability to specify a default `delay` for all mocked responses passed to `MockLink`. This `delay` can be configured globally (all instances of `MockLink` will use the global defaults), or per-instance (all mocks in a single instance will use the defaults). A `delay` defined on a single mock will supercede all default delays. Per-instance defaults supercede global defaults.
|
|
136
|
+
|
|
137
|
+
**Global defaults**
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
MockLink.defaultOptions = {
|
|
141
|
+
// Use a default delay of 20ms for all mocks in all instances without a specified delay
|
|
142
|
+
delay: 20,
|
|
143
|
+
|
|
144
|
+
// altenatively use a callback which will be executed for each mock
|
|
145
|
+
delay: () => getRandomNumber(),
|
|
146
|
+
|
|
147
|
+
// or use the built-in `realisticDelay`. This is the default
|
|
148
|
+
delay: realisticDelay(),
|
|
149
|
+
};
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**Per-instance defaults**
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
new MockLink(
|
|
156
|
+
[
|
|
157
|
+
// Use the default delay
|
|
158
|
+
{
|
|
159
|
+
request: { query },
|
|
160
|
+
result: { data: { greeting: "Hello" } },
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
request: { query },
|
|
164
|
+
result: { data: { greeting: "Hello" } },
|
|
165
|
+
// Override the default for this mock
|
|
166
|
+
delay: 10,
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
{
|
|
170
|
+
defaultOptions: {
|
|
171
|
+
// Use a default delay of 20ms for all mocks without a specified delay
|
|
172
|
+
delay: 20,
|
|
173
|
+
|
|
174
|
+
// altenatively use a callback which will be executed for each mock
|
|
175
|
+
delay: () => getRandomNumber(),
|
|
176
|
+
|
|
177
|
+
// or use the built-in `realisticDelay`. This is the default
|
|
178
|
+
delay: realisticDelay(),
|
|
179
|
+
},
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
```
|
|
183
|
+
|
|
3
184
|
## 4.0.0-alpha.7
|
|
4
185
|
|
|
5
186
|
### Major Changes
|
|
@@ -607,6 +788,20 @@
|
|
|
607
788
|
|
|
608
789
|
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't emit a partial cache result from `cache-only` queries when `returnPartialData` is `false`.
|
|
609
790
|
|
|
791
|
+
## 3.13.7
|
|
792
|
+
|
|
793
|
+
### Patch Changes
|
|
794
|
+
|
|
795
|
+
- [#12540](https://github.com/apollographql/apollo-client/pull/12540) [`0098932`](https://github.com/apollographql/apollo-client/commit/009893220934081f6e5733bff5863c768a597117) Thanks [@phryneas](https://github.com/phryneas)! - Refactor: Move notification scheduling logic from `QueryInfo` to `ObservableQuery`
|
|
796
|
+
|
|
797
|
+
- [#12540](https://github.com/apollographql/apollo-client/pull/12540) [`0098932`](https://github.com/apollographql/apollo-client/commit/009893220934081f6e5733bff5863c768a597117) Thanks [@phryneas](https://github.com/phryneas)! - Refactored cache emit logic for ObservableQuery. This should be an invisible change.
|
|
798
|
+
|
|
799
|
+
## 3.13.6
|
|
800
|
+
|
|
801
|
+
### Patch Changes
|
|
802
|
+
|
|
803
|
+
- [#12285](https://github.com/apollographql/apollo-client/pull/12285) [`cdc55ff`](https://github.com/apollographql/apollo-client/commit/cdc55ff54bf4c83ec8571508ec4bf8156af1bc97) Thanks [@phryneas](https://github.com/phryneas)! - keep ObservableQuery created by useQuery non-active before it is first subscribed
|
|
804
|
+
|
|
610
805
|
## 3.13.5
|
|
611
806
|
|
|
612
807
|
### Patch Changes
|
|
@@ -94,7 +94,7 @@ class ApolloCache {
|
|
|
94
94
|
if (environment_1.__DEV__) {
|
|
95
95
|
const actualFragmentName = fragmentName || (0, utilities_1.getFragmentDefinition)(fragment).name.value;
|
|
96
96
|
if (!id) {
|
|
97
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
97
|
+
__DEV__ && invariant_1.invariant.warn(94, actualFragmentName);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
const diffOptions = {
|