●Change8

v4.0.0-alpha.15

Breaking Changes
πŸ“¦ apollo-client
⚠ 2 breaking✨ 2 featuresπŸ› 2 fixes⚑ 1 deprecationsπŸ”§ 12 symbols

Summary

This release moves unstable testing utilities to an internal namespace, removes several deprecated testing helpers, adds subtle `useQuery` and `ObservableQuery` behavior improvements, and deprecates old MockLink type exports.

⚠️ Breaking Changes

  • Removed testing utilities `createMockClient`, `mockObservableLink`, and `mockSingleLink` from `@apollo/client/testing`. Update code to use `ApolloClient` with `MockLink` or `MockSubscriptionLink` as shown.
  • Removed the `@apollo/client/testing/core` entrypoint. Import from `@apollo/client/testing` instead.

Migration Steps

  1. Replace `createMockClient(...)` with a new `ApolloClient` instance configured with `MockLink` as demonstrated.
  2. Replace `mockObservableLink()` with `new MockSubscriptionLink()`.
  3. Replace `mockSingleLink({...})` with `new MockLink([...])`.
  4. Import types from the `MockLink` namespace (e.g., `MockLink.MockedResponse`) instead of the top‑level exports.
  5. Update imports to use `@apollo/client/testing` instead of `@apollo/client/testing/core`.

✨ New Features

  • `useQuery` now only updates `previousData` when the `data` value actually changes.
  • `ObservableQuery` now returns `{ loading: false }` for `fetchPolicy: 'standby'` even before a subscription is established.

πŸ› Bug Fixes

  • When `skip` changes from `false` to `true` in `useQuery`, the hook now retains existing `data` instead of setting it to `undefined`.
  • `error` property is omitted when `skip` is `true` in `useQuery`.

πŸ”§ Affected Symbols

createMockClientmockObservableLinkmockSingleLinkMockLink.MockedResponseMockLink.OptionsMockLink.ResultFunctionObservableQueryuseQueryMockSubscriptionLinkMockLinkApolloClientInMemoryCache

⚑ Deprecations

  • `MockedResponse`, `MockLinkOptions`, and `ResultFunction` types are deprecated; use `MockLink.MockedResponse`, `MockLink.Options`, and `MockLink.ResultFunction` instead.