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
- Replace `createMockClient(...)` with a new `ApolloClient` instance configured with `MockLink` as demonstrated.
- Replace `mockObservableLink()` with `new MockSubscriptionLink()`.
- Replace `mockSingleLink({...})` with `new MockLink([...])`.
- Import types from the `MockLink` namespace (e.g., `MockLink.MockedResponse`) instead of the topβlevel exports.
- 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.