@apollo/client 4.0.0-rc.8 → 4.0.0
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 +2488 -0
- package/README.md +6 -2
- package/__cjs/cache/inmemory/inMemoryCache.cjs +2 -2
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.cjs +18 -12
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs +1 -1
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.cjs +1 -1
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -1
- package/__cjs/core/QueryInfo.cjs +2 -6
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +1 -1
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +9 -6
- package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
- package/__cjs/incremental/handlers/notImplemented.d.cts +11 -0
- package/__cjs/link/batch/batchLink.cjs +30 -2
- package/__cjs/link/batch/batchLink.cjs.map +1 -1
- package/__cjs/link/batch/batchLink.d.cts +69 -2
- package/__cjs/link/batch-http/BaseBatchHttpLink.cjs +156 -0
- package/__cjs/link/batch-http/BaseBatchHttpLink.cjs.map +1 -0
- package/__cjs/link/batch-http/BaseBatchHttpLink.d.cts +68 -0
- package/__cjs/link/batch-http/batchHttpLink.cjs +3 -128
- package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -20
- package/__cjs/link/batch-http/index.cjs +2 -1
- package/__cjs/link/batch-http/index.cjs.map +1 -1
- package/__cjs/link/batch-http/index.d.cts +2 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +3 -3
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +20 -1
- package/__cjs/link/context/index.cjs +19 -0
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +64 -2
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +5 -2
- package/__cjs/link/core/types.d.cts +0 -4
- package/__cjs/link/http/BaseHttpLink.cjs +59 -8
- package/__cjs/link/http/BaseHttpLink.cjs.map +1 -1
- package/__cjs/link/http/BaseHttpLink.d.cts +256 -2
- package/__cjs/link/http/HttpLink.cjs +1 -1
- package/__cjs/link/http/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +5 -208
- package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
- package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +7 -7
- package/__cjs/link/index.cjs.map +1 -1
- package/__cjs/link/index.d.cts +2 -1
- package/__cjs/link/persisted-queries/index.cjs +16 -0
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +181 -0
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +48 -0
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +115 -0
- package/__cjs/link/retry/retryLink.cjs +25 -3
- package/__cjs/link/retry/retryLink.cjs.map +1 -1
- package/__cjs/link/retry/retryLink.d.cts +82 -9
- package/__cjs/link/schema/index.cjs +20 -0
- package/__cjs/link/schema/index.cjs.map +1 -1
- package/__cjs/link/schema/index.d.cts +128 -6
- package/__cjs/link/ws/index.cjs +18 -0
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +56 -5
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/masking/GraphQLCodegenDataMasking.d.cts +10 -42
- package/__cjs/masking/PreserveTypes.cjs +3 -0
- package/__cjs/masking/PreserveTypes.cjs.map +1 -0
- package/__cjs/masking/PreserveTypes.d.cts +26 -0
- package/__cjs/masking/index.cjs.map +1 -1
- package/__cjs/masking/index.d.cts +1 -1
- package/__cjs/masking/internal/types.d.cts +0 -1
- package/__cjs/masking/types.d.cts +6 -23
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +2 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +1 -1
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +2 -1
- package/__cjs/react/hooks/useQuery.d.cts +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +2 -1
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +1 -1
- package/__cjs/react/hooks/useSyncExternalStore.cjs +2 -6
- package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +1 -1
- package/__cjs/react/types/deprecated.d.cts +1 -1
- package/__cjs/react/types/types.documentation.d.cts +1 -1
- package/__cjs/testing/core/mocking/mockSubscriptionLink.d.cts +1 -1
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +5 -0
- package/__cjs/utilities/common/stripTypename.cjs +11 -0
- package/__cjs/utilities/common/stripTypename.cjs.map +1 -1
- package/__cjs/utilities/common/stripTypename.d.cts +11 -0
- package/__cjs/utilities/graphql/DocumentTransform.cjs +84 -1
- package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
- package/__cjs/utilities/graphql/DocumentTransform.d.cts +94 -5
- package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs +27 -0
- package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs.map +1 -1
- package/__cjs/utilities/graphql/isFormattedExecutionResult.d.cts +27 -0
- package/__cjs/utilities/graphql/operations.cjs +54 -3
- package/__cjs/utilities/graphql/operations.cjs.map +1 -1
- package/__cjs/utilities/graphql/operations.d.cts +54 -3
- package/__cjs/utilities/graphql/storeUtils.cjs +9 -0
- package/__cjs/utilities/graphql/storeUtils.cjs.map +1 -1
- package/__cjs/utilities/graphql/storeUtils.d.cts +9 -0
- package/__cjs/utilities/graphql/transform.cjs +12 -1
- package/__cjs/utilities/graphql/transform.cjs.map +1 -1
- package/__cjs/utilities/graphql/transform.d.cts +12 -1
- package/__cjs/utilities/internal/canonicalStringify.cjs +30 -7
- package/__cjs/utilities/internal/canonicalStringify.cjs.map +1 -1
- package/__cjs/utilities/internal/canonicalStringify.d.cts +30 -7
- package/__cjs/utilities/internal/getMainDefinition.cjs +36 -8
- package/__cjs/utilities/internal/getMainDefinition.cjs.map +1 -1
- package/__cjs/utilities/internal/getMainDefinition.d.cts +36 -8
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +2 -6
- package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/v4-migration.cjs +9 -0
- package/__cjs/v4-migration.cjs.map +1 -0
- package/__cjs/v4-migration.d.cts +826 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/inmemory/inMemoryCache.js +2 -2
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.js +18 -12
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/writeToStore.js +1 -1
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -1
- package/core/ObservableQuery.js +1 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.js +1 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +9 -6
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/notImplemented.d.ts +11 -0
- package/incremental/handlers/notImplemented.js.map +1 -1
- package/legacyEntryPoints/v4-migration/index.d.ts +1 -0
- package/legacyEntryPoints/v4-migration/index.js +1 -0
- package/legacyEntryPoints/v4-migration/v4-migration.cjs +1 -0
- package/legacyEntryPoints/v4-migration/v4-migration.d.cts +1 -0
- package/link/batch/batchLink.d.ts +69 -2
- package/link/batch/batchLink.js +30 -2
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch-http/BaseBatchHttpLink.d.ts +68 -0
- package/link/batch-http/BaseBatchHttpLink.js +152 -0
- package/link/batch-http/BaseBatchHttpLink.js.map +1 -0
- package/link/batch-http/batchHttpLink.d.ts +5 -21
- package/link/batch-http/batchHttpLink.js +1 -125
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/batch-http/index.d.ts +2 -1
- package/link/batch-http/index.js +2 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/client-awareness/ClientAwarenessLink.d.ts +21 -2
- package/link/client-awareness/ClientAwarenessLink.js +3 -3
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
- package/link/context/index.d.ts +65 -3
- package/link/context/index.js +19 -0
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +5 -2
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/types.d.ts +0 -4
- package/link/core/types.js.map +1 -1
- package/link/http/BaseHttpLink.d.ts +257 -3
- package/link/http/BaseHttpLink.js +59 -8
- package/link/http/BaseHttpLink.js.map +1 -1
- package/link/http/HttpLink.d.ts +6 -209
- package/link/http/HttpLink.js +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +2 -2
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +7 -7
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/index.d.ts +2 -1
- package/link/index.js.map +1 -1
- package/link/persisted-queries/index.d.ts +182 -1
- package/link/persisted-queries/index.js +16 -0
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts +115 -0
- package/link/remove-typename/removeTypenameFromVariables.js +48 -0
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/retryLink.d.ts +83 -10
- package/link/retry/retryLink.js +25 -3
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +129 -7
- package/link/schema/index.js +20 -0
- package/link/schema/index.js.map +1 -1
- package/link/ws/index.d.ts +56 -5
- package/link/ws/index.js +18 -0
- package/link/ws/index.js.map +1 -1
- package/local-state/LocalState.js.map +1 -1
- package/masking/GraphQLCodegenDataMasking.d.ts +10 -42
- package/masking/GraphQLCodegenDataMasking.js.map +1 -1
- package/masking/PreserveTypes.d.ts +26 -0
- package/masking/PreserveTypes.js +2 -0
- package/masking/PreserveTypes.js.map +1 -0
- package/masking/index.d.ts +1 -1
- package/masking/index.js.map +1 -1
- package/masking/internal/types.d.ts +0 -1
- package/masking/internal/types.js.map +1 -1
- package/masking/types.d.ts +6 -23
- package/masking/types.js.map +1 -1
- package/package.json +8 -2
- package/react/hooks/useBackgroundQuery.d.ts +2 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +1 -1
- package/react/hooks/useLoadableQuery.d.ts +2 -1
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +2 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +2 -1
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +2 -1
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.d.ts +2 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useReadQuery.d.ts +1 -1
- package/react/hooks-compiled/useReadQuery.js.map +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js +1 -1
- package/react/hooks-compiled/useSyncExternalStore.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +1 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/types/deprecated.d.ts +1 -1
- package/react/types/deprecated.js.map +1 -1
- package/react/types/types.documentation.d.ts +1 -1
- package/react/types/types.documentation.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/react/MockedProvider.d.ts +5 -0
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/common/stripTypename.d.ts +11 -0
- package/utilities/common/stripTypename.js +11 -0
- package/utilities/common/stripTypename.js.map +1 -1
- package/utilities/graphql/DocumentTransform.d.ts +94 -5
- package/utilities/graphql/DocumentTransform.js +84 -1
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/isFormattedExecutionResult.d.ts +27 -0
- package/utilities/graphql/isFormattedExecutionResult.js +27 -0
- package/utilities/graphql/isFormattedExecutionResult.js.map +1 -1
- package/utilities/graphql/operations.d.ts +54 -3
- package/utilities/graphql/operations.js +54 -3
- package/utilities/graphql/operations.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +9 -0
- package/utilities/graphql/storeUtils.js +9 -0
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +12 -1
- package/utilities/graphql/transform.js +12 -1
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/internal/canonicalStringify.d.ts +30 -7
- package/utilities/internal/canonicalStringify.js +30 -7
- package/utilities/internal/canonicalStringify.js.map +1 -1
- package/utilities/internal/getMainDefinition.d.ts +37 -9
- package/utilities/internal/getMainDefinition.js +36 -8
- package/utilities/internal/getMainDefinition.js.map +1 -1
- package/utilities/internal/removeDirectivesFromDocument.js +1 -2
- package/utilities/internal/removeDirectivesFromDocument.js.map +1 -1
- package/utilities/internal/types/DocumentationTypes.d.ts +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/v4-migration.d.ts +826 -0
- package/v4-migration.js +8 -0
- package/v4-migration.js.map +1 -0
- package/version.js +1 -1
- package/version.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,2423 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
# Apollo Client 4.0 Release Notes
|
|
6
|
+
|
|
7
|
+
Apollo Client 4.0 delivers a more modern, efficient, and type-safe GraphQL client experience through various architectural improvements and API refinements. This release focuses on developer experience, bundle size optimization, and framework flexibility.
|
|
8
|
+
|
|
9
|
+
## Key Improvements
|
|
10
|
+
|
|
11
|
+
### 🎯 Framework-Agnostic Core
|
|
12
|
+
|
|
13
|
+
Apollo Client 4.0 separates React functionality from the core library, making `@apollo/client` truly framework-agnostic. React exports now live in `@apollo/client/react`, allowing developers to use Apollo Client with any JavaScript framework without React dependencies.
|
|
14
|
+
|
|
15
|
+
### 📦 Smaller Bundle Sizes
|
|
16
|
+
|
|
17
|
+
- **Opt-in Local State Management**: The `@client` directive functionality is now opt-in via the `LocalState` class, reducing bundle size when not using local state
|
|
18
|
+
- **Modern Build Target**: Transpiled to target `since 2023, node >= 20, not dead`, leveraging modern JavaScript features for better performance
|
|
19
|
+
- **Improved Tree-Shaking**: Proper `exports` field in package.json enables better dead code elimination
|
|
20
|
+
|
|
21
|
+
### 💥 Unified Error Handling
|
|
22
|
+
|
|
23
|
+
Apollo Client 4.0 completely reimagines error handling for better clarity and debugging:
|
|
24
|
+
|
|
25
|
+
- `ApolloError` removed in favor of specific error classes
|
|
26
|
+
- Unification of errors to a single `error` property
|
|
27
|
+
- Network errors now respect `errorPolicy` settings
|
|
28
|
+
- External errors passed through without wrapping
|
|
29
|
+
- New, more granular error classes with static `.is()` methods for robust type narrowing
|
|
30
|
+
|
|
31
|
+
### 🔧 Enhanced TypeScript Support
|
|
32
|
+
|
|
33
|
+
- **Namespaced Types**: Types are now colocated with their APIs (e.g., `useQuery.Options` instead of `QueryHookOptions`)
|
|
34
|
+
- **Precise Return Types**: Return types accurately reflect the options passed (e.g., `returnPartialData` makes `data` type `DeepPartial<TData>`)
|
|
35
|
+
- **Stricter Type Safety**: Required variables are now enforced more consistently throughout the client
|
|
36
|
+
- **New `dataState` Property**: Enables accurate type narrowing of query results
|
|
37
|
+
- **Module Augmentation**: Custom context types via declaration merging instead of fragile generics
|
|
38
|
+
- **Customizable Type Implementations**: Select types can now be customized to provide your own type implementation to seamlessly integrate with external tools such as GraphQL Codegen or `gql.tada`
|
|
39
|
+
|
|
40
|
+
### ⚡ Modern Observable Implementation
|
|
41
|
+
|
|
42
|
+
Apollo Client 4.0 migrates from `zen-observable` to **RxJS**, providing the industry-standard Observable implementation backed by a rich ecosystem of utilities.
|
|
43
|
+
|
|
44
|
+
## Major Features
|
|
45
|
+
|
|
46
|
+
### Unified Error Handling
|
|
47
|
+
|
|
48
|
+
Apollo Client 4.0 completely reimagines error handling for better clarity and debugging:
|
|
49
|
+
|
|
50
|
+
**Key Changes:**
|
|
51
|
+
|
|
52
|
+
- `ApolloError` removed in favor of specific error classes
|
|
53
|
+
- Network errors now respect `errorPolicy` settings
|
|
54
|
+
- External errors passed through without wrapping
|
|
55
|
+
- New error classes with static `.is()` methods for type checking
|
|
56
|
+
|
|
57
|
+
**Error Classes:**
|
|
58
|
+
|
|
59
|
+
- `CombinedGraphQLErrors` - GraphQL errors from the server
|
|
60
|
+
- `ServerError` - Non-GraphQL server errors
|
|
61
|
+
- `ServerParseError` - Server response parsing errors
|
|
62
|
+
- `UnconventionalError` - Wrapper for non-error thrown values
|
|
63
|
+
- `LinkError` - Errors from the link chain (via `.is()` check)
|
|
64
|
+
|
|
65
|
+
**Migration Example:**
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Apollo Client 3
|
|
69
|
+
if (error instanceof ApolloError) {
|
|
70
|
+
console.log(error.graphQLErrors);
|
|
71
|
+
console.log(error.networkError);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Apollo Client 4
|
|
75
|
+
import { CombinedGraphQLErrors } from "@apollo/client";
|
|
76
|
+
|
|
77
|
+
if (CombinedGraphQLErrors.is(error)) {
|
|
78
|
+
console.log(error.errors); // GraphQL errors
|
|
79
|
+
} else if (error) {
|
|
80
|
+
console.log(error.message); // Other errors
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### The `dataState` Property
|
|
85
|
+
|
|
86
|
+
A new property that clearly indicates the completeness of query results:
|
|
87
|
+
|
|
88
|
+
**Values:**
|
|
89
|
+
|
|
90
|
+
- `empty` - No data available (`data` is `undefined`)
|
|
91
|
+
- `partial` - Incomplete data from cache when `returnPartialData` is `true`
|
|
92
|
+
- `streaming` - Incomplete data from a deferred query still streaming
|
|
93
|
+
- `complete` - Fully satisfied query result
|
|
94
|
+
|
|
95
|
+
**Benefits:**
|
|
96
|
+
|
|
97
|
+
- Accurate TypeScript type narrowing
|
|
98
|
+
- Clear loading state distinction
|
|
99
|
+
- Better handling of partial results
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const { data, dataState } = useQuery(MY_QUERY);
|
|
103
|
+
|
|
104
|
+
if (dataState === "complete") {
|
|
105
|
+
// TypeScript knows data is fully populated
|
|
106
|
+
console.log(data.allFields);
|
|
107
|
+
} else if (dataState === "partial") {
|
|
108
|
+
// TypeScript knows data might be missing fields
|
|
109
|
+
console.log(data?.someField);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Pluggable Incremental Delivery (`@defer` Support)
|
|
114
|
+
|
|
115
|
+
Apollo Client 4.0 makes incremental delivery configurable and future-proof:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { Defer20220824Handler } from "@apollo/client/incremental";
|
|
119
|
+
|
|
120
|
+
const client = new ApolloClient({
|
|
121
|
+
// ...
|
|
122
|
+
incrementalHandler: new Defer20220824Handler(),
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Available Handlers:**
|
|
127
|
+
|
|
128
|
+
- `NotImplementedHandler` - Default, throws if `@defer` is used
|
|
129
|
+
- `Defer20220824Handler` - Apollo Router format support (also aliased as `GraphQL17Alpha2Handler`)
|
|
130
|
+
|
|
131
|
+
### Local State Management Improvements
|
|
132
|
+
|
|
133
|
+
Local state is now opt-in via the `LocalState` class:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { LocalState } from "@apollo/client/local-state";
|
|
137
|
+
|
|
138
|
+
const client = new ApolloClient({
|
|
139
|
+
cache,
|
|
140
|
+
localState: new LocalState({
|
|
141
|
+
resolvers: {
|
|
142
|
+
Query: {
|
|
143
|
+
myField: () => "Hello World",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Resolver Context Changes:**
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
// Apollo Client 3
|
|
154
|
+
const resolver = (parent, args, context, info) => {
|
|
155
|
+
const { cache } = context;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Apollo Client 4
|
|
159
|
+
const resolver = (parent, args, context, info) => {
|
|
160
|
+
const { client, requestContext, phase } = context;
|
|
161
|
+
const cache = client.cache;
|
|
162
|
+
};
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## React-Specific Improvements
|
|
166
|
+
|
|
167
|
+
### More Predictable Hooks
|
|
168
|
+
|
|
169
|
+
**`useLazyQuery` Overhaul:**
|
|
170
|
+
|
|
171
|
+
- No longer accepts `variables` or `context` options (pass to `execute` instead)
|
|
172
|
+
- `execute` function only accepts `variables` and `context`
|
|
173
|
+
- Cannot be called during render or SSR
|
|
174
|
+
- Automatic cancellation of in-flight queries when new ones start
|
|
175
|
+
|
|
176
|
+
**`useMutation` Changes:**
|
|
177
|
+
|
|
178
|
+
- Removed `ignoreResults` option - use `client.mutate` directly for fire-and-forget mutations
|
|
179
|
+
|
|
180
|
+
**`useQuery` Changes:**
|
|
181
|
+
|
|
182
|
+
- `notifyOnNetworkStatusChange` now defaults to `true`
|
|
183
|
+
- Removed deprecated `onCompleted` and `onError` callbacks
|
|
184
|
+
|
|
185
|
+
### New SSR API
|
|
186
|
+
|
|
187
|
+
The new `prerenderStatic` API replaces deprecated SSR functions:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { prerenderStatic } from "@apollo/client/react/ssr";
|
|
191
|
+
|
|
192
|
+
// Works with React 19's prerender APIs
|
|
193
|
+
const html = await prerenderStatic(<App />, {
|
|
194
|
+
client,
|
|
195
|
+
});
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### React Compiler Support
|
|
199
|
+
|
|
200
|
+
Pre-compiled React hooks optimized by the React Compiler:
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
// Use compiled hooks for potential performance improvements
|
|
204
|
+
import { useQuery } from "@apollo/client/react/compiled";
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The compiled hooks are built with React Compiler v19.1.0-rc.2 and include a runtime polyfill for compatibility with React 17+.
|
|
208
|
+
|
|
209
|
+
## Link System Evolution
|
|
210
|
+
|
|
211
|
+
### All Links Now Classes
|
|
212
|
+
|
|
213
|
+
Migration from creator functions to classes:
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
// Apollo Client 3
|
|
217
|
+
import { createHttpLink, setContext } from "@apollo/client";
|
|
218
|
+
const httpLink = createHttpLink({ uri: "/graphql" });
|
|
219
|
+
const authLink = setContext((operation, prevContext) => {
|
|
220
|
+
/*...*/
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// Apollo Client 4
|
|
224
|
+
import { HttpLink, SetContextLink } from "@apollo/client";
|
|
225
|
+
const httpLink = new HttpLink({ uri: "/graphql" });
|
|
226
|
+
const authLink = new SetContextLink((prevContext, operation) => {
|
|
227
|
+
/*...*/
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### ErrorLink Changes
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
// Apollo Client 3
|
|
235
|
+
onError(({ graphQLErrors, networkError }) => {
|
|
236
|
+
// Handle errors separately
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Apollo Client 4
|
|
240
|
+
new ErrorLink(({ error }) => {
|
|
241
|
+
if (CombinedGraphQLErrors.is(error)) {
|
|
242
|
+
// Handle GraphQL errors
|
|
243
|
+
} else if (error) {
|
|
244
|
+
// Handle other errors
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Migration Tools
|
|
250
|
+
|
|
251
|
+
### Automated Codemod
|
|
252
|
+
|
|
253
|
+
Apollo Client 4.0 provides a comprehensive codemod to automate migration:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# Basic usage
|
|
257
|
+
npx apollo-client-codemod-migrate-3-to-4 src
|
|
258
|
+
|
|
259
|
+
# TypeScript projects (run separately)
|
|
260
|
+
npx apollo-client-codemod-migrate-3-to-4 --parser ts --extensions ts src
|
|
261
|
+
npx apollo-client-codemod-migrate-3-to-4 --parser tsx --extensions tsx src
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The codemod handles:
|
|
265
|
+
|
|
266
|
+
1. **Import updates** - Moves React imports to `@apollo/client/react`
|
|
267
|
+
2. **Type migrations** - Updates types to new namespaced locations
|
|
268
|
+
3. **Link updates** - Converts creator functions to classes
|
|
269
|
+
4. **Removed exports** - Moves to `@apollo/client/v4-migration` with migration instructions
|
|
270
|
+
|
|
271
|
+
## Breaking Changes Summary
|
|
272
|
+
|
|
273
|
+
### Installation
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# RxJS is now a peer dependency
|
|
277
|
+
npm install @apollo/client graphql rxjs
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### ApolloClient Constructor
|
|
281
|
+
|
|
282
|
+
- `link` option is now required (no more implicit `HttpLink` creation)
|
|
283
|
+
- `uri`, `headers`, `credentials` removed - use `HttpLink` directly
|
|
284
|
+
- `name` and `version` moved to `clientAwareness` option
|
|
285
|
+
- `resolvers` moved to `LocalState` constructor
|
|
286
|
+
- `connectToDevTools` replaced with `devtools.enabled`
|
|
287
|
+
- `disableNetworkFetches` renamed to `prioritizeCacheValues`
|
|
288
|
+
|
|
289
|
+
### Type System
|
|
290
|
+
|
|
291
|
+
- Removed `TContext` and `TCacheShape` generics
|
|
292
|
+
- Types moved to namespaces (see migration guide for full list)
|
|
293
|
+
- Custom context via module augmentation
|
|
294
|
+
|
|
295
|
+
### Observable Changes
|
|
296
|
+
|
|
297
|
+
- Requires calling `.pipe()` for transformations
|
|
298
|
+
- Use RxJS operators instead of method chaining
|
|
299
|
+
|
|
300
|
+
### Testing
|
|
301
|
+
|
|
302
|
+
- `MockedProvider` now has realistic delays by default (20-50ms)
|
|
303
|
+
- `createMockClient` removed - use `MockLink` directly
|
|
304
|
+
|
|
305
|
+
## Performance & Build Improvements
|
|
306
|
+
|
|
307
|
+
- **Modern JavaScript**: No downlevel transpilation for modern features
|
|
308
|
+
- **No Polyfills**: Cleaner bundles, bring your own if needed
|
|
309
|
+
- **Development Mode**: Controlled via export conditions, not global `__DEV__`
|
|
310
|
+
- **ESM Support**: Proper `exports` field for better module resolution
|
|
311
|
+
- **Source Maps**: Fixed and improved for better debugging
|
|
312
|
+
|
|
313
|
+
## Deprecations & Removals
|
|
314
|
+
|
|
315
|
+
### Removed Packages/Exports
|
|
316
|
+
|
|
317
|
+
- React render prop components (`@apollo/client/react/components`)
|
|
318
|
+
- Higher-order components (`@apollo/client/react/hoc`)
|
|
319
|
+
- `@apollo/client/react/parser`
|
|
320
|
+
- `@apollo/client/utilities/globals`
|
|
321
|
+
|
|
322
|
+
## Upgrade Path
|
|
323
|
+
|
|
324
|
+
1. **Update to Apollo Client 3.14** first for deprecation warnings
|
|
325
|
+
2. **Install peer dependencies**: `npm install rxjs`
|
|
326
|
+
3. **Run the codemod** to automate import and type updates
|
|
327
|
+
4. **Update ApolloClient initialization** (explicit `HttpLink`, `LocalState` if needed)
|
|
328
|
+
5. **Review error handling** - update to use new error classes
|
|
329
|
+
6. **Test thoroughly** - especially SSR, error handling, and local state
|
|
330
|
+
|
|
331
|
+
## Resources
|
|
332
|
+
|
|
333
|
+
- [Migration Guide](https://www.apollographql.com/docs/react/migrating/apollo-client-4-migration)
|
|
334
|
+
- [Changelog](https://github.com/apollographql/apollo-client/blob/main/CHANGELOG.md)
|
|
335
|
+
|
|
336
|
+
## Acknowledgments
|
|
337
|
+
|
|
338
|
+
Apollo Client 4.0 represents years of community feedback and contributions. Thank you to all our contributors, early adopters, and the entire GraphQL community for making this release possible.
|
|
339
|
+
|
|
340
|
+
<details>
|
|
341
|
+
|
|
342
|
+
<summary>
|
|
343
|
+
|
|
344
|
+
### Major Changes
|
|
345
|
+
|
|
346
|
+
</summary>
|
|
347
|
+
|
|
348
|
+
- [#12644](https://github.com/apollographql/apollo-client/pull/12644) [`fe2f005`](https://github.com/apollographql/apollo-client/commit/fe2f005c34913ae082b96a807dc240e2785d50bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Replace the `result` property on `ServerError` with `bodyText`. `bodyText` is set to the raw string body. `HttpLink` and `BatchHttpLink` no longer try and parse the response body as JSON when a `ServerError` is thrown.
|
|
349
|
+
|
|
350
|
+
- [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - The `includeExtensions` option of `HttpLink` and `BatchHttpLink` now defaults
|
|
351
|
+
to `true`.
|
|
352
|
+
|
|
353
|
+
If `includeExtensions` is `true`, but `extensions` is not set or empty, extensions
|
|
354
|
+
will not be included in outgoing requests.
|
|
355
|
+
|
|
356
|
+
- [#12686](https://github.com/apollographql/apollo-client/pull/12686) [`dc4b1d0`](https://github.com/apollographql/apollo-client/commit/dc4b1d0d2479a37067113b7bd161a550fb8e4df6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - A `@defer` query that has not yet finished streaming is now considered loading and thus the `loading` flag will be `true` until the response has completed. A new `NetworkStatus.streaming` value has been introduced and will be set as the `networkStatus` while the response is streaming.
|
|
357
|
+
|
|
358
|
+
- [#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.
|
|
359
|
+
|
|
360
|
+
```diff
|
|
361
|
+
- const errorLink = onError(({ graphQLErrors, networkError, protocolErrors }) => {
|
|
362
|
+
- graphQLErrors.forEach(error => console.log(error.message));
|
|
363
|
+
+ const errorLink = onError(({ error }) => {
|
|
364
|
+
+ if (error.name === 'CombinedGraphQLErrors') {
|
|
365
|
+
+ error.errors.forEach(rawError => console.log(rawError.message));
|
|
366
|
+
+ }
|
|
367
|
+
});
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
- [#12586](https://github.com/apollographql/apollo-client/pull/12586) [`605db8e`](https://github.com/apollographql/apollo-client/commit/605db8e94fe2ce74c0a395f38f6873d40f431365) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `typeDefs` option from `ApolloClient`.
|
|
371
|
+
|
|
372
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `asyncMap` utility function. Instead use one of the RxJS operators that creates Observables from promises, such as `from`.
|
|
373
|
+
|
|
374
|
+
- [#12398](https://github.com/apollographql/apollo-client/pull/12398) [`8cf5077`](https://github.com/apollographql/apollo-client/commit/8cf5077bed1ab46fdd32c5e253071506c0076064) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `isApolloError` utility function to check if the error object is an `ApolloError` instance. Use `instanceof` to check for more specific error types that replace `ApolloError`.
|
|
375
|
+
|
|
376
|
+
- [#12379](https://github.com/apollographql/apollo-client/pull/12379) [`ef892b4`](https://github.com/apollographql/apollo-client/commit/ef892b4dc505b02049525f9aba32c51f1c00c922) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `addTypename` option from `InMemoryCache` and `MockedProvider`. `__typename` is now always added to the outgoing query document when using `InMemoryCache` and cannot be disabled.
|
|
377
|
+
|
|
378
|
+
If you are using `<MockedProvider />` with `addTypename={false}`, ensure that your mocked responses include a `__typename` field. This will ensure cache normalization kicks in and behaves more like production.
|
|
379
|
+
|
|
380
|
+
- [#12396](https://github.com/apollographql/apollo-client/pull/12396) [`00f3d0a`](https://github.com/apollographql/apollo-client/commit/00f3d0a674eede1f909092283041cf8ac8d1b576) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `errors` property from `useQuery` and `useLazyQuery`. Read errors from the `error` property instead.
|
|
381
|
+
|
|
382
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.getContext` now returns a `Readonly<OperationContext>` type.
|
|
383
|
+
|
|
384
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `ApolloLink.Request` (i.e. `GraphQLRequest`) passed to `ApolloLink.execute` no longer accepts `operationName` and `operationType` options. These properties are derived from the `query` and set on the returned `ApolloLink.Operation` type.
|
|
385
|
+
|
|
386
|
+
- [#12712](https://github.com/apollographql/apollo-client/pull/12712) [`bbb2b61`](https://github.com/apollographql/apollo-client/commit/bbb2b61d259da54560a79813b130a977dae10523) Thanks [@jerelmiller](https://github.com/jerelmiller)! - An error is now thrown when trying to call `fetchMore` on a `cache-only` query.
|
|
387
|
+
|
|
388
|
+
- [#12222](https://github.com/apollographql/apollo-client/pull/12222) [`d1a9054`](https://github.com/apollographql/apollo-client/commit/d1a905461d4378522c3257de00afba2ae8decd22) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Drop support for React 16.
|
|
389
|
+
|
|
390
|
+
- [#12787](https://github.com/apollographql/apollo-client/pull/12787) [`8ce31fa`](https://github.com/apollographql/apollo-client/commit/8ce31fae54b1ae76c557f361cc946858cb2ff66b) Thanks [@phryneas](https://github.com/phryneas)! - Remove `DataProxy` namespace and interface.
|
|
391
|
+
|
|
392
|
+
- [#12450](https://github.com/apollographql/apollo-client/pull/12450) [`876d070`](https://github.com/apollographql/apollo-client/commit/876d07042cf3348b3769b2bb415aa5f70ce9844c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `TSerialized` generic argument to `ApolloCache`. The `ApolloCache` base cache abstraction now returns `unknown` for `cache.extract` which can be overridden by a cache subclass.
|
|
393
|
+
|
|
394
|
+
- [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `getCacheKey` function is no longer available from `operation.getContext()` in the link chain. Use `operation.client.cache.identify(obj)` in the link chain instead.
|
|
395
|
+
|
|
396
|
+
- [#12376](https://github.com/apollographql/apollo-client/pull/12376) [`a0c996a`](https://github.com/apollographql/apollo-client/commit/a0c996a816fbb6a2323231c0422d1c8a3e20cbaf) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `ignoreResults` option from `useMutation`. If you don't want to synchronize component state with the mutation, use `useApolloClient` to access your client instance and use `client.mutate` directly.
|
|
397
|
+
|
|
398
|
+
- [#12644](https://github.com/apollographql/apollo-client/pull/12644) [`fe2f005`](https://github.com/apollographql/apollo-client/commit/fe2f005c34913ae082b96a807dc240e2785d50bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - More strictly adhere to the [GraphQL over HTTP spec](https://graphql.github.io/graphql-over-http/draft/). This change adds support for the `application/graphql-response+json` media type and modifies the behavior of the `application/json` media type.
|
|
399
|
+
|
|
400
|
+
- The client will parse the response as a well-formed GraphQL response when the server encodes `content-type` using `application/graphql-response+json` with a non-200 status code.
|
|
401
|
+
- The client will now throw a `ServerError` when the server encodes `content-type` using `application/json` and returns a non-200 status code.
|
|
402
|
+
- The client will now throw a `ServerError` when the server encodes using any other `content-type` and returns a non-200 status code.
|
|
403
|
+
|
|
404
|
+
NOTE: If you use a testing utility to mock requests in your test, you may experience different behavior than production if your testing utility responds as `application/json` but your production server responds as `application/graphql-response+json`. If a `content-type` header is not set, the client interprets the response as `application/json`.
|
|
405
|
+
|
|
406
|
+
- [#12600](https://github.com/apollographql/apollo-client/pull/12600) [`34ff6aa`](https://github.com/apollographql/apollo-client/commit/34ff6aa25b47c3e84d0b18e2c69bc995814bf2f2) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move most of the utilities in `@apollo/client/utilities` to `@apollo/client/utilities/internal`. Many of the utilities exported from the `@apollo/client/utilities` endpoint were not considered stable.
|
|
407
|
+
|
|
408
|
+
As a result of this change, utilities or types exported from `@apollo/client/utilities` are now documented and considered stable and will not undergo breaking changes.
|
|
409
|
+
|
|
410
|
+
- [#12513](https://github.com/apollographql/apollo-client/pull/12513) [`9c3207c`](https://github.com/apollographql/apollo-client/commit/9c3207c44ddad1f8b845c09495d6c070ace8de7b) Thanks [@phryneas](https://github.com/phryneas)! - Removed the `@apollo/client/react/context` and `@apollo/client/react/hooks` entry points. Please use `@apollo/client/react` instead.
|
|
411
|
+
|
|
412
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Unusubscribing from `ObservableQuery` while a request is in flight will no longer terminate the request by unsubscribing from the link observable.
|
|
413
|
+
|
|
414
|
+
- [#12463](https://github.com/apollographql/apollo-client/pull/12463) [`3868df8`](https://github.com/apollographql/apollo-client/commit/3868df81f973dc7b5a79fadf4dc1b0e291003b7f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.setOptions` has been removed as it was an alias of `reobserve`. Prefer using `reobserve` directly instead.
|
|
415
|
+
|
|
416
|
+
```diff
|
|
417
|
+
const observable = client.watchQuery(options);
|
|
418
|
+
|
|
419
|
+
// Use reobserve to set new options and reevaluate the query
|
|
420
|
+
- observable.setOptions(newOptions);
|
|
421
|
+
+ observable.reobserve(newOptions);
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
As a result of this change, `reobserve` has been marked for public use and is no longer considered an internal API. The `newNetworkStatus` argument has been removed to facilitate this change.
|
|
425
|
+
|
|
426
|
+
- [#12478](https://github.com/apollographql/apollo-client/pull/12478) [`5ea6a45`](https://github.com/apollographql/apollo-client/commit/5ea6a45b3ec2f0d526abe78ae03c42bb519f87c7) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `variables` from the result returned from `useSubscription`.
|
|
427
|
+
|
|
428
|
+
- [#12735](https://github.com/apollographql/apollo-client/pull/12735) [`5159880`](https://github.com/apollographql/apollo-client/commit/51598808851e16af722baaefbd1f90534332e07a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `resultCacheMaxSize` option from `InMemoryCache` options.
|
|
429
|
+
|
|
430
|
+
- [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - The `ApolloClient` constructor options `name` and `version` that are used to
|
|
431
|
+
configure the client awareness feature have moved onto a `clientAwareness` key.
|
|
432
|
+
|
|
433
|
+
```diff
|
|
434
|
+
const client = new ApolloClient({
|
|
435
|
+
// ..
|
|
436
|
+
- name: "my-app",
|
|
437
|
+
- version: "1.0.0",
|
|
438
|
+
+ clientAwareness: {
|
|
439
|
+
+ name: "my-app",
|
|
440
|
+
+ version: "1.0.0",
|
|
441
|
+
+ },
|
|
442
|
+
});
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `previousData` property on `useLazyQuery` will now change only when `data` changes. Previously `previousData` would change to the same value as `data` while the query was loading.
|
|
446
|
+
|
|
447
|
+
- [#12690](https://github.com/apollographql/apollo-client/pull/12690) [`5812759`](https://github.com/apollographql/apollo-client/commit/5812759b6659df49277635e89492c0d72c3b57d6) Thanks [@phryneas](https://github.com/phryneas)! - Aliasing any other field to `__typename` is now forbidden.
|
|
448
|
+
|
|
449
|
+
- [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery` will now keep previous `data` around when emitting a `loading` state, unless `query` or `variables` changed.
|
|
450
|
+
Note that `@exports` variables are not taken into account for this, so `data` will stay around even if they change.
|
|
451
|
+
|
|
452
|
+
- [#12776](https://github.com/apollographql/apollo-client/pull/12776) [`bce9b74`](https://github.com/apollographql/apollo-client/commit/bce9b7448a226b109cbe8f14911503fb09f37825) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Report masked fragments as complete even when a nested masked fragment contains partial data.
|
|
453
|
+
|
|
454
|
+
- [#12788](https://github.com/apollographql/apollo-client/pull/12788) [`4179446`](https://github.com/apollographql/apollo-client/commit/417944677d2e79606b0f6cabd8d5d8b2063c876b) Thanks [@phryneas](https://github.com/phryneas)! - `TVariables` now always `extends OperationVariables` in all interfaces.
|
|
455
|
+
|
|
456
|
+
- [#12224](https://github.com/apollographql/apollo-client/pull/12224) [`51e6c0f`](https://github.com/apollographql/apollo-client/commit/51e6c0f8657d20cedc570c6e9a244f877047dd61) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `partialRefetch` option.
|
|
457
|
+
|
|
458
|
+
- [#12407](https://github.com/apollographql/apollo-client/pull/12407) [`8b1390b`](https://github.com/apollographql/apollo-client/commit/8b1390bf0050c6bd4d5a32b67c3b96369d0552d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Calling `refetch` with new variables will now set the `networkStatus` to `refetch` instead of `setVariables`.
|
|
459
|
+
|
|
460
|
+
- [#12476](https://github.com/apollographql/apollo-client/pull/12476) [`6afff60`](https://github.com/apollographql/apollo-client/commit/6afff60beece953406af2cbe07f7ccbf973cadaa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Subscriptions now emit a `SubscribeResult` instead of a `FetchResult`. As a result, the `errors` field has been removed in favor of `error`.
|
|
461
|
+
|
|
462
|
+
- [#12457](https://github.com/apollographql/apollo-client/pull/12457) [`32e85ea`](https://github.com/apollographql/apollo-client/commit/32e85ea9eb93c1ffb10d6f70e9e2775e1326e9aa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Network errors triggered by queries now adhere to the `errorPolicy`. This means that GraphQL errors and network errors now behave the same way. Previously promise-based APIs, such as `client.query`, would reject the promise with the network error even if `errorPolicy` was set to `ignore`. The promise is now resolved with the `error` property set to the network error instead.
|
|
463
|
+
|
|
464
|
+
- [#12840](https://github.com/apollographql/apollo-client/pull/12840) [`83e132a`](https://github.com/apollographql/apollo-client/commit/83e132ab1bacb3293da61dd4519379e36a1fb090) Thanks [@phryneas](https://github.com/phryneas)! - If you use an incremental delivery handler, you now have to explicitly opt into adding the chunk types to the `ApolloLink.Result` type.
|
|
465
|
+
|
|
466
|
+
```ts title="apollo-client.d.ts
|
|
467
|
+
import { Defer20220824Handler } from "@apollo/client/incremental";
|
|
468
|
+
|
|
469
|
+
declare module "@apollo/client" {
|
|
470
|
+
export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {}
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
- [#12712](https://github.com/apollographql/apollo-client/pull/12712) [`bbb2b61`](https://github.com/apollographql/apollo-client/commit/bbb2b61d259da54560a79813b130a977dae10523) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache-only` queries are no longer refetched when calling `client.reFetchObservableQueries` when `includeStandby` is `true`.
|
|
475
|
+
|
|
476
|
+
- [#12808](https://github.com/apollographql/apollo-client/pull/12808) [`8e31a23`](https://github.com/apollographql/apollo-client/commit/8e31a2303b18f6fc4d8ec1cf4c01bf26b90f3f0b) Thanks [@phryneas](https://github.com/phryneas)! - HTTP Multipart handling will now throw an error if the connection closed before the final boundary has been received.
|
|
477
|
+
Data after the final boundary will be ignored.
|
|
478
|
+
|
|
479
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `iterateObserversSafely` utility function.
|
|
480
|
+
|
|
481
|
+
- [#12825](https://github.com/apollographql/apollo-client/pull/12825) [`292b949`](https://github.com/apollographql/apollo-client/commit/292b949e9e1d10a715e0fd403737361f91432fbf) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `serializeFetchParameter` helper is no longer exported and `JSON.stringify` is used directly. As such, the `ClientParseError` type has also been removed in favor of throwing any JSON serialize errors directly.
|
|
482
|
+
|
|
483
|
+
- [#12595](https://github.com/apollographql/apollo-client/pull/12595) [`60bb49c`](https://github.com/apollographql/apollo-client/commit/60bb49ccea9aecf3e6a212b5a1f71907e60af886) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `@apollo/client/testing/experimental` test utilities. Use [GraphQL Testing Library](https://github.com/apollographql/graphql-testing-library) instead.
|
|
484
|
+
|
|
485
|
+
- [#12718](https://github.com/apollographql/apollo-client/pull/12718) [`ecfc02a`](https://github.com/apollographql/apollo-client/commit/ecfc02a37908b58d1f799f0e817cdeab98482720) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump only to release latest as `rc`.
|
|
486
|
+
|
|
487
|
+
- [#12470](https://github.com/apollographql/apollo-client/pull/12470) [`d32902f`](https://github.com/apollographql/apollo-client/commit/d32902f26a4c5dea30421ee52aeea52df3e5334e) Thanks [@phryneas](https://github.com/phryneas)! - `ssrMode`, `ssrForceFetchDelay` and `disableNetworkFetches` have been reworked:
|
|
488
|
+
|
|
489
|
+
Previously, a `ObservableQuery` created by `client.query` or `client.watchQuery`
|
|
490
|
+
while one of those were active would permanently be changed from a `fetchPolicy`
|
|
491
|
+
of `"network-only"` or `"cache-and-network"` to `"cache-first"`, and stay that way
|
|
492
|
+
even long after `disableNetworkFetches` would have been deactivated.
|
|
493
|
+
|
|
494
|
+
Now, the `ObservableQuery` will keep their original `fetchPolicy`, but queries
|
|
495
|
+
made during `disableNetworkFetches` will just apply the `fetchPolicy` replacement
|
|
496
|
+
at request time, just for that one request.
|
|
497
|
+
|
|
498
|
+
`ApolloClient.disableNetworkFetches` has been renamed to `ApolloClient.prioritizeCacheValues` to better reflect this behaviour.
|
|
499
|
+
|
|
500
|
+
- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.variables` can now be reset back to empty when calling `reobserve` with `variables: undefined`. Previously the `variables` key would be ignored so `variables` would remain unchanged.
|
|
501
|
+
|
|
502
|
+
- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `never` is no longer supported as a valid `TVariables` generic argument for APIs that require `variables` as part of its type. Use `Record<string, never>` instead.
|
|
503
|
+
|
|
504
|
+
- [#12735](https://github.com/apollographql/apollo-client/pull/12735) [`5159880`](https://github.com/apollographql/apollo-client/commit/51598808851e16af722baaefbd1f90534332e07a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `connectToDevtools` option from `ApolloClientOptions`. Use `devtools.enabled` instead.
|
|
505
|
+
|
|
506
|
+
- [#12576](https://github.com/apollographql/apollo-client/pull/12576) [`a92ff78`](https://github.com/apollographql/apollo-client/commit/a92ff780abee60896bb9632867e90c82d0829255) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `cache` and `forceFetch` properties are no longer available on context when calling `operation.getContext()`. `cache` can be accessed through the `operation` with `operation.client.cache` instead. `forceFetch` has been replaced with `queryDeduplication` which specifies whether `queryDeduplication` was enabled for the request or not.
|
|
507
|
+
|
|
508
|
+
- [#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.
|
|
509
|
+
|
|
510
|
+
- [#12485](https://github.com/apollographql/apollo-client/pull/12485) [`d338303`](https://github.com/apollographql/apollo-client/commit/d3383033d306b7d66e90f5f3170c24453cd76464) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Throw an error for queries and mutations if the link chain completes without emitting a value.
|
|
511
|
+
|
|
512
|
+
- [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - Removed `getLastResult`, `getLastError` and `resetLastResults` from `ObservableQuery`
|
|
513
|
+
|
|
514
|
+
- [#12663](https://github.com/apollographql/apollo-client/pull/12663) [`01512f2`](https://github.com/apollographql/apollo-client/commit/01512f2429dd394fb72b8ba9284047a09ade666f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Unsubscribing from an `ObservableQuery` before a value has been emitted will remove the query from the tracked list of queries and will no longer be eligible for query deduplication.
|
|
515
|
+
|
|
516
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.operationType` is now a non-null `OperationTypeNode`. It is now safe to compare this value without having to check for `undefined`.
|
|
517
|
+
|
|
518
|
+
- [#12398](https://github.com/apollographql/apollo-client/pull/12398) [`8cf5077`](https://github.com/apollographql/apollo-client/commit/8cf5077bed1ab46fdd32c5e253071506c0076064) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Apollo Client no longer wraps errors in `ApolloError`. `ApolloError` has been replaced with separate error classes depending on the cause of the error. As such, APIs that return an `error` property have been updated to use the generic `Error` type. Use `instanceof` to check for more specific error types.
|
|
519
|
+
|
|
520
|
+
## Migration guide
|
|
521
|
+
|
|
522
|
+
`ApolloError` encapsulated 4 main error properties. The type of error would determine which property was set:
|
|
523
|
+
|
|
524
|
+
- `graphqlErrors` - Errors returned from the `errors` field by the GraphQL server
|
|
525
|
+
- `networkError` - Any non-GraphQL error that caused the query to fail
|
|
526
|
+
- `protocolErrors` - Transport-level errors that occur during [multipart HTTP subscriptions](https://www.apollographql.com/docs/graphos/routing/operations/subscriptions/multipart-protocol)
|
|
527
|
+
- `clientErrors` - A space to define custom errors. Mostly unused.
|
|
528
|
+
|
|
529
|
+
These errors were mutally exclusive, meaning both `networkError` and `graphqlErrors` were never set simultaneously. The following replaces each of these fields from `ApolloError`.
|
|
530
|
+
|
|
531
|
+
### `graphqlErrors`
|
|
532
|
+
|
|
533
|
+
GraphQL errors are now encapsulated in a `CombinedGraphQLErrors` instance. You can access the raw GraphQL errors via the `errors` property.
|
|
534
|
+
|
|
535
|
+
```js
|
|
536
|
+
import { CombinedGraphQLErrors } from "@apollo/client";
|
|
537
|
+
|
|
538
|
+
// ...
|
|
539
|
+
|
|
540
|
+
const { error } = useQuery(query);
|
|
541
|
+
|
|
542
|
+
if (error && error instanceof CombinedGraphQLErrors) {
|
|
543
|
+
console.log(error.errors);
|
|
544
|
+
}
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
### `networkError`
|
|
548
|
+
|
|
549
|
+
Network errors are no longer wrapped and are instead passed through directly.
|
|
550
|
+
|
|
551
|
+
```js
|
|
552
|
+
const client = new ApolloClient({
|
|
553
|
+
link: new ApolloLink(() => {
|
|
554
|
+
return new Observable((observer) => {
|
|
555
|
+
observer.error(new Error("Test error"));
|
|
556
|
+
});
|
|
557
|
+
}),
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
// ...
|
|
561
|
+
|
|
562
|
+
const { error } = useQuery(query);
|
|
563
|
+
|
|
564
|
+
// error is `new Error('Test error')`;
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
### `protocolErrors`
|
|
568
|
+
|
|
569
|
+
Protocol errors are now encapsulated in a `CombinedProtocolErrors` instance. You can access the raw protocol errors via the `errors` property.
|
|
570
|
+
|
|
571
|
+
```js
|
|
572
|
+
import { CombinedProtocolErrors } from "@apollo/client";
|
|
573
|
+
|
|
574
|
+
// ...
|
|
575
|
+
|
|
576
|
+
const { error } = useSubscription(subscription);
|
|
577
|
+
|
|
578
|
+
if (error && error instanceof CombinedProtocolErrors) {
|
|
579
|
+
console.log(error.errors);
|
|
580
|
+
}
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
### `clientErrors`
|
|
584
|
+
|
|
585
|
+
These were unused by the client and have no replacement. Any non-GraphQL or non-protocol errors are now passed through unwrapped.
|
|
586
|
+
|
|
587
|
+
### Strings as errors
|
|
588
|
+
|
|
589
|
+
If the link sends a string error, Apollo Client will wrap this in an `Error` instance. This ensures `error` properties are guaranteed to be of type `Error`.
|
|
590
|
+
|
|
591
|
+
```js
|
|
592
|
+
const client = new ApolloClient({
|
|
593
|
+
link: new ApolloLink(() => {
|
|
594
|
+
return new Observable((observer) => {
|
|
595
|
+
// Oops we sent a string instead of wrapping it in an `Error`
|
|
596
|
+
observer.error("Test error");
|
|
597
|
+
});
|
|
598
|
+
}),
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// ...
|
|
602
|
+
|
|
603
|
+
const { error } = useQuery(query);
|
|
604
|
+
|
|
605
|
+
// The error string is wrapped and returned as `new Error('Test error')`;
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
### Non-error types
|
|
609
|
+
|
|
610
|
+
If the link chain sends any other object type as an error, Apollo Client will wrap this in an `UnknownError` instance with the [`cause`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause) set to the original object. This ensures `error` properties are guaranteed to be of type `Error`.
|
|
611
|
+
|
|
612
|
+
```js
|
|
613
|
+
const client = new ApolloClient({
|
|
614
|
+
link: new ApolloLink(() => {
|
|
615
|
+
return new Observable((observer) => {
|
|
616
|
+
observer.error({ message: "Not a proper error type" });
|
|
617
|
+
});
|
|
618
|
+
}),
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// ...
|
|
622
|
+
|
|
623
|
+
const { error } = useQuery(query);
|
|
624
|
+
|
|
625
|
+
// error is an `UnknownError` instance. error.cause returns the original object.
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `operation.operationName` is now set as `string | undefined` where `undefined` represents an anonymous query. Previously `operationName` would return an empty string as the `operationName` for anonymous queries.
|
|
629
|
+
|
|
630
|
+
- [#12450](https://github.com/apollographql/apollo-client/pull/12450) [`876d070`](https://github.com/apollographql/apollo-client/commit/876d07042cf3348b3769b2bb415aa5f70ce9844c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `TCacheShape` generic argument to `ApolloClient`. `client.extract()` now returns `unknown` by default. You will either need to type-cast this to the expected serialized shape, or use the `cache.extract()` directly from the subclass to get more specific types.
|
|
631
|
+
|
|
632
|
+
- [#12774](https://github.com/apollographql/apollo-client/pull/12774) [`511b4f3`](https://github.com/apollographql/apollo-client/commit/511b4f3e792a75aa5aa27b335e8119dbc2a9c254) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Apply document transforms before reading data from the cache for `client.readQuery`, `client.readFragment`, `client.watchFragment`, `useFragment`, and `useSuspenseFragment`.
|
|
633
|
+
|
|
634
|
+
NOTE: This change does not affect the equivalent `cache.*` APIs. To read data from the cache without first running document transforms, run `cache.readQuery`, `cache.readFragment`, etc.
|
|
635
|
+
|
|
636
|
+
- [#12705](https://github.com/apollographql/apollo-client/pull/12705) [`a60f411`](https://github.com/apollographql/apollo-client/commit/a60f411e58cc67730d0dc4513e4045f004027ded) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache-only` queries will now initialize with `loading: false` and `networkStatus: NetworkStatus.ready` when there is no data in the cache.
|
|
637
|
+
|
|
638
|
+
This means `useQuery` will no longer render a short initial loading state before rendering `loading: false` and `ObservableQuery.getCurrentResult()` will now return `loading: false` immediately.
|
|
639
|
+
|
|
640
|
+
- [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Unify error behavior on mutations for GraphQL errors and network errors by ensuring network errors are subject to the `errorPolicy`. Network errors created when using an `errorPolicy` of `all` will now resolve the promise and be returned on the `error` property of the result, or stripped away when the `errorPolicy` is `none`.
|
|
641
|
+
|
|
642
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `fromError` utility function. Use [`throwError`](https://rxjs.dev/api/index/function/throwError) instead.
|
|
643
|
+
|
|
644
|
+
- [#12649](https://github.com/apollographql/apollo-client/pull/12649) [`0be92ad`](https://github.com/apollographql/apollo-client/commit/0be92ad51cf8de444fa1cc507bab2c21d230a44e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `TData` generic provided to types that return a `dataState` property is now modified by the given `DataState` generic instead of passing a modified `TData` type. For example, a `QueryRef` that could return partial data was defined as `QueryRef<DeepPartial<TData>, TVariables>`. Now `TData` should be provided unmodified and a set of allowed states should be given instead: `QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'>`.
|
|
645
|
+
|
|
646
|
+
To migrate, use the following guide to replace your type with the right set of states (all types listed below are changed the same way):
|
|
647
|
+
|
|
648
|
+
```diff
|
|
649
|
+
- QueryRef<TData, TVariables>
|
|
650
|
+
// `QueryRef`'s default is 'complete' | 'streaming' so this can also be left alone if you prefer
|
|
651
|
+
// All other types affected by this change default to all states
|
|
652
|
+
+ QueryRef<TData, TVariables>
|
|
653
|
+
+ QueryRef<TData, TVariables, 'complete' | 'streaming'>
|
|
654
|
+
|
|
655
|
+
- QueryRef<TData | undefined, TVariables>
|
|
656
|
+
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'empty'>
|
|
657
|
+
|
|
658
|
+
- QueryRef<DeepPartial<TData>, TVariables>
|
|
659
|
+
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'>
|
|
660
|
+
|
|
661
|
+
- QueryRef<DeepPartial<TData> | undefined, TVariables>
|
|
662
|
+
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial' | 'empty'>
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
The following types are affected. Provide the allowed `dataState` values to the `TDataState` generic:
|
|
666
|
+
|
|
667
|
+
- `ApolloQueryResult`
|
|
668
|
+
- `QueryRef`
|
|
669
|
+
- `PreloadedQueryRef`
|
|
670
|
+
- `useLazyQuery.Result`
|
|
671
|
+
- `useQuery.Result`
|
|
672
|
+
- `useReadQuery.Result`
|
|
673
|
+
- `useSuspenseQuery.Result`
|
|
674
|
+
|
|
675
|
+
All `*QueryRef` types default to `complete | streaming` states while the rest of the types default to `'complete' | 'streaming' | 'partial' | 'empty'` states. You shouldn't need to provide the states unless you need to either allow for partial data/empty values (`*QueryRef`) or a restricted set of states.
|
|
676
|
+
|
|
677
|
+
- [#12850](https://github.com/apollographql/apollo-client/pull/12850) [`268cd80`](https://github.com/apollographql/apollo-client/commit/268cd800a2d73305c0df8dd38b6bd1cee98f0fec) Thanks [@phryneas](https://github.com/phryneas)! - Introduce a versioning policy.
|
|
678
|
+
|
|
679
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `concat`, `from`, and `split` functions on `ApollLink` no longer support a plain request handler function. Please wrap the request handler with `new ApolloLink`.
|
|
680
|
+
|
|
681
|
+
```diff
|
|
682
|
+
const link = new ApolloLink(/* ... */);
|
|
683
|
+
|
|
684
|
+
link.concat(
|
|
685
|
+
- (operation, forward) => forward(operation),
|
|
686
|
+
+ new ApolloLink((operation, forward) => forward(operation)),
|
|
687
|
+
);
|
|
688
|
+
```
|
|
689
|
+
|
|
690
|
+
- [#12802](https://github.com/apollographql/apollo-client/pull/12802) [`e2b51b3`](https://github.com/apollographql/apollo-client/commit/e2b51b30acbd360253100f9d2a91fe7e0c57be4c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Disallow the `mutation` option for the `mutate` function returned from `useMutation`.
|
|
691
|
+
|
|
692
|
+
- [#12211](https://github.com/apollographql/apollo-client/pull/12211) [`c2736db`](https://github.com/apollographql/apollo-client/commit/c2736db3ad6f8b6e56f065682d5b76614f41bfd4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `graphql`, `withQuery`, `withMutation`, `withSubscription`, and `withApollo` hoc components. Use the provided React hooks instead.
|
|
693
|
+
|
|
694
|
+
- [#12690](https://github.com/apollographql/apollo-client/pull/12690) [`5812759`](https://github.com/apollographql/apollo-client/commit/5812759b6659df49277635e89492c0d72c3b57d6) Thanks [@phryneas](https://github.com/phryneas)! - Aliasing a field to an alias beginning with `__ac_` is now forbidden - this namespace is now reserved for internal use.
|
|
695
|
+
|
|
696
|
+
- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - When passing a `variables` key with the value `undefined`, the value will be replaced by the default value in the query, if it is provided, rather than leave it as `undefined`.
|
|
697
|
+
|
|
698
|
+
```ts
|
|
699
|
+
// given this query
|
|
700
|
+
const query = gql`
|
|
701
|
+
query PaginatedQuery($limit: Int! = 10, $offset: Int) {
|
|
702
|
+
list(limit: $limit, offset: $offset) {
|
|
703
|
+
id
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
`;
|
|
707
|
+
|
|
708
|
+
const observable = client.query({
|
|
709
|
+
query,
|
|
710
|
+
variables: { limit: 5, offset: 0 },
|
|
711
|
+
});
|
|
712
|
+
console.log(observable.variables); // => { limit: 5, offset: 0 }
|
|
713
|
+
|
|
714
|
+
observable.reobserve({ variables: { limit: undefined, offset: 10 } });
|
|
715
|
+
// limit is now `10`. This would previously be `undefined`
|
|
716
|
+
console.log(observable.variables); // => { limit: 10, offset: 10 }
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
- [#12262](https://github.com/apollographql/apollo-client/pull/12262) [`10ef733`](https://github.com/apollographql/apollo-client/commit/10ef7338cdcbbaf75d806f426e9708c9e095c2da) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `itAsync` test utility.
|
|
720
|
+
|
|
721
|
+
- [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - Adds enhanced client awareness to the client.
|
|
722
|
+
|
|
723
|
+
`HttpLink` and `BatchHttpLink` will now per default send information about the
|
|
724
|
+
client library you are using in `extensions`.
|
|
725
|
+
|
|
726
|
+
This could look like this:
|
|
727
|
+
|
|
728
|
+
```json
|
|
729
|
+
{
|
|
730
|
+
"query": "query GetUser($id: ID!) { user(id: $id) { __typename id name } }",
|
|
731
|
+
"variables": {
|
|
732
|
+
"id": 5
|
|
733
|
+
},
|
|
734
|
+
"extensions": {
|
|
735
|
+
"clientLibrary": {
|
|
736
|
+
"name": "@apollo/client",
|
|
737
|
+
"version": "4.0.0"
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
This feature can be disabled by passing `enhancedClientAwareness: { transport: false }` to your
|
|
744
|
+
`ApolloClient`, `HttpLink` or `BatchHttpLink` constructor options.
|
|
745
|
+
|
|
746
|
+
- [#12742](https://github.com/apollographql/apollo-client/pull/12742) [`575bf3e`](https://github.com/apollographql/apollo-client/commit/575bf3ed5885efb09c1eec497af4d2690c6b87d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The new `SetContextLink` flips the `prevContext` and `operation` arguments in the callback. The `setContext` function has remained unchanged.
|
|
747
|
+
|
|
748
|
+
```diff
|
|
749
|
+
- new SetContextLink((operation, prevContext) => {
|
|
750
|
+
+ new SetContextLink((prevContext, operation) => {
|
|
751
|
+
// ...
|
|
752
|
+
})
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
- [#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`.
|
|
756
|
+
|
|
757
|
+
- [#12465](https://github.com/apollographql/apollo-client/pull/12465) [`a132163`](https://github.com/apollographql/apollo-client/commit/a1321637cafb4023d6df416e9467294114d8346b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Flatten out React hook types. As a result, the base types have been removed. Prefer using the hook types instead. Removed types include:
|
|
758
|
+
|
|
759
|
+
- `BaseMutationOptions`
|
|
760
|
+
- `BaseQueryOptions`
|
|
761
|
+
- `BaseSubscriptionOptions`
|
|
762
|
+
- `ObservableQueryFields`
|
|
763
|
+
- `MutationSharedOptions`
|
|
764
|
+
- `QueryFunctionOptions`
|
|
765
|
+
|
|
766
|
+
- [#12675](https://github.com/apollographql/apollo-client/pull/12675) [`8f1d974`](https://github.com/apollographql/apollo-client/commit/8f1d974881ff54339b6b6593a219ba6d5fd013c0) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery` no longer has a `queryId` property.
|
|
767
|
+
`ApolloClient.getObservableQueries` no longer returns a `Map<string, ObservableQuery>`, but a `Set<ObservableQuery>`.
|
|
768
|
+
|
|
769
|
+
- [#12398](https://github.com/apollographql/apollo-client/pull/12398) [`8cf5077`](https://github.com/apollographql/apollo-client/commit/8cf5077bed1ab46fdd32c5e253071506c0076064) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Updates the `ServerError` and `ServerParseError` types to be proper `Error` subclasses. Perviously these were plain `Error` intances with additional properties added at runtime. All properties are retained, but `instanceof` checks now work correctly.
|
|
770
|
+
|
|
771
|
+
```js
|
|
772
|
+
import { ServerError, ServerParseError } from "@apollo/client";
|
|
773
|
+
|
|
774
|
+
if (error instanceof ServerError) {
|
|
775
|
+
// ...
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
if (error instanceof ServerParseError) {
|
|
779
|
+
// ...
|
|
780
|
+
}
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
- [#12712](https://github.com/apollographql/apollo-client/pull/12712) [`bbb2b61`](https://github.com/apollographql/apollo-client/commit/bbb2b61d259da54560a79813b130a977dae10523) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache-only` queries are now excluded from `client.refetchQueries` in all situations. `cache-only` queries affected by `updateCache` are also excluded from `refetchQueries` when `onQueryUpdated` is not provided.
|
|
784
|
+
|
|
785
|
+
- [#12463](https://github.com/apollographql/apollo-client/pull/12463) [`3868df8`](https://github.com/apollographql/apollo-client/commit/3868df81f973dc7b5a79fadf4dc1b0e291003b7f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useQuery` no longer returns `reobserve` as part of its result. It was possible to use `reobserve` to set new options on the underlying `ObservableQuery` instance which differed from the options passed to the hook. This could result in unexpected results. Instead prefer to rerender the hook with new options.
|
|
786
|
+
|
|
787
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` no longer supports SSR environments and will now throw if the `execute` function is called in SSR. If you need to run a query in an SSR environment, use `useQuery` instead.
|
|
788
|
+
|
|
789
|
+
- [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `resolvers` option from `ApolloClient`. Local resolvers have instead been moved to the new `LocalState` instance which is assigned to the `localState` option in `ApolloClient`. To migrate, move the `resolvers` values into a `LocalState` instance and assign that instance to `localState`.
|
|
790
|
+
|
|
791
|
+
```diff
|
|
792
|
+
new ApolloClient({
|
|
793
|
+
- resolvers: { /* ... */ }
|
|
794
|
+
+ localState: new LocalState({
|
|
795
|
+
+ resolvers: { /* ... */ }
|
|
796
|
+
+ }),
|
|
797
|
+
});
|
|
798
|
+
```
|
|
799
|
+
|
|
800
|
+
- [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `client.mutate` now returns a `MutateResult` instead of `FetchResult`. As a result, the `errors` property has been removed in favor of `error` which is set if either a network error occured or GraphQL errors are returned from the server.
|
|
801
|
+
|
|
802
|
+
`useMutation` now also returns a `MutateResult` instead of a `FetchResult`.
|
|
803
|
+
|
|
804
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The execute function returned from `useLazyQuery` now only supports the `context` and `variables` options. This means that passing options supported by the hook no longer override the hook value.
|
|
805
|
+
|
|
806
|
+
To change options, rerender the component with new options. These options will take effect with the next query execution.
|
|
807
|
+
|
|
808
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery` will no longer terminate on errors and will instead emit a `next` value with an `error` property. This ensures that `ObservableQuery` instances can continue to receive updates after errors are returned in requests without the need to resubscribe to the observable.
|
|
809
|
+
|
|
810
|
+
- [#12681](https://github.com/apollographql/apollo-client/pull/12681) [`b181f98`](https://github.com/apollographql/apollo-client/commit/b181f98476e635ba3eccab170c09d91f5408060c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Changing most options when rerendering `useQuery` will no longer trigger a `reobserve` which may cause network fetches. Instead, the changed options will be applied to the next cache update or fetch.
|
|
811
|
+
|
|
812
|
+
Options that now trigger a `reobserve` when changed between renders are:
|
|
813
|
+
|
|
814
|
+
- `query`
|
|
815
|
+
- `variables`
|
|
816
|
+
- `skip`
|
|
817
|
+
- Changing `fetchPolicy` to or from `standby`
|
|
818
|
+
|
|
819
|
+
- [#12787](https://github.com/apollographql/apollo-client/pull/12787) [`8ce31fa`](https://github.com/apollographql/apollo-client/commit/8ce31fae54b1ae76c557f361cc946858cb2ff66b) Thanks [@phryneas](https://github.com/phryneas)! - Generic arguments for `Cache.ReadOptions` were flipped from `TVariables, TData` to `TData, TVariables`.
|
|
820
|
+
|
|
821
|
+
- [#12837](https://github.com/apollographql/apollo-client/pull/12837) [`7c49fdc`](https://github.com/apollographql/apollo-client/commit/7c49fdce2f40571d92c83602bbb1b5bd891f626b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - You must now opt in to use GraphQL Codegen data masking types when using Apollo Client's data masking feature. By default, Apollo Client now uses an identity type to apply to masked/unmasked types.
|
|
822
|
+
|
|
823
|
+
If you're using GraphQL Codegen to generate masked types, opt into the GraphQL Codegen masked types using declaration merging on the `TypeOverides` interface.
|
|
824
|
+
|
|
825
|
+
```ts title="apollo-client.d.ts
|
|
826
|
+
import { GraphQLCodegenDataMasking } from "@apollo/client/masking";
|
|
827
|
+
|
|
828
|
+
declare module "@apollo/client" {
|
|
829
|
+
export interface TypeOverrides
|
|
830
|
+
extends GraphQLCodegenDataMasking.TypeOverrides {}
|
|
831
|
+
}
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
- [#12824](https://github.com/apollographql/apollo-client/pull/12824) [`0506f12`](https://github.com/apollographql/apollo-client/commit/0506f12936d3fe7c840e5d56a5efa20bbce1525e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure the `error` argument for the `delay` and `attempts` functions on `RetryLink` are an `ErrorLike`.
|
|
835
|
+
|
|
836
|
+
- [#12398](https://github.com/apollographql/apollo-client/pull/12398) [`8cf5077`](https://github.com/apollographql/apollo-client/commit/8cf5077bed1ab46fdd32c5e253071506c0076064) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `throwServerError` utility function. Now that `ServerError` is an
|
|
837
|
+
`Error` subclass, you can throw these errors directly:
|
|
838
|
+
|
|
839
|
+
```js
|
|
840
|
+
import { ServerError } from "@apollo/client";
|
|
841
|
+
|
|
842
|
+
// instead of
|
|
843
|
+
throwServerError(response, result, "error message");
|
|
844
|
+
|
|
845
|
+
// Use
|
|
846
|
+
throw new ServerError("error message", { response, result });
|
|
847
|
+
```
|
|
848
|
+
|
|
849
|
+
- [#12837](https://github.com/apollographql/apollo-client/pull/12837) [`7c49fdc`](https://github.com/apollographql/apollo-client/commit/7c49fdce2f40571d92c83602bbb1b5bd891f626b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The types mode for data masking has been removed. Adding a types mode to the `DataMasking` interface has no effect. Remove the `mode` key in the module where you declare the `DataMasking` type for the `@apollo/client` module.
|
|
850
|
+
|
|
851
|
+
As a result, the `Masked` and `MaskedDocumentNode` types have also been removed since these have no effect when types are preserved.
|
|
852
|
+
|
|
853
|
+
- [#12304](https://github.com/apollographql/apollo-client/pull/12304) [`86469a2`](https://github.com/apollographql/apollo-client/commit/86469a25abb72dbd68adff3554e3909036e77eee) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `Cache.DiffResult<T>` type is now a union type with better type safety for both complete and partial results. Checking `diff.complete` will now narrow the type of `result` depending on whether the value is `true` or `false`.
|
|
854
|
+
|
|
855
|
+
When `true`, `diff.result` will be a non-null value equal to the `T` generic type. When `false`, `diff.result` now reports `result` as `DeepPartial<T> | null` indicating that fields in the result may be missing (`DeepPartial<T>`) or empty entirely (`null`).
|
|
856
|
+
|
|
857
|
+
- [#12731](https://github.com/apollographql/apollo-client/pull/12731) [`0198870`](https://github.com/apollographql/apollo-client/commit/0198870107eab7ad0bc69a549cb069fa41b3280f) Thanks [@phryneas](https://github.com/phryneas)! - Ship React Compiler compiled React hooks in `@apollo/client/react/compiled`.
|
|
858
|
+
|
|
859
|
+
We now ship a React-Compiler compiled version of the React hooks in
|
|
860
|
+
`@apollo/client/react/compiled`.
|
|
861
|
+
|
|
862
|
+
This entry point contains everything that `@apollo/client/react` does,
|
|
863
|
+
so you can use it as a drop-in replacement in your whole application
|
|
864
|
+
if you choose to use the compiled hooks.
|
|
865
|
+
|
|
866
|
+
- [#12446](https://github.com/apollographql/apollo-client/pull/12446) [`ab920d2`](https://github.com/apollographql/apollo-client/commit/ab920d2701aa276482dbc78b44a1c25c76467bc9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `defaultOptions` option from `useQuery`. Use options directly or use the global `ApolloClient` `defaultOptions`.
|
|
867
|
+
|
|
868
|
+
- [#12649](https://github.com/apollographql/apollo-client/pull/12649) [`0be92ad`](https://github.com/apollographql/apollo-client/commit/0be92ad51cf8de444fa1cc507bab2c21d230a44e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `QueryReference` type. Please use `QueryRef` instead.
|
|
869
|
+
|
|
870
|
+
- [#12396](https://github.com/apollographql/apollo-client/pull/12396) [`00f3d0a`](https://github.com/apollographql/apollo-client/commit/00f3d0a674eede1f909092283041cf8ac8d1b576) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `errors` property from the results emitted from `ObservableQuery` or returned from `client.query`. Read errors from the `error` property instead.
|
|
871
|
+
|
|
872
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The result resolved from the promise returned from the execute function in `useLazyQuery` is now an `ApolloQueryResult` type and no longer includes all the fields returned from the `useLazyQuery` hook tuple.
|
|
873
|
+
|
|
874
|
+
If you need access to the additional properties such as `called`, `refetch`, etc. not included in `ApolloQueryResult`, read them from the hook instead.
|
|
875
|
+
|
|
876
|
+
- [#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`.
|
|
877
|
+
|
|
878
|
+
```diff
|
|
879
|
+
new MockLink([
|
|
880
|
+
{
|
|
881
|
+
request: {
|
|
882
|
+
query,
|
|
883
|
+
+ variables: (requestVariables) => true
|
|
884
|
+
},
|
|
885
|
+
- variableMatcher: (requestVariables) => true
|
|
886
|
+
}
|
|
887
|
+
]);
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
- [#12793](https://github.com/apollographql/apollo-client/pull/12793) [`24e98a1`](https://github.com/apollographql/apollo-client/commit/24e98a16648d4c21f37ba51a678a8849f88174ea) Thanks [@phryneas](https://github.com/phryneas)! - `ApolloConsumer` has been removed - please use `useApolloClient` instead.
|
|
891
|
+
|
|
892
|
+
- [#12714](https://github.com/apollographql/apollo-client/pull/12714) [`0e39469`](https://github.com/apollographql/apollo-client/commit/0e394692eaf0f8d8e506d8304935deafa952accf) Thanks [@phryneas](https://github.com/phryneas)! - Rework option handling for `fetchMore`.
|
|
893
|
+
|
|
894
|
+
- Previously, if the `query` option was specified, no options would be inherited
|
|
895
|
+
from the underlying `ObservableQuery`.
|
|
896
|
+
Now, even if `query` is specified, all unspecified options except for `variables` will be inherited from the underlying `ObservableQuery`.
|
|
897
|
+
- If `query` is not specified, `variables` will still be shallowly merged with the `variables` of the underlying `ObservableQuery`. If a `query` option is specified, the `variables` passed to `fetchMore` are used instead.
|
|
898
|
+
- `errorPolicy` of `fetchMore` will now always default to `"none"` instead of inherited from the `ObservableQuery` options. This can prevent accidental cache writes of partial data for a paginated query. To opt into receive partial data that may be written to the cache, pass an `errorPolicy` to `fetchMore` to override the default.
|
|
899
|
+
|
|
900
|
+
- [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove local resolvers APIs from `ApolloClient` in favor of `localState`. Methods removed are:
|
|
901
|
+
|
|
902
|
+
- `addResolvers`
|
|
903
|
+
- `getResolvers`
|
|
904
|
+
- `setResolvers`
|
|
905
|
+
- `setLocalStateFragmentMatcher`
|
|
906
|
+
|
|
907
|
+
- [#12576](https://github.com/apollographql/apollo-client/pull/12576) [`a92ff78`](https://github.com/apollographql/apollo-client/commit/a92ff780abee60896bb9632867e90c82d0829255) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ApolloLink.execute` now requires a third argument which provides the `client` that initiated the request to the link chain. If you use `execute` directly, add a third argument with a `client` property:
|
|
908
|
+
|
|
909
|
+
```ts
|
|
910
|
+
ApolloLink.execute(link, operation, { client });
|
|
911
|
+
|
|
912
|
+
// or if you import the `execute` function directly:
|
|
913
|
+
execute(link, operation, { client });
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
- [#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.
|
|
917
|
+
In the next major, the `@apollo/client/core` entry point will be removed.
|
|
918
|
+
Please change imports over from `@apollo/client/core` to `@apollo/client`.
|
|
919
|
+
|
|
920
|
+
- [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - Added a new `Streaming` type that will mark `data` in results while `dataState`
|
|
921
|
+
is `"streaming"`.
|
|
922
|
+
|
|
923
|
+
`Streaming<TData>` defaults to `TData`, but can be overwritten in userland to
|
|
924
|
+
integrate with different codegen dialects.
|
|
925
|
+
|
|
926
|
+
You can override this type globally - this example shows how to override it
|
|
927
|
+
with `DeepPartial<TData>`:
|
|
928
|
+
|
|
929
|
+
```ts
|
|
930
|
+
import { HKT, DeepPartial } from "@apollo/client/utilities";
|
|
931
|
+
|
|
932
|
+
type StreamingOverride<TData> = DeepPartial<TData>;
|
|
933
|
+
|
|
934
|
+
interface StreamingOverrideHKT extends HKT {
|
|
935
|
+
return: StreamingOverride<this["arg1"]>;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
declare module "@apollo/client" {
|
|
939
|
+
export interface TypeOverrides {
|
|
940
|
+
Streaming: StreamingOverrideHKT;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
```
|
|
944
|
+
|
|
945
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` will no longer rerender with the loading state when calling the execute function the first time unless the `notifyOnNetworkStatusChange` option is set to `true` (which is the new default).
|
|
946
|
+
|
|
947
|
+
If you prefer the behavior from 3.x, rerender the component with
|
|
948
|
+
`notifyOnNetworkStatusChange` set to `false` after the execute function is
|
|
949
|
+
called the first time.
|
|
950
|
+
|
|
951
|
+
```ts
|
|
952
|
+
function MyComponent() {
|
|
953
|
+
const [notifyOnNetworkStatusChange, setNotifyOnNetworkStatusChange] =
|
|
954
|
+
useState(true);
|
|
955
|
+
const [execute] = useLazyQuery(query, { notifyOnNetworkStatusChange });
|
|
956
|
+
|
|
957
|
+
async function runExecute() {
|
|
958
|
+
await execute();
|
|
959
|
+
|
|
960
|
+
// Set to false after the initial fetch to stop receiving notifications
|
|
961
|
+
// about changes to the loading states.
|
|
962
|
+
setNotifyOnNetworkStatusChange(false);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// ...
|
|
966
|
+
}
|
|
967
|
+
```
|
|
968
|
+
|
|
969
|
+
- [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Mutations no longer report errors if the GraphQL result from the server contains an empty array of errors.
|
|
970
|
+
|
|
971
|
+
- [#12254](https://github.com/apollographql/apollo-client/pull/12254) [`0028ac0`](https://github.com/apollographql/apollo-client/commit/0028ac0147aaea9ab559f15630200a132b43da42) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Changes the default `Accept` header to `application/graphql-response+json`.
|
|
972
|
+
|
|
973
|
+
- [#12633](https://github.com/apollographql/apollo-client/pull/12633) [`9bfb51f`](https://github.com/apollographql/apollo-client/commit/9bfb51fdbca69560da71f9012c74ee172b6c2b69) Thanks [@phryneas](https://github.com/phryneas)! - If the `execute` function of `useLazyQuery` is executed, previously started queries
|
|
974
|
+
from the same `useLazyQuery` usage will be rejected with an `AbortError` unless
|
|
975
|
+
`.retain()` is called on the promise returned by previous `execute` calls.
|
|
976
|
+
|
|
977
|
+
Please keep in mind that `useLazyQuery` is primarily meant as a means to synchronize
|
|
978
|
+
your component to the status of a query and that it's purpose it not to make a
|
|
979
|
+
series of network calls.
|
|
980
|
+
If you plan on making a series of network calls without the need to synchronize
|
|
981
|
+
the result with your component, consider using `ApolloClient.query` instead.
|
|
982
|
+
|
|
983
|
+
- [#12513](https://github.com/apollographql/apollo-client/pull/12513) [`9c3207c`](https://github.com/apollographql/apollo-client/commit/9c3207c44ddad1f8b845c09495d6c070ace8de7b) Thanks [@phryneas](https://github.com/phryneas)! - Removed the `@apollo/client/react/parser` entry point. There is no replacement.
|
|
984
|
+
|
|
985
|
+
- [#12430](https://github.com/apollographql/apollo-client/pull/12430) [`2ff66d0`](https://github.com/apollographql/apollo-client/commit/2ff66d06b6d444fbcb46e580ac40e673e695740f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.setVariables` will now resolve with the last emitted result instead of `undefined` when either the variables match the current variables or there are no subscribers to the query.
|
|
986
|
+
|
|
987
|
+
- [#12685](https://github.com/apollographql/apollo-client/pull/12685) [`3b74800`](https://github.com/apollographql/apollo-client/commit/3b748003df89ec69a6ad045fb47bbe9c3e62104c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the check and warning for `cache.fragmentMatches` when applying data masking. `cache.fragmentMatches` is a required API and data masking may crash when `cache.fragmentMatches` does not exist.
|
|
988
|
+
|
|
989
|
+
- [#12385](https://github.com/apollographql/apollo-client/pull/12385) [`cad5117`](https://github.com/apollographql/apollo-client/commit/cad511723a1b8b0ac2042cf49435f7affb0dc4e4) Thanks [@phryneas](https://github.com/phryneas)! - Apollo Client now defaults to production mode, not development mode, if the
|
|
990
|
+
environment cannot be determined.
|
|
991
|
+
|
|
992
|
+
In modern bundlers, this should automatically be handled by the bundler loading
|
|
993
|
+
the bundler with the `development` export condition.
|
|
994
|
+
|
|
995
|
+
If neither the `production` nor the `development` export condition are
|
|
996
|
+
used by the bundler/runtime, Apollo Client will fall back to `globalThis.__DEV__`
|
|
997
|
+
to determine if it should run in production or development mode.
|
|
998
|
+
|
|
999
|
+
Unlike Apollo Client 3 though, if `globalThis.__DEV__` is not set to `true`,
|
|
1000
|
+
Apollo Client will now default to `production`, not to `development`, behaviour.
|
|
1001
|
+
|
|
1002
|
+
This switch to _explicilty_ requiring `true` also resolves a situation where
|
|
1003
|
+
an HTML element with `id="__DEV__"` would create a global `__DEV__` variable
|
|
1004
|
+
with a referent to the DOM element, which in the past was picked up as "truthy" and
|
|
1005
|
+
would have triggered development mode.
|
|
1006
|
+
|
|
1007
|
+
- [#12644](https://github.com/apollographql/apollo-client/pull/12644) [`fe2f005`](https://github.com/apollographql/apollo-client/commit/fe2f005c34913ae082b96a807dc240e2785d50bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Change the default `Accept` header to `application/graphql-response+json,application/json;q=0.9`.
|
|
1008
|
+
|
|
1009
|
+
- [#12476](https://github.com/apollographql/apollo-client/pull/12476) [`6afff60`](https://github.com/apollographql/apollo-client/commit/6afff60beece953406af2cbe07f7ccbf973cadaa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Unify error behavior on subscriptions for GraphQL errors and network errors by ensuring network errors are subject to the `errorPolicy`. Network errors that terminate the connection will now be emitted on the `error` property passed to the `next` callback followed by a call to the `complete` callback.
|
|
1010
|
+
|
|
1011
|
+
- [#12499](https://github.com/apollographql/apollo-client/pull/12499) [`ce35ea2`](https://github.com/apollographql/apollo-client/commit/ce35ea2b3a87d6dd6757e9be50ecc42837bebe56) Thanks [@phryneas](https://github.com/phryneas)! - Enable React compiler for hooks in ESM builds.
|
|
1012
|
+
|
|
1013
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `reobserve` option is no longer available in the result returned from `useLazyQuery`. This was considered an internal API and should not be used directly.
|
|
1014
|
+
|
|
1015
|
+
- [#12333](https://github.com/apollographql/apollo-client/pull/12333) [`3e4beaa`](https://github.com/apollographql/apollo-client/commit/3e4beaa8b768a893da80aae0428f79ee01d6aa38) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix type of `data` property on `ApolloQueryResult`. Previously this field was non-optional, non-null `TData`, however at runtime this value could be set to `undefined`. This field is now reported as `TData | undefined`.
|
|
1016
|
+
|
|
1017
|
+
This will affect you in a handful of places:
|
|
1018
|
+
|
|
1019
|
+
- The `data` property emitted from the result passed to the `next` callback from `client.watchQuery`
|
|
1020
|
+
- Fetch-based APIs that return an `ApolloQueryResult` type such as `observableQuery.refetch`, `observableQuery.fetchMore`, etc.
|
|
1021
|
+
|
|
1022
|
+
- [#12644](https://github.com/apollographql/apollo-client/pull/12644) [`fe2f005`](https://github.com/apollographql/apollo-client/commit/fe2f005c34913ae082b96a807dc240e2785d50bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `HttpLink` and `BatchHttpLink` no longer emit a `next` notification with the JSON-parsed response body when a well-formed GraphQL response is returned and a `ServerError` is thrown.
|
|
1023
|
+
|
|
1024
|
+
- [#12742](https://github.com/apollographql/apollo-client/pull/12742) [`575bf3e`](https://github.com/apollographql/apollo-client/commit/575bf3ed5885efb09c1eec497af4d2690c6b87d4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `operation` argument to the callback passed to `SetContextLink` is now of type `SetContextLink.SetContextOperation` which is an `Operation` without the `getContext` or `setContext` functions. Previously the type of `operation` was `GraphQLRequest` which had access to a `context` property. The `context` property was always `undefined` and could result in bugs when using it instead of the `prevContext` argument.
|
|
1025
|
+
|
|
1026
|
+
This change means the `operation` argument now contains an accessible `client` property.
|
|
1027
|
+
|
|
1028
|
+
- [#12639](https://github.com/apollographql/apollo-client/pull/12639) [`1bdf489`](https://github.com/apollographql/apollo-client/commit/1bdf4893abb173c97877c71012afa15f9d3da8e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move internal testing utilities in `@apollo/client/testing` to `@apollo/client/testing/internal` and remove deprecated testing utilities. Some of the testing utilities exported from the `@apollo/client/testing` endpoint were not considered stable. As a result of this change, testing utilities or types exported from `@apollo/client/testing` are now considered stable and will not undergo breaking changes.
|
|
1029
|
+
|
|
1030
|
+
The following APIs were removed. To migrate, update usages of the following APIs as such:
|
|
1031
|
+
|
|
1032
|
+
**`createMockClient`**
|
|
1033
|
+
|
|
1034
|
+
```diff
|
|
1035
|
+
- const client = createMockClient(data, query, variables);
|
|
1036
|
+
+ const client = new ApolloClient({
|
|
1037
|
+
+ cache: new InMemoryCache(),
|
|
1038
|
+
+ link: new MockLink([
|
|
1039
|
+
+ {
|
|
1040
|
+
+ request: { query, variables },
|
|
1041
|
+
+ result: { data },
|
|
1042
|
+
+ }
|
|
1043
|
+
+ ]),
|
|
1044
|
+
+ });
|
|
1045
|
+
```
|
|
1046
|
+
|
|
1047
|
+
**`mockObservableLink`**
|
|
1048
|
+
|
|
1049
|
+
```diff
|
|
1050
|
+
- const link = mockObservableLink();
|
|
1051
|
+
+ const link = new MockSubscriptionLink();
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
**`mockSingleLink`**
|
|
1055
|
+
|
|
1056
|
+
```diff
|
|
1057
|
+
- const link = mockSingleLink({
|
|
1058
|
+
- request: { query, variables },
|
|
1059
|
+
- result: { data },
|
|
1060
|
+
- });
|
|
1061
|
+
+ const link = new MockLink([
|
|
1062
|
+
+ {
|
|
1063
|
+
+ request: { query, variables },
|
|
1064
|
+
+ result: { data },
|
|
1065
|
+
+ }
|
|
1066
|
+
+ ]);
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
- [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Third-party caches must now implement the `fragmentMatches` API. Additionally `fragmentMatches` must be able to handle both `InlineFragmentNode` and `FragmentDefinitionNode` nodes.
|
|
1070
|
+
|
|
1071
|
+
```ts
|
|
1072
|
+
class MyCache extends ApolloCache {
|
|
1073
|
+
// This is now required
|
|
1074
|
+
public fragmentMatches(
|
|
1075
|
+
fragment: InlineFragmentNode | FragmentDefinitionNode,
|
|
1076
|
+
typename: string
|
|
1077
|
+
): boolean {
|
|
1078
|
+
return; // ... logic to determine if typename matches fragment
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
```
|
|
1082
|
+
|
|
1083
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The promise returned when calling the execute function from `useLazyQuery` will now reject when using an `errorPolicy` of `none` when GraphQL errors are returned from the result.
|
|
1084
|
+
|
|
1085
|
+
- [#12684](https://github.com/apollographql/apollo-client/pull/12684) [`e697431`](https://github.com/apollographql/apollo-client/commit/e697431a9995fd1900e625c30a9065edd71111d9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `context` from `useLazyQuery` hook options. If used, `context` must now be provided to the `execute` function. `context` will reset to `{}` if not provided as an option to `execute`.
|
|
1086
|
+
|
|
1087
|
+
- [#12704](https://github.com/apollographql/apollo-client/pull/12704) [`45dba43`](https://github.com/apollographql/apollo-client/commit/45dba43b6ba0c306aad8cfbcfd4029265f5e9106) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `ErrorResponse` object passed to the `disable` and `retry` callback options provided to `createPersistedQueryLink` no longer provides separate `graphQLErrors` and `networkError` properties and instead have been combined to a single `error` property of type `ErrorLike`.
|
|
1088
|
+
|
|
1089
|
+
```diff
|
|
1090
|
+
// The following also applies to the `retry` function since it has the same signature
|
|
1091
|
+
createPersistedQueryLink({
|
|
1092
|
+
- disable: ({ graphQLErrors, networkError }) => {
|
|
1093
|
+
+ disable: ({ error }) => {
|
|
1094
|
+
- if (graphQLErrors) {
|
|
1095
|
+
+ if (CombinedGraphQLErrors.is(error)) {
|
|
1096
|
+
// ... handle GraphQL errors
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
- if (networkError) {
|
|
1100
|
+
+ if (error) {
|
|
1101
|
+
// ... handle link errors
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
// optionally check for a specific kind of error
|
|
1105
|
+
- if (networkError) {
|
|
1106
|
+
+ if (ServerError.is(error)) {
|
|
1107
|
+
// ... handle a server error
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
```
|
|
1111
|
+
|
|
1112
|
+
The `response` property has also been renamed to `result`.
|
|
1113
|
+
|
|
1114
|
+
```diff
|
|
1115
|
+
createPersistedQueryLink({
|
|
1116
|
+
- disable: ({ response }) => {
|
|
1117
|
+
+ disable: ({ result }) => {
|
|
1118
|
+
// ... handle GraphQL errors
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
```
|
|
1123
|
+
|
|
1124
|
+
- [#12823](https://github.com/apollographql/apollo-client/pull/12823) [`19e315e`](https://github.com/apollographql/apollo-client/commit/19e315e316ae458913f4d11961b0a2a365df0a19) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move all 1st party link types into a namespace.
|
|
1125
|
+
|
|
1126
|
+
- [#12223](https://github.com/apollographql/apollo-client/pull/12223) [`69c1cb6`](https://github.com/apollographql/apollo-client/commit/69c1cb6f831941598987185238a299b050a364bd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `subscribeAndCount` testing utility from `@apollo/client/testing`.
|
|
1127
|
+
|
|
1128
|
+
- [#12300](https://github.com/apollographql/apollo-client/pull/12300) [`4d581e4`](https://github.com/apollographql/apollo-client/commit/4d581e4f5a3c5409e5f06a5f164beabdada150f1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Moves all React-related exports to the `@apollo/client/react` entrypoint and out of the main `@apollo/client` entrypoint. This prevents the need to install React in order to use the core client.
|
|
1129
|
+
|
|
1130
|
+
The following is a list of exports available in `@apollo/client` that should now import from `@apollo/client/react`.
|
|
1131
|
+
|
|
1132
|
+
- `ApolloConsumer`
|
|
1133
|
+
- `ApolloProvider`
|
|
1134
|
+
- `createQueryPreloader`
|
|
1135
|
+
- `getApolloContext`
|
|
1136
|
+
- `skipToken`
|
|
1137
|
+
- `useApolloClient`
|
|
1138
|
+
- `useBackgroundQuery`
|
|
1139
|
+
- `useFragment`
|
|
1140
|
+
- `useLazyQuery`
|
|
1141
|
+
- `useLoadableQuery`
|
|
1142
|
+
- `useMutation`
|
|
1143
|
+
- `useQuery`
|
|
1144
|
+
- `useQueryRefHandlers`
|
|
1145
|
+
- `useReactiveVar`
|
|
1146
|
+
- `useReadQuery`
|
|
1147
|
+
- `useSubscription`
|
|
1148
|
+
- `useSuspenseQuery`
|
|
1149
|
+
|
|
1150
|
+
The following is a list of exports available in `@apollo/client/testing` that should now import from `@apollo/client/testing/react`:
|
|
1151
|
+
|
|
1152
|
+
- `MockedProvider`
|
|
1153
|
+
|
|
1154
|
+
- [#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`.
|
|
1155
|
+
|
|
1156
|
+
- [#12588](https://github.com/apollographql/apollo-client/pull/12588) [`eed825a`](https://github.com/apollographql/apollo-client/commit/eed825a2549f1d21fff2ec179815206b3baf0fcb) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `TContext` generic argument from all types that use it. `TContext` is replaced with `DefaultContext` which can be modified using declaration merging.
|
|
1157
|
+
|
|
1158
|
+
- [#12647](https://github.com/apollographql/apollo-client/pull/12647) [`a70fac6`](https://github.com/apollographql/apollo-client/commit/a70fac6dd8f26b46c813723a7206e55bfb677690) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery`s will now only be registered with the `ApolloClient` while they
|
|
1159
|
+
have subscribers.
|
|
1160
|
+
|
|
1161
|
+
That means that `ApolloClient.getObservableQueries` and `ApolloClient.refetchQueries`
|
|
1162
|
+
will only be able to return/refetch queries that have at least one subscriber.
|
|
1163
|
+
|
|
1164
|
+
This changes the previous meaning of `active` and `inactive` queries:
|
|
1165
|
+
|
|
1166
|
+
- `inactive` queries are queries with a subscriber that are skipped from a
|
|
1167
|
+
React hook or have a `fetchPolicy` of `standby`
|
|
1168
|
+
- `active` queries are queries with at least one subscriber that are not skipped or in `standby`.
|
|
1169
|
+
|
|
1170
|
+
`ObservableQuery`s without subscribers but with an active ongoing network request
|
|
1171
|
+
(e.g. caused by calling `reobserve`) will be handled as if they had a subscriber
|
|
1172
|
+
for the duration of the query.
|
|
1173
|
+
|
|
1174
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `transformOperation` and `validateOperation` have been removed and are no longer exported from `@apollo/client/link/utils`. These utilities have been merged into the implementation of `createOperation`. As a result, `createOperation` now returns a well-formed `Operation` object. Previously `createOperation` relied on an external call to `transformOperation` to provide a well-formed `Operation` type. If you use `createOperation` directly, remove the calls to `transformOperation` and `validateOperation` and pass the request directly.
|
|
1175
|
+
|
|
1176
|
+
- [#12428](https://github.com/apollographql/apollo-client/pull/12428) [`abed922`](https://github.com/apollographql/apollo-client/commit/abed92225fd2a5d2a0a2298893a1170df1cd7400) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes the `urql` multipart subscriptions utilities. Use the native multipart subscriptions support in `urql` instead.
|
|
1177
|
+
|
|
1178
|
+
- [#12590](https://github.com/apollographql/apollo-client/pull/12590) [`a005e82`](https://github.com/apollographql/apollo-client/commit/a005e822de7b24783f85be45df142ffbb9bc561b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Drop `graphql` v15 as a valid peer dependency.
|
|
1179
|
+
|
|
1180
|
+
- [#12678](https://github.com/apollographql/apollo-client/pull/12678) [`91a876b`](https://github.com/apollographql/apollo-client/commit/91a876b059042828e431931e7a3c2e0365c387b8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `queryRef`s created by `preloadQuery` no longer have a `.toPromise()` function. Instead `preloadQuery` now has a `toPromise` function that accepts a queryRef and will resolve when the underlying promise has been resolved.
|
|
1181
|
+
|
|
1182
|
+
```diff
|
|
1183
|
+
const queryRef = preloadQuery(query, options);
|
|
1184
|
+
|
|
1185
|
+
- await queryRef.toPromise();
|
|
1186
|
+
+ await preloadQuery.toPromise(queryRef);
|
|
1187
|
+
```
|
|
1188
|
+
|
|
1189
|
+
- [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - Reworked the logic for then a loading state is triggered. If the link chain responds synchronously, a loading state will be omitted, otherwise it will be triggered.
|
|
1190
|
+
If local resolvers are used, the time window for "sync vs async" starts as soon as `@exports` variables are resolved.
|
|
1191
|
+
|
|
1192
|
+
- [#12637](https://github.com/apollographql/apollo-client/pull/12637) [`d2a60d4`](https://github.com/apollographql/apollo-client/commit/d2a60d45e734a2518dad2443f85d82553cd6456a) Thanks [@phryneas](https://github.com/phryneas)! - `useQuery`: only advance `previousData` if `data` actually changed
|
|
1193
|
+
|
|
1194
|
+
- [#12478](https://github.com/apollographql/apollo-client/pull/12478) [`5ea6a45`](https://github.com/apollographql/apollo-client/commit/5ea6a45b3ec2f0d526abe78ae03c42bb519f87c7) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove deprecated `onSubscriptionData` and `onSubscriptionComplete` callbacks from `useSubscription`. Use `onData` and `onComplete` instead.
|
|
1195
|
+
|
|
1196
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Switch to [RxJS](https://rxjs.dev/) as the observable implementation. `rxjs` is now a peer dependency of Apollo Client which means you will now need to install `rxjs` in addition to `@apollo/client`.
|
|
1197
|
+
|
|
1198
|
+
This change is mostly transparent, however transforming values on observables, common in link implementations, differs in RxJS vs `zen-observable`. For example, you could modify values in the link chain emitted from a downstream link by using the `.map` function. In RxJS, this is done with the `.pipe` function and passing a `map` operator instead.
|
|
1199
|
+
|
|
1200
|
+
```ts
|
|
1201
|
+
import { map } from "rxjs";
|
|
1202
|
+
|
|
1203
|
+
const link new ApolloLink((operation, forward) => {
|
|
1204
|
+
return forward(operation).pipe(
|
|
1205
|
+
map((result) => performTransform(result))
|
|
1206
|
+
);
|
|
1207
|
+
});
|
|
1208
|
+
```
|
|
1209
|
+
|
|
1210
|
+
For a full list of operators and comprehensive documentation on the capabilities of RxJS, check out the [documentation](https://rxjs.dev/).
|
|
1211
|
+
|
|
1212
|
+
- [#12442](https://github.com/apollographql/apollo-client/pull/12442) [`c5ead08`](https://github.com/apollographql/apollo-client/commit/c5ead08d0f10ddd6232b742defe9620533bf41e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `canonizeResults` option. It was prone to memory leaks. As such, some results that were referentially equal when `canonizeResults` option was set to `true` no longer retain the same object identity.
|
|
1213
|
+
|
|
1214
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The request handler provided to `ApolloLink` must now return an `Observable`. `null` is no longer supported as a valid return value. If you rely on `null` so that `ApolloLink` provides an empty observable, use the `EMPTY` observable from RxJS instead:
|
|
1215
|
+
|
|
1216
|
+
```diff
|
|
1217
|
+
import { ApolloLink } from "@apollo/client";
|
|
1218
|
+
+ import { EMPTY } from "rxjs";
|
|
1219
|
+
|
|
1220
|
+
const link = new ApolloLink((operation, forward) => {
|
|
1221
|
+
- return null;
|
|
1222
|
+
+ return EMPTY;
|
|
1223
|
+
});
|
|
1224
|
+
```
|
|
1225
|
+
|
|
1226
|
+
If you have a custom link that overrides the `request` method, remove `null` from the return signature:
|
|
1227
|
+
|
|
1228
|
+
```diff
|
|
1229
|
+
class MyCustomLink extends ApolloLink {
|
|
1230
|
+
request(
|
|
1231
|
+
operation: ApolloLink.Operation,
|
|
1232
|
+
forward: ApolloLink.ForwardFunction,
|
|
1233
|
+
- ): Observable<ApolloLink.Result> | null {
|
|
1234
|
+
+ ): Observable<ApolloLink.Result> {
|
|
1235
|
+
// implementation
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
```
|
|
1239
|
+
|
|
1240
|
+
- [#12329](https://github.com/apollographql/apollo-client/pull/12329) [`61febe4`](https://github.com/apollographql/apollo-client/commit/61febe4ef8712a2035d7ac89ea7283138db5229d) Thanks [@phryneas](https://github.com/phryneas)! - Rework package publish format (#12329, #12382)
|
|
1241
|
+
|
|
1242
|
+
We have reworked the way Apollo Client is packaged.
|
|
1243
|
+
|
|
1244
|
+
- shipping ESM and CJS
|
|
1245
|
+
- fixing up source maps
|
|
1246
|
+
- the build targets a modern runtime environment (browserslist query: `"since 2023, node >= 20, not dead"`)
|
|
1247
|
+
- removed the "proxy directory" `package.json` files, e.g. `cache/core/package.json` and `react/package.json`. While these helped with older build tools, modern build tooling uses the `exports` field in the root `package.json` instead and the presence of these files can confuse modern build tooling. If your build tooling still relies on those, please update your imports to import from e.g. `@apollo/client/cache/core/index.js` instead of `@apollo/client/cache/core` - but generally, this should not be necessary.
|
|
1248
|
+
- added an `exports` field to `package.json` to expose entry points
|
|
1249
|
+
- instead of `globalThis.__DEV__`, Apollo Client now primarily relies on the `development` and `production` exports conditions. It falls back to `globalThis.__DEV__` if the bundler doesn't know these, though.
|
|
1250
|
+
|
|
1251
|
+
- [#12566](https://github.com/apollographql/apollo-client/pull/12566) [`ce4b488`](https://github.com/apollographql/apollo-client/commit/ce4b488bef13f2f5ce1b348d8c3196e198165dd6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't `broadcastQueries` when a query is torn down.
|
|
1252
|
+
|
|
1253
|
+
- [#12397](https://github.com/apollographql/apollo-client/pull/12397) [`2545a54`](https://github.com/apollographql/apollo-client/commit/2545a5415b06283be83eb9c4a03a3a8a39b8bcde) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `ObservableQuery.resetQueryStoreErrors` method. This method reset some internal state that was not consumed elsewhere in the client and resulted in a no-op.
|
|
1254
|
+
|
|
1255
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `fromPromise` utility function. Use [`from`](https://rxjs.dev/api/index/function/from) instead.
|
|
1256
|
+
|
|
1257
|
+
- [#12388](https://github.com/apollographql/apollo-client/pull/12388) [`0d825be`](https://github.com/apollographql/apollo-client/commit/0d825bef533b41f2e99ef22e620d9f9472825057) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Require environments that support `WeakMap`, `WeakSet` and symbols. Apollo Client would fallback to `Map` and `Set` if the weak versions were not available. This has been removed and expects that these features are available in the source environment.
|
|
1258
|
+
|
|
1259
|
+
If you are running in an environment without `WeakMap`, `WeakSet` or symbols, you will need to find appropriate polyfills.
|
|
1260
|
+
|
|
1261
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` no longer supports calling the execute function in render and will now throw. If you need to execute the query immediately, use `useQuery` instead or move the call to a `useEffect`.
|
|
1262
|
+
|
|
1263
|
+
- [#12631](https://github.com/apollographql/apollo-client/pull/12631) [`b147cac`](https://github.com/apollographql/apollo-client/commit/b147cac5c96c44bfc3deb72c12c7521981584c12) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery` will now return a `loading: false` state for `fetchPolicy` `standby`, even before subscription
|
|
1264
|
+
|
|
1265
|
+
- [#12639](https://github.com/apollographql/apollo-client/pull/12639) [`1bdf489`](https://github.com/apollographql/apollo-client/commit/1bdf4893abb173c97877c71012afa15f9d3da8e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `@apollo/client/testing/core` entrypoint in favor of `@apollo/client/testing`.
|
|
1266
|
+
|
|
1267
|
+
- [#12591](https://github.com/apollographql/apollo-client/pull/12591) [`a7e7383`](https://github.com/apollographql/apollo-client/commit/a7e738328951f5dac25a5fe48d28b3640a3e0eb9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Rename the `@apollo/client/link/core` entrypoint to `@apollo/client/link`.
|
|
1268
|
+
|
|
1269
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `defaultOptions` and `initialFetchPolicy` options are no longer supported with `useLazyQuery`.
|
|
1270
|
+
|
|
1271
|
+
If you use `defaultOptions`, pass those options directly to the hook instead. If you use `initialFetchPolicy`, use `fetchPolicy` instead.
|
|
1272
|
+
|
|
1273
|
+
- [#12823](https://github.com/apollographql/apollo-client/pull/12823) [`19e315e`](https://github.com/apollographql/apollo-client/commit/19e315e316ae458913f4d11961b0a2a365df0a19) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `OperationBatcher` class is no longer exported from `@apollo/client/link/batch`. It is an implementation detail of `BatchLink` and should not be relied on directly.
|
|
1274
|
+
|
|
1275
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `createOperation` no longer accepts `context` as the first argument. Instead make sure `context` is set as the `context` property on the request passed to `createOperation`.
|
|
1276
|
+
|
|
1277
|
+
```diff
|
|
1278
|
+
createOperation(
|
|
1279
|
+
- startingContext,
|
|
1280
|
+
- { query },
|
|
1281
|
+
+ { query, context: startingContext },
|
|
1282
|
+
{ client }
|
|
1283
|
+
);
|
|
1284
|
+
```
|
|
1285
|
+
|
|
1286
|
+
- [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - Dropped the `saveAsLastResult` argument from `ObservableQuery.getCurrentResult`
|
|
1287
|
+
|
|
1288
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` no longer supports `variables` in the hook options and therefore no longer performs variable merging. The execute function must now be called with `variables` instead.
|
|
1289
|
+
|
|
1290
|
+
```ts
|
|
1291
|
+
function MyComponent() {
|
|
1292
|
+
const [execute] = useLazyQuery(query);
|
|
1293
|
+
|
|
1294
|
+
function runExecute() {
|
|
1295
|
+
execute({ variables: { ... }});
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
```
|
|
1299
|
+
|
|
1300
|
+
This change means the execute function returned from `useLazyQuery` is more type-safe. The execute function will require you to pass a `variables` option if the query type includes required variables.
|
|
1301
|
+
|
|
1302
|
+
- [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The resolver function's `context` argument (the 3rd argument) has changed to provide additional information without the possibility of name clashes. Previously the `context` argument would spread request context and override the `client` and `cache` properties to give access to both inside of a resolver. The `context` argument takes now takes the following shape:
|
|
1303
|
+
|
|
1304
|
+
```ts
|
|
1305
|
+
{
|
|
1306
|
+
// the request context. By default `TContextValue` is of type `DefaultContext`,
|
|
1307
|
+
// but can be changed if a `context` function is provided.
|
|
1308
|
+
requestContext: TContextValue,
|
|
1309
|
+
// The client instance making the request
|
|
1310
|
+
client: ApolloClient,
|
|
1311
|
+
// Whether the resolver is run as a result of gathering exported variables
|
|
1312
|
+
// or resolving the value as part of the result
|
|
1313
|
+
phase: "exports" | "resolve"
|
|
1314
|
+
}
|
|
1315
|
+
```
|
|
1316
|
+
|
|
1317
|
+
To migrate, pull any request context from `requestContext` and the `cache` from the `client` property:
|
|
1318
|
+
|
|
1319
|
+
```diff
|
|
1320
|
+
new LocalState({
|
|
1321
|
+
resolvers: {
|
|
1322
|
+
Query: {
|
|
1323
|
+
- myResolver: (parent, args, { someValue, cache }) => {
|
|
1324
|
+
+ myResolver: (parent, args, { requestContext, client }) => {
|
|
1325
|
+
+ const someValue = requestContext.someValue;
|
|
1326
|
+
+ const cache = client.cache;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
```
|
|
1332
|
+
|
|
1333
|
+
- [#12712](https://github.com/apollographql/apollo-client/pull/12712) [`bbb2b61`](https://github.com/apollographql/apollo-client/commit/bbb2b61d259da54560a79813b130a977dae10523) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache-only` queries no longer poll when a `pollInterval` is set. Instead a warning is now emitted that polling has no effect. If the `fetchPolicy` is changed to `cache-only` after polling is already active, polling is stopped.
|
|
1334
|
+
|
|
1335
|
+
- [#12704](https://github.com/apollographql/apollo-client/pull/12704) [`45dba43`](https://github.com/apollographql/apollo-client/commit/45dba43b6ba0c306aad8cfbcfd4029265f5e9106) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `response` property in `onError` link has been renamed to `result`.
|
|
1336
|
+
|
|
1337
|
+
```diff
|
|
1338
|
+
- onError(({ response }) => {
|
|
1339
|
+
+ onError(({ result }) => {
|
|
1340
|
+
// ...
|
|
1341
|
+
});
|
|
1342
|
+
```
|
|
1343
|
+
|
|
1344
|
+
- [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Apollo Client no longer ships with support for `@client` fields out-of-the-box and now must be opt-in. To opt in to use `@client` fields, pass an instantiated `LocalState` instance to the `localState` option. If a query contains `@client` and local state hasn't been configured, an error will be thrown.
|
|
1345
|
+
|
|
1346
|
+
```ts
|
|
1347
|
+
import { LocalState } from "@apollo/client/local-state";
|
|
1348
|
+
|
|
1349
|
+
new ApolloClient({
|
|
1350
|
+
localState: new LocalState(),
|
|
1351
|
+
});
|
|
1352
|
+
```
|
|
1353
|
+
|
|
1354
|
+
- [#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.
|
|
1355
|
+
|
|
1356
|
+
If you would like to restore the old behavior, use a global default delay of `0`.
|
|
1357
|
+
|
|
1358
|
+
```ts
|
|
1359
|
+
MockLink.defaultOptions = {
|
|
1360
|
+
delay: 0,
|
|
1361
|
+
};
|
|
1362
|
+
```
|
|
1363
|
+
|
|
1364
|
+
- [#12442](https://github.com/apollographql/apollo-client/pull/12442) [`c5ead08`](https://github.com/apollographql/apollo-client/commit/c5ead08d0f10ddd6232b742defe9620533bf41e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `resetResultIdentities` option from `InMemoryCache.gc()`. This affected object canonization which has been removed.
|
|
1365
|
+
|
|
1366
|
+
- [#12304](https://github.com/apollographql/apollo-client/pull/12304) [`86469a2`](https://github.com/apollographql/apollo-client/commit/86469a25abb72dbd68adff3554e3909036e77eee) Thanks [@jerelmiller](https://github.com/jerelmiller)! - ### Changes for users of `InMemoryCache`
|
|
1367
|
+
|
|
1368
|
+
`cache.diff` now returns `null` instead of an empty object (`{}`) when `returnPartialData` is `true` and the result is empty.
|
|
1369
|
+
|
|
1370
|
+
If you use `cache.diff` directly with `returnPartialData: true`, you will need to check for `null` before accessing any other fields on the `result` property. A non-null value indicates that at least one field was present in the cache for the given query document.
|
|
1371
|
+
|
|
1372
|
+
### Changes for third-party cache implementations
|
|
1373
|
+
|
|
1374
|
+
The client now expects `cache.diff` to return `null` instead of an empty object when there is no data that can be fulfilled from the cache and `returnPartialData` is `true`. If your cache implementation returns an empty object, please update this to return `null`.
|
|
1375
|
+
|
|
1376
|
+
- [#12433](https://github.com/apollographql/apollo-client/pull/12433) [`b86e50b`](https://github.com/apollographql/apollo-client/commit/b86e50b1dc121cd67fe73655256b6c61afc18cb4) Thanks [@phryneas](https://github.com/phryneas)! - Remove workarounds for streaming with non-WhatWG response bodies to reduce bundle size.
|
|
1377
|
+
|
|
1378
|
+
This removes support for `fetch` implementations that return Node Streams, Async Iterators or Blob instances as `Response.body`.
|
|
1379
|
+
|
|
1380
|
+
In the WhatWG Fetch specification, [`Response.body`](https://fetch.spec.whatwg.org/#body) is specified as a WhatWG [ReadableStream](https://streams.spec.whatwg.org/#readablestream).
|
|
1381
|
+
|
|
1382
|
+
At this point in time, this is natively supported in browsers, `node` and React Native (via [react-native-fetch-api](https://www.npmjs.com/package/react-native-fetch-api), see our [setup instructions for React Native](https://www.apollographql.com/docs/react/integrations/react-native#consuming-multipart-http-via-text-streaming)).
|
|
1383
|
+
|
|
1384
|
+
If you are using an older `fetch` polyfill that deviates from the spec, this might not be compatible - for example, [node-fetch](https://github.com/node-fetch/node-fetch?tab=readme-ov-file#interface-body) returns a node `Readable` instead of a `ReadableStream`.
|
|
1385
|
+
In those cases, please switch to a compatible alternative such as the `node`-native `fetch`, or `undici`.
|
|
1386
|
+
|
|
1387
|
+
- [#12484](https://github.com/apollographql/apollo-client/pull/12484) [`9a8b9ce`](https://github.com/apollographql/apollo-client/commit/9a8b9cebbcf290984a4f154f261a4090e636e50e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `loading`, `networkStatus`, and `partial` properties on all promise-based query APIs. These properties were mostly static and were unnecessary since promise resolution guaranteed that the query was not longer loading.
|
|
1388
|
+
|
|
1389
|
+
This affects the following APIs:
|
|
1390
|
+
|
|
1391
|
+
- `client.query`
|
|
1392
|
+
- `client.refetchQueries`
|
|
1393
|
+
- `client.reFetchObservableQueries`
|
|
1394
|
+
- `client.resetStore`
|
|
1395
|
+
- `observableQuery.fetchMore`
|
|
1396
|
+
- `observableQuery.refetch`
|
|
1397
|
+
- `observableQuery.reobserve`
|
|
1398
|
+
- `observableQuery.setVariables`
|
|
1399
|
+
- The `useLazyQuery` `execute` function
|
|
1400
|
+
|
|
1401
|
+
- [#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`.
|
|
1402
|
+
|
|
1403
|
+
```ts
|
|
1404
|
+
new ApolloClient({
|
|
1405
|
+
defaultOptions: {
|
|
1406
|
+
watchQuery: {
|
|
1407
|
+
// Use the v3 default
|
|
1408
|
+
notifyOnNetworkStatusChange: false,
|
|
1409
|
+
},
|
|
1410
|
+
},
|
|
1411
|
+
});
|
|
1412
|
+
```
|
|
1413
|
+
|
|
1414
|
+
- [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `fragmentMatcher` option from `ApolloClient`. Custom fragment matchers used with local state are no longer supported. Fragment matching is now performed by the configured `cache` via the `cache.fragmentMatches` API.
|
|
1415
|
+
|
|
1416
|
+
- [#12430](https://github.com/apollographql/apollo-client/pull/12430) [`2ff66d0`](https://github.com/apollographql/apollo-client/commit/2ff66d06b6d444fbcb46e580ac40e673e695740f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Removes `ObservableQuery.result()` method. If you use this method and need similar functionality, use the `firstValueFrom` helper in RxJS.
|
|
1417
|
+
|
|
1418
|
+
```ts
|
|
1419
|
+
import { firstValueFrom, from } from "rxjs";
|
|
1420
|
+
|
|
1421
|
+
// The `from` is necessary to turn `observableQuery` into an RxJS observable
|
|
1422
|
+
const result = await firstValueFrom(from(observableQuery));
|
|
1423
|
+
```
|
|
1424
|
+
|
|
1425
|
+
- [#12359](https://github.com/apollographql/apollo-client/pull/12359) [`ebb4d96`](https://github.com/apollographql/apollo-client/commit/ebb4d9644104244fb066b93a32df778928f2f8a9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `onCompleted` and `onError` callbacks from `useQuery` and `useLazyQuery`.
|
|
1426
|
+
|
|
1427
|
+
See [#12352](https://github.com/apollographql/apollo-client/issues/12352) for more context on this change.
|
|
1428
|
+
|
|
1429
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Subscriptions are no longer eagerly started after calling `client.subscribe`. To kick off the subscription, you will now need to subscribe to the returned observable.
|
|
1430
|
+
|
|
1431
|
+
```ts
|
|
1432
|
+
// Subscriptions are no longer started when calling subscribe on its own.
|
|
1433
|
+
const subscriptionObservable = client.subscribe(...);
|
|
1434
|
+
|
|
1435
|
+
// Instead, subscribe to the returned observable to kick off the subscription.
|
|
1436
|
+
subscriptionObservable.subscribe({
|
|
1437
|
+
next: (value) => console.log(value)
|
|
1438
|
+
});
|
|
1439
|
+
```
|
|
1440
|
+
|
|
1441
|
+
- [#12476](https://github.com/apollographql/apollo-client/pull/12476) [`6afff60`](https://github.com/apollographql/apollo-client/commit/6afff60beece953406af2cbe07f7ccbf973cadaa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - GraphQL errors or network errors emitted while using an `errorPolicy` of `ignore` in subscriptions will no longer emit a result if there is no `data` emitted along with the error.
|
|
1442
|
+
|
|
1443
|
+
- [#12367](https://github.com/apollographql/apollo-client/pull/12367) [`e6af35e`](https://github.com/apollographql/apollo-client/commit/e6af35ed30c732ad834e6c524bc9ce5adbe5f706) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `useLazyQuery` will now only execute the query when the execute function is called. Previously `useLazyQuery` would behave like `useQuery` after the first call to the execute function which means changes to options might perform network requests.
|
|
1444
|
+
|
|
1445
|
+
You can now safely rerender `useLazyQuery` with new options which will take effect the next time you manually trigger the query.
|
|
1446
|
+
|
|
1447
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `TVariables` generic argument on the `GraphQLRequest` type.
|
|
1448
|
+
|
|
1449
|
+
- [#12464](https://github.com/apollographql/apollo-client/pull/12464) [`0595f39`](https://github.com/apollographql/apollo-client/commit/0595f39deba52ac43fa0780b742564134ec7ab89) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `called` property from `useQuery`.
|
|
1450
|
+
|
|
1451
|
+
- [#12384](https://github.com/apollographql/apollo-client/pull/12384) [`6aa6fd3`](https://github.com/apollographql/apollo-client/commit/6aa6fd316cfdb31ebbe3e3133cca2965604e7ca1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `toPromise` utility function. Use [`firstValueFrom`](https://rxjs.dev/api/index/function/firstValueFrom) instead.
|
|
1452
|
+
|
|
1453
|
+
- [#12476](https://github.com/apollographql/apollo-client/pull/12476) [`6afff60`](https://github.com/apollographql/apollo-client/commit/6afff60beece953406af2cbe07f7ccbf973cadaa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Subscriptions no longer emit errors in the `error` callback and instead provide errors on the `error` property on the result passed to the `next` callback. As a result, errors will no longer automatically terminate the connection allowing additional results to be emitted when the connection stays open.
|
|
1454
|
+
|
|
1455
|
+
When an error terminates the downstream connection, a `next` event will be emitted with an `error` property followed by a `complete` event instead.
|
|
1456
|
+
|
|
1457
|
+
- [#12841](https://github.com/apollographql/apollo-client/pull/12841) [`65b503f`](https://github.com/apollographql/apollo-client/commit/65b503fe4bfcf942e8f66f36f622f5f6448d6731) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `DataMasking` interface exported from `@apollo/client` and `@apollo/client/masking`.
|
|
1458
|
+
|
|
1459
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The context object returned from `operation.getContext()` is now frozen to prevent mutable changes to the object which could result in subtle bugs. This applies to the `previousContext` object passed to the `operation.setContext()` callback as well.
|
|
1460
|
+
|
|
1461
|
+
- [#12715](https://github.com/apollographql/apollo-client/pull/12715) [`0be0b3f`](https://github.com/apollographql/apollo-client/commit/0be0b3f54a1b533c95c69d3698c5c3bdbd6279fe) Thanks [@phryneas](https://github.com/phryneas)! - All links are now available as classes. The old creator functions have been deprecated.
|
|
1462
|
+
|
|
1463
|
+
Please migrate these function calls to class creations:
|
|
1464
|
+
|
|
1465
|
+
```diff
|
|
1466
|
+
import {
|
|
1467
|
+
- setContext
|
|
1468
|
+
+ SetContextLink
|
|
1469
|
+
} from "@apollo/client/link/context"
|
|
1470
|
+
|
|
1471
|
+
-const link = setContext(...)
|
|
1472
|
+
+const link = new SetContextLink(...)
|
|
1473
|
+
```
|
|
1474
|
+
|
|
1475
|
+
```diff
|
|
1476
|
+
import {
|
|
1477
|
+
- createHttpLink
|
|
1478
|
+
+ HttpLink
|
|
1479
|
+
} from "@apollo/client/link/http"
|
|
1480
|
+
|
|
1481
|
+
-const link = createHttpLink(...)
|
|
1482
|
+
+const link = new HttpLink(...)
|
|
1483
|
+
```
|
|
1484
|
+
|
|
1485
|
+
```diff
|
|
1486
|
+
import {
|
|
1487
|
+
- createPersistedQueryLink
|
|
1488
|
+
+ PersistedQueryLink
|
|
1489
|
+
} from "@apollo/client/link/persisted-queries"
|
|
1490
|
+
|
|
1491
|
+
-const link = createPersistedQueryLink(...)
|
|
1492
|
+
+const link = new PersistedQueryLink(...)
|
|
1493
|
+
```
|
|
1494
|
+
|
|
1495
|
+
```diff
|
|
1496
|
+
import {
|
|
1497
|
+
- removeTypenameFromVariables
|
|
1498
|
+
+ RemoveTypenameFromVariablesLink
|
|
1499
|
+
} from "@apollo/client/link/remove-typename"
|
|
1500
|
+
|
|
1501
|
+
-const link = removeTypenameFromVariables(...)
|
|
1502
|
+
+const link = new RemoveTypenameFromVariablesLink(...)
|
|
1503
|
+
```
|
|
1504
|
+
|
|
1505
|
+
- [#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.
|
|
1506
|
+
|
|
1507
|
+
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`.
|
|
1508
|
+
|
|
1509
|
+
**with `MockLink`**
|
|
1510
|
+
|
|
1511
|
+
```diff
|
|
1512
|
+
new MockLink([
|
|
1513
|
+
{
|
|
1514
|
+
request: { query, variables },
|
|
1515
|
+
- newData: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
1516
|
+
+ result: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
1517
|
+
+ maxUsageCount: Number.POSITIVE_INFINITY,
|
|
1518
|
+
}
|
|
1519
|
+
])
|
|
1520
|
+
```
|
|
1521
|
+
|
|
1522
|
+
**with `MockedProvider`**
|
|
1523
|
+
|
|
1524
|
+
```diff
|
|
1525
|
+
<MockedProvider
|
|
1526
|
+
mocks={[
|
|
1527
|
+
{
|
|
1528
|
+
request: { query, variables },
|
|
1529
|
+
- newData: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
1530
|
+
+ result: (variables) => ({ data: { greeting: "Hello " + variables.greeting } }),
|
|
1531
|
+
+ maxUsageCount: Number.POSITIVE_INFINITY,
|
|
1532
|
+
}
|
|
1533
|
+
]}
|
|
1534
|
+
/>
|
|
1535
|
+
```
|
|
1536
|
+
|
|
1537
|
+
- [#12556](https://github.com/apollographql/apollo-client/pull/12556) [`c3fceda`](https://github.com/apollographql/apollo-client/commit/c3fceda86c5e0f499d0b5fa54ea7dc4c4391ae2c) Thanks [@phryneas](https://github.com/phryneas)! - A call to `ObservableQuery.setVariables` with different variables or a `ObservableQuery.refetch` call will always now guarantee that a value will be emitted from the observable, even if it is deep equal to the previous value.
|
|
1538
|
+
|
|
1539
|
+
- [#12647](https://github.com/apollographql/apollo-client/pull/12647) [`a70fac6`](https://github.com/apollographql/apollo-client/commit/a70fac6dd8f26b46c813723a7206e55bfb677690) Thanks [@phryneas](https://github.com/phryneas)! - `ApolloClient.stop()` now cleans up more agressively to prevent memory leaks:
|
|
1540
|
+
|
|
1541
|
+
- It will now unsubscribe all active `ObservableQuery` instances by emitting a `completed` event.
|
|
1542
|
+
- It will now reject all currently running queries with `"QueryManager stopped while query was in flight"`.
|
|
1543
|
+
- It will remove all queryRefs from the suspense cache.
|
|
1544
|
+
|
|
1545
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `forward` function passed to the request handler is now always provided to `request` and no longer optional. If you create custom links by subclassing `ApolloLink`, the `forward` function no longer needs to be optional:
|
|
1546
|
+
|
|
1547
|
+
```ts
|
|
1548
|
+
class CustomLink extends ApolloLink {
|
|
1549
|
+
request(
|
|
1550
|
+
operation: ApolloLink.Operation,
|
|
1551
|
+
// This no longer needs to be typed as optional
|
|
1552
|
+
forward: ApolloLink.ForwardFunction
|
|
1553
|
+
) {
|
|
1554
|
+
// ...
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
```
|
|
1558
|
+
|
|
1559
|
+
As a result of this change, `ApolloLink` no longer detects terminating links by checking function arity on the request handler. This means using methods such as `concat` on a terminating link no longer emit a warning. On the flip side, if the terminating link calls the `forward` function, a warning is emitted and an observable that immediately completes is returned which will result in an error from Apollo Client.
|
|
1560
|
+
|
|
1561
|
+
- [#12589](https://github.com/apollographql/apollo-client/pull/12589) [`15f5a1c`](https://github.com/apollographql/apollo-client/commit/15f5a1c29ac05015387a7bbc2dbe9a91d09fedfa) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Require the `link` option when instantiating `ApolloClient`. This removes the `uri`, `credentials` and `headers` options from `ApolloClient` in favor of passing an instantiated `HttpLink` directly. To migrate:
|
|
1562
|
+
|
|
1563
|
+
**If using `uri`, `credentials`, or `headers` options**
|
|
1564
|
+
|
|
1565
|
+
```diff
|
|
1566
|
+
new ApolloClient({
|
|
1567
|
+
// ...
|
|
1568
|
+
- uri,
|
|
1569
|
+
- credentials,
|
|
1570
|
+
- headers,
|
|
1571
|
+
+ link: new HttpLink({ uri, credentials, headers }),
|
|
1572
|
+
// or if you prefer the function call approach:
|
|
1573
|
+
+ link: createHttpLink({ uri, credentials, headers }),
|
|
1574
|
+
});
|
|
1575
|
+
```
|
|
1576
|
+
|
|
1577
|
+
**If creating a client without the `link` option**
|
|
1578
|
+
|
|
1579
|
+
```diff
|
|
1580
|
+
new ApolloClient({
|
|
1581
|
+
// ...
|
|
1582
|
+
+ link: ApolloLink.empty()
|
|
1583
|
+
});
|
|
1584
|
+
```
|
|
1585
|
+
|
|
1586
|
+
- [#12304](https://github.com/apollographql/apollo-client/pull/12304) [`86469a2`](https://github.com/apollographql/apollo-client/commit/86469a25abb72dbd68adff3554e3909036e77eee) Thanks [@jerelmiller](https://github.com/jerelmiller)! - ### Changes for users of `InMemoryCache`
|
|
1587
|
+
|
|
1588
|
+
`cache.diff` no longer throws when `returnPartialData` is set to `false` without a complete result. Instead, `cache.diff` will return `null` when it is unable to read a full cache result.
|
|
1589
|
+
|
|
1590
|
+
If you use `cache.diff` directly with `returnPartialData: false`, remove the `try`/`catch` block and replace with a check for `null`.
|
|
1591
|
+
|
|
1592
|
+
### Changes for third-party cache implementations
|
|
1593
|
+
|
|
1594
|
+
The client now expects `cache.diff` to return `null` instead of throwing when the cache returns an incomplete result and `returnPartialData` is `false`. The internal `try`/`catch` blocks have been removed around `cache.diff`. If your cache implementation throws for incomplete results, please update this to return `null`.
|
|
1595
|
+
|
|
1596
|
+
- [#12451](https://github.com/apollographql/apollo-client/pull/12451) [`77e1b13`](https://github.com/apollographql/apollo-client/commit/77e1b133bdba32c67b5a840090dbacb16282dee9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Default the `TData` generic type to `unknown` in all APIs that use a `TData` generic argument such as `useQuery`, `client.query`, etc.
|
|
1597
|
+
|
|
1598
|
+
- [#12562](https://github.com/apollographql/apollo-client/pull/12562) [`90bf0e6`](https://github.com/apollographql/apollo-client/commit/90bf0e61516a382182f212ac8ab891099e2eb009) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `client.query` no longer supports a `fetchPolicy` of `standby`. `standby` does not fetch and did not return `data`. `standby` is meant for watched queries where fetching should be on hold.
|
|
1599
|
+
|
|
1600
|
+
- [#12211](https://github.com/apollographql/apollo-client/pull/12211) [`c2736db`](https://github.com/apollographql/apollo-client/commit/c2736db3ad6f8b6e56f065682d5b76614f41bfd4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the deprecated `Query`, `Mutation`, and `Subscription` components. Use the provided React hooks instead.
|
|
1601
|
+
|
|
1602
|
+
</details>
|
|
1603
|
+
|
|
1604
|
+
<details>
|
|
1605
|
+
|
|
1606
|
+
<summary>
|
|
1607
|
+
|
|
1608
|
+
### Minor Changes
|
|
1609
|
+
|
|
1610
|
+
</summary>
|
|
1611
|
+
|
|
1612
|
+
- [#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.
|
|
1613
|
+
|
|
1614
|
+
- [#12711](https://github.com/apollographql/apollo-client/pull/12711) [`f730f83`](https://github.com/apollographql/apollo-client/commit/f730f83346d4e3c20116da6f55fdd1381114416c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add an `extensions` property to `CombinedGraphQLErrors` to capture any extensions from the original response.
|
|
1615
|
+
|
|
1616
|
+
- [#12438](https://github.com/apollographql/apollo-client/pull/12438) [`5089516`](https://github.com/apollographql/apollo-client/commit/5089516aa3ad140df22bb8a458faeeb884ed0388) Thanks [@phryneas](https://github.com/phryneas)! - Drop `rehackt` dependency.
|
|
1617
|
+
We can now directly import from `react` without causing build errors in RSC.
|
|
1618
|
+
|
|
1619
|
+
- [#12437](https://github.com/apollographql/apollo-client/pull/12437) [`4779dc7`](https://github.com/apollographql/apollo-client/commit/4779dc7badaba10d8c7a271eb0da6a079049b65d) Thanks [@phryneas](https://github.com/phryneas)! - Remove polyfills for Object.freeze,seal and preventExtensions in React Native
|
|
1620
|
+
|
|
1621
|
+
These polyfills were only necessary until React Native 0.59, which
|
|
1622
|
+
[patched the problem](https://github.com/facebook/react-native/pull/21492) on
|
|
1623
|
+
the React Native side.
|
|
1624
|
+
|
|
1625
|
+
With React Native 0.61, the `Map` function was [completely replaced](https://github.com/facebook/react-native/commit/93b9ac74e59bbe84ea388d7c1879857b4acab114)
|
|
1626
|
+
with a native implementation that never had the problems we guarded against.
|
|
1627
|
+
|
|
1628
|
+
- [#12557](https://github.com/apollographql/apollo-client/pull/12557) [`51d26ae`](https://github.com/apollographql/apollo-client/commit/51d26ae631c6631a189c98ea9357b18e77a9a876) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add ability to specify message formatter for `CombinedGraphQLErrors` and `CombinedProtocolErrors`. To provide your own message formatter, override the static `formatMessage` property on these classes.
|
|
1629
|
+
|
|
1630
|
+
```ts
|
|
1631
|
+
CombinedGraphQLErrors.formatMessage = (
|
|
1632
|
+
errors,
|
|
1633
|
+
{ result, defaultFormatMessage }
|
|
1634
|
+
) => {
|
|
1635
|
+
return "Some formatted message";
|
|
1636
|
+
};
|
|
1637
|
+
|
|
1638
|
+
CombinedProtocolErrors.formatMessage = (errors, { defaultFormatMessage }) => {
|
|
1639
|
+
return "Some formatted message";
|
|
1640
|
+
};
|
|
1641
|
+
```
|
|
1642
|
+
|
|
1643
|
+
- [#12776](https://github.com/apollographql/apollo-client/pull/12776) [`bce9b74`](https://github.com/apollographql/apollo-client/commit/bce9b7448a226b109cbe8f14911503fb09f37825) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `dataState` to the value emitted from `client.watchFragment`.
|
|
1644
|
+
|
|
1645
|
+
- [#12670](https://github.com/apollographql/apollo-client/pull/12670) [`0a880ea`](https://github.com/apollographql/apollo-client/commit/0a880ea4c2360a985fdd2edadb94fcc4b82bad73) Thanks [@phryneas](https://github.com/phryneas)! - Provide a mechanism to override the DataMasking types.
|
|
1646
|
+
|
|
1647
|
+
Up until now, our types `Masked`, `MaskedDocumentNode`, `FragmentType`, `MaybeMasked` and `Unmasked` would assume that you are stictly using the type output format of GraphQL Codegen.
|
|
1648
|
+
|
|
1649
|
+
With this change, you can now modify the behaviour of those types if you use a different form of codegen that produces different types for your queries.
|
|
1650
|
+
|
|
1651
|
+
A simple implementation that would override the `Masked` type to remove all fields starting with `_` from a type would look like this:
|
|
1652
|
+
|
|
1653
|
+
```ts
|
|
1654
|
+
// your actual implementation of `Masked`
|
|
1655
|
+
type CustomMaskedImplementation<TData> = {
|
|
1656
|
+
[K in keyof TData as K extends `_${string}` ? never : K]: TData[K];
|
|
1657
|
+
};
|
|
1658
|
+
|
|
1659
|
+
import { HKT } from "@apollo/client/utilities";
|
|
1660
|
+
// transform this type into a higher kinded type that can be evaulated at a later time
|
|
1661
|
+
interface CustomMaskedType extends HKT {
|
|
1662
|
+
arg1: unknown; // TData
|
|
1663
|
+
return: CustomMaskedImplementation<this["arg1"]>;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
// create an "implementation interface" for the types you want to override
|
|
1667
|
+
export interface CustomDataMaskingImplementation {
|
|
1668
|
+
Masked: CustomMaskedType;
|
|
1669
|
+
// other possible keys: `MaskedDocumentNode`, `FragmentType`, `MaybeMasked` and `Unmasked`
|
|
1670
|
+
}
|
|
1671
|
+
```
|
|
1672
|
+
|
|
1673
|
+
then you would use that `CustomDataMaskingImplementation` interface in your project to extend the `TypeOverrides` interface exported by `@apollo/client` with it's functionality:
|
|
1674
|
+
|
|
1675
|
+
```ts
|
|
1676
|
+
declare module "@apollo/client" {
|
|
1677
|
+
export interface TypeOverrides extends CustomDataMaskingImplementation {}
|
|
1678
|
+
}
|
|
1679
|
+
```
|
|
1680
|
+
|
|
1681
|
+
After that, all internal usage of `Masked` in Apollo Client as well as all usage in your code base will use the new `CustomMaskedType` implementation.
|
|
1682
|
+
|
|
1683
|
+
If you don't specify overrides, Apollo Client will still default to the GraphQL Codegen data masking implementation.
|
|
1684
|
+
The types for that are also explicitly exported as the `GraphQLCodegenDataMasking` namespace in `@apollo/client/masking`.
|
|
1685
|
+
|
|
1686
|
+
- [#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.
|
|
1687
|
+
|
|
1688
|
+
```ts
|
|
1689
|
+
import { realisticDelay } from "@apollo/client/testing";
|
|
1690
|
+
|
|
1691
|
+
new MockLink([
|
|
1692
|
+
{
|
|
1693
|
+
request: { query },
|
|
1694
|
+
result: { data: { greeting: "Hello" } },
|
|
1695
|
+
delay: realisticDelay(),
|
|
1696
|
+
},
|
|
1697
|
+
{
|
|
1698
|
+
request: { query },
|
|
1699
|
+
result: { data: { greeting: "Hello" } },
|
|
1700
|
+
delay: realisticDelay({ min: 10, max: 100 }),
|
|
1701
|
+
},
|
|
1702
|
+
]);
|
|
1703
|
+
```
|
|
1704
|
+
|
|
1705
|
+
- [#12844](https://github.com/apollographql/apollo-client/pull/12844) [`18a0cad`](https://github.com/apollographql/apollo-client/commit/18a0cad773257e540ec8dc8e90f7a875a0ccf99f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add an entrypoint at `@apollo/client/v4-migration` that includes removed values and types. Each export includes doc blocks on how to migrate away from the removed type.
|
|
1706
|
+
|
|
1707
|
+
- [#12546](https://github.com/apollographql/apollo-client/pull/12546) [`5dffbbe`](https://github.com/apollographql/apollo-client/commit/5dffbbe407eb1d9adbcb0fff89f2d3a75dc1ad2b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a static `is` method to error types defined by Apollo Client. `is` makes it simpler to determine whether an error is a specific type, which can be helpful in cases where you'd like to narrow the error type in order to use specific properties from that error.
|
|
1708
|
+
|
|
1709
|
+
This change applies to the following error types:
|
|
1710
|
+
|
|
1711
|
+
- `CombinedGraphQLErrors`
|
|
1712
|
+
- `CombinedProtocolErrors`
|
|
1713
|
+
- `ServerError`
|
|
1714
|
+
- `ServerParseError`
|
|
1715
|
+
- `UnconventionalError`
|
|
1716
|
+
|
|
1717
|
+
**Example**
|
|
1718
|
+
|
|
1719
|
+
```ts
|
|
1720
|
+
import { CombinedGraphQLErrors } from "@apollo/client";
|
|
1721
|
+
|
|
1722
|
+
if (CombinedGraphQLErrors.is(error)) {
|
|
1723
|
+
console.log(error.message);
|
|
1724
|
+
error.errors.forEach((graphQLError) => console.log(graphQLError.message));
|
|
1725
|
+
}
|
|
1726
|
+
```
|
|
1727
|
+
|
|
1728
|
+
- [#12614](https://github.com/apollographql/apollo-client/pull/12614) [`d2851e2`](https://github.com/apollographql/apollo-client/commit/d2851e2c74541995760a86904b1e3ab4bd736e62) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Revamp local resolvers and fix several issues from the existing `resolvers` option.
|
|
1729
|
+
|
|
1730
|
+
- Throwing errors in a resolver will set the field value as `null` and add an error to the response's `errors` array.
|
|
1731
|
+
- Remote results are dealiased before they are passed as the parent object to a resolver so that you can access fields by their field name.
|
|
1732
|
+
- You can now specify a `context` function that you can use to customize the `requestContext` given to resolvers.
|
|
1733
|
+
- The `LocalState` class accepts a `Resolvers` generic that provides autocompletion and type checking against your resolver types to ensure your resolvers are type-safe.
|
|
1734
|
+
- `data: null` is now handled correctly and does not call your local resolvers when the server does not provide a result.
|
|
1735
|
+
- Additional warnings have been added to provide hints when resolvers behave unexpectedly.
|
|
1736
|
+
|
|
1737
|
+
```ts
|
|
1738
|
+
import { LocalState } from "@apollo/client/local-state";
|
|
1739
|
+
|
|
1740
|
+
import { Resolvers } from "./path/to/local-resolvers-types.ts";
|
|
1741
|
+
|
|
1742
|
+
// LocalState now accepts a `Resolvers` generic.
|
|
1743
|
+
const localState = new LocalState<Resolvers>({
|
|
1744
|
+
// The return value of this funciton
|
|
1745
|
+
context: (options) => ({
|
|
1746
|
+
// ...
|
|
1747
|
+
}),
|
|
1748
|
+
resolvers: {
|
|
1749
|
+
// ...
|
|
1750
|
+
},
|
|
1751
|
+
});
|
|
1752
|
+
|
|
1753
|
+
// You may also pass a `ContextValue` generic used to ensure the `context`
|
|
1754
|
+
// function returns the correct type. This type is inferred from your resolvers
|
|
1755
|
+
// if not provided.
|
|
1756
|
+
new LocalState<Resolvers, ContextValue>({
|
|
1757
|
+
// ...
|
|
1758
|
+
});
|
|
1759
|
+
```
|
|
1760
|
+
|
|
1761
|
+
- [#12828](https://github.com/apollographql/apollo-client/pull/12828) [`81b03d8`](https://github.com/apollographql/apollo-client/commit/81b03d86ad7e7384124708477829bcbf63d4fa2c) Thanks [@phryneas](https://github.com/phryneas)! - `invariant.error` will now also log in production builds, not only dev builds
|
|
1762
|
+
|
|
1763
|
+
- [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - The callback function that can be passed to the `ApolloClient.mutate`
|
|
1764
|
+
`refetchQueries` option will now receive a `FormattedExecutionResult` with an
|
|
1765
|
+
additional `dataState` option that describes if the result is `"streaming"`
|
|
1766
|
+
or `"complete"`.
|
|
1767
|
+
This indicates whether the `data` value is of type
|
|
1768
|
+
|
|
1769
|
+
- `Unmasked<TData>` (if `"complete"`)
|
|
1770
|
+
- `Streaming<Unmasked<TData>>` (if `"streaming"`)
|
|
1771
|
+
|
|
1772
|
+
- [#12385](https://github.com/apollographql/apollo-client/pull/12385) [`cad5117`](https://github.com/apollographql/apollo-client/commit/cad511723a1b8b0ac2042cf49435f7affb0dc4e4) Thanks [@phryneas](https://github.com/phryneas)! - Apollo Client is no longer using `ts-invariant`, but ships with a modified variant of it.
|
|
1773
|
+
|
|
1774
|
+
The existing export `setLogVerbosity` from `@apollo/client` is still available and
|
|
1775
|
+
now points to this new integration.
|
|
1776
|
+
**In most cases, you should be using this export.**
|
|
1777
|
+
It will no longer adjust the verbosity of `ts-invariant` and as such no longer
|
|
1778
|
+
influence other packages relying on `ts-invariant`.
|
|
1779
|
+
|
|
1780
|
+
The new entry point `@apollo/client/utilities/invariant` now exports `invariant`,
|
|
1781
|
+
`InvariantError` and `setVerbosity`.
|
|
1782
|
+
(Note that these tools are mostly meant to be used by Apollo Client and libraries directly
|
|
1783
|
+
based on Apollo Client like the `@apollo/client-integration-*` packages.)
|
|
1784
|
+
|
|
1785
|
+
- [#12576](https://github.com/apollographql/apollo-client/pull/12576) [`a92ff78`](https://github.com/apollographql/apollo-client/commit/a92ff780abee60896bb9632867e90c82d0829255) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Provide an extension to define types for `context` passed to the link chain. To define your own types, use [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html) to add properties to the `DefaultContext` type.
|
|
1786
|
+
|
|
1787
|
+
```ts
|
|
1788
|
+
// @apollo-client.d.ts
|
|
1789
|
+
// This import is necessary to ensure all Apollo Client imports
|
|
1790
|
+
// are still available to the rest of the application.
|
|
1791
|
+
import "@apollo/client";
|
|
1792
|
+
|
|
1793
|
+
declare module "@apollo/client" {
|
|
1794
|
+
interface DefaultContext extends Record<string, any> {
|
|
1795
|
+
myProperty: string;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
```
|
|
1799
|
+
|
|
1800
|
+
Links that provide context options can be used with this type to add those context types to `DefaultContext`. For example, to add context options from `HttpLink`, add the following code:
|
|
1801
|
+
|
|
1802
|
+
```ts
|
|
1803
|
+
import { HttpLink } from "@apollo/client";
|
|
1804
|
+
|
|
1805
|
+
declare module "@apollo/client" {
|
|
1806
|
+
interface DefaultContext extends HttpLink.ContextOptions {
|
|
1807
|
+
myProperty: string;
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
```
|
|
1811
|
+
|
|
1812
|
+
At this time, the following built-in links support context options:
|
|
1813
|
+
|
|
1814
|
+
- `HttpLink.ContextOptions`
|
|
1815
|
+
- `BatchHttpLink.ContextOptions`
|
|
1816
|
+
|
|
1817
|
+
- [#12714](https://github.com/apollographql/apollo-client/pull/12714) [`0e39469`](https://github.com/apollographql/apollo-client/commit/0e394692eaf0f8d8e506d8304935deafa952accf) Thanks [@phryneas](https://github.com/phryneas)! - Allow passing `errorPolicy` option to `fetchMore` and change default value to "none".
|
|
1818
|
+
|
|
1819
|
+
- [#12497](https://github.com/apollographql/apollo-client/pull/12497) [`ff2cbe1`](https://github.com/apollographql/apollo-client/commit/ff2cbe1db1815c30f5fda7f6c07091663e065582) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a `data` property to `CombinedGraphQLErrors` that captures any partial data returned by the GraphQL response when `errors` are also returned.
|
|
1820
|
+
|
|
1821
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ApolloLink`'s `concat` method now accepts multiple links to concatenate together.
|
|
1822
|
+
|
|
1823
|
+
```ts
|
|
1824
|
+
const first = new ApolloLink();
|
|
1825
|
+
|
|
1826
|
+
const link = first.concat(second, third, fouth);
|
|
1827
|
+
```
|
|
1828
|
+
|
|
1829
|
+
- [#12753](https://github.com/apollographql/apollo-client/pull/12753) [`b85818d`](https://github.com/apollographql/apollo-client/commit/b85818dcc66d3ed8b1c3a7e5e37b2875d6bf9d03) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Renamed `client.reFetchObservableQueries` to `client.refetchObservableQueries`.
|
|
1830
|
+
`client.reFetchObservableQueries` is still available as an alias, but is now
|
|
1831
|
+
deprecated and will be removed in a future major version.
|
|
1832
|
+
|
|
1833
|
+
- [#12561](https://github.com/apollographql/apollo-client/pull/12561) [`99d72bf`](https://github.com/apollographql/apollo-client/commit/99d72bfdb38e3d9679f60b9acb065a84e3b42fd6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the ability to detect if an error was an error was emitted from the link chain. This is useful if your application throws custom errors in other areas of the application and you'd like to differentiate them from errors emitted by the link chain itself.
|
|
1834
|
+
|
|
1835
|
+
To detect if an error was emitted from the link chain, use `LinkError.is`.
|
|
1836
|
+
|
|
1837
|
+
```ts
|
|
1838
|
+
import { LinkError } from "@apollo/client";
|
|
1839
|
+
|
|
1840
|
+
client.query({ query }).catch((error) => {
|
|
1841
|
+
if (LinkError.is(error)) {
|
|
1842
|
+
// This error originated from the link chain
|
|
1843
|
+
}
|
|
1844
|
+
});
|
|
1845
|
+
```
|
|
1846
|
+
|
|
1847
|
+
- [#12698](https://github.com/apollographql/apollo-client/pull/12698) [`be77d1a`](https://github.com/apollographql/apollo-client/commit/be77d1a6ddf719cab4780a0679fcd98556ac7f22) Thanks [@phryneas](https://github.com/phryneas)! - Adjusted the accept header for multipart requests according to the new GraphQL over HTTP spec with these changes:
|
|
1848
|
+
|
|
1849
|
+
```diff
|
|
1850
|
+
-multipart/mixed;boundary=graphql;subscriptionSpec=1.0,application/json
|
|
1851
|
+
+multipart/mixed;boundary=graphql;subscriptionSpec=1.0,application/graphql-response+json,application/json;q=0.9
|
|
1852
|
+
```
|
|
1853
|
+
|
|
1854
|
+
```diff
|
|
1855
|
+
-multipart/mixed;deferSpec=20220824,application/json
|
|
1856
|
+
+multipart/mixed;deferSpec=20220824,application/graphql-response+json,application/json;q=0.9
|
|
1857
|
+
```
|
|
1858
|
+
|
|
1859
|
+
- [#12663](https://github.com/apollographql/apollo-client/pull/12663) [`01512f2`](https://github.com/apollographql/apollo-client/commit/01512f2429dd394fb72b8ba9284047a09ade666f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Subscriptions created by `client.subscribe()` can now be restarted. Restarting a subscription will terminate the connection with the link chain and recreate the request. Restarts also work across deduplicated subscriptions so calling `restart` on an `observable` who's request is deduplicated will restart the connection for each observable.
|
|
1860
|
+
|
|
1861
|
+
```ts
|
|
1862
|
+
const observable = client.subscribe({ query: subscription });
|
|
1863
|
+
|
|
1864
|
+
// Restart the connection to the link
|
|
1865
|
+
observable.restart();
|
|
1866
|
+
```
|
|
1867
|
+
|
|
1868
|
+
- [#12639](https://github.com/apollographql/apollo-client/pull/12639) [`1bdf489`](https://github.com/apollographql/apollo-client/commit/1bdf4893abb173c97877c71012afa15f9d3da8e6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move `MockLink` types to `MockLink` namespace. This affects the `MockedResponse`, `MockLinkOptions`, and `ResultFunction` types. These types are still exported but are deprecated in favor of the namespace. To migrate, use the types on the `MockLink` namespace instead.
|
|
1869
|
+
|
|
1870
|
+
```diff
|
|
1871
|
+
import {
|
|
1872
|
+
- MockedResponse,
|
|
1873
|
+
- MockLinkOptions,
|
|
1874
|
+
- ResultFunction,
|
|
1875
|
+
+ MockLink
|
|
1876
|
+
} from "@apollo/client/testing";
|
|
1877
|
+
|
|
1878
|
+
- const mocks: MockedResponse = [];
|
|
1879
|
+
+ const mocks: MockLink.MockedResponse = [];
|
|
1880
|
+
|
|
1881
|
+
- const result: ResultFunction = () => {/* ... */ }
|
|
1882
|
+
+ const result: MockLink.ResultFunction = () => {/* ... */ }
|
|
1883
|
+
|
|
1884
|
+
- const options: MockLinkOptions = {}
|
|
1885
|
+
+ const options: MockLink.Options = {}
|
|
1886
|
+
```
|
|
1887
|
+
|
|
1888
|
+
- [#12201](https://github.com/apollographql/apollo-client/pull/12201) [`1c6e03c`](https://github.com/apollographql/apollo-client/commit/1c6e03c9c74a9fad2a1c2e1c3ae61a9560038238) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Overridable types for `dataState: "complete"`, `dataState: "streaming"` and
|
|
1889
|
+
`dataState: "partial"` responses.
|
|
1890
|
+
|
|
1891
|
+
This adds the `DataValue` namespace exported from Apollo Client with the three
|
|
1892
|
+
types `DataValue.Complete`, `DataValue.Streaming` and `DataValue.Partial`.
|
|
1893
|
+
|
|
1894
|
+
These types will be used to mark `TData` in the respective states.
|
|
1895
|
+
|
|
1896
|
+
- `Complete` defaults to `TData`
|
|
1897
|
+
- `Streaming` defaults to `TData`
|
|
1898
|
+
- `Partial` defaults to `DeepPartial<TData>`
|
|
1899
|
+
|
|
1900
|
+
All three can be overwritten, e.g. to be `DeepReadonly` using higher kinded types
|
|
1901
|
+
by following this pattern:
|
|
1902
|
+
|
|
1903
|
+
```ts
|
|
1904
|
+
import { HKT, DeepPartial } from "@apollo/client/utilities";
|
|
1905
|
+
import { DeepReadonly } from "some-type-helper-library";
|
|
1906
|
+
|
|
1907
|
+
interface CompleteOverride extends HKT {
|
|
1908
|
+
return: DeepReadonly<this["arg1"]>;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
interface StreamingOverride extends HKT {
|
|
1912
|
+
return: DeepReadonly<this["arg1"]>;
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
interface PartialOverride extends HKT {
|
|
1916
|
+
return: DeepReadonly<DeepPartial<this["arg1"]>>;
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
declare module "@apollo/client" {
|
|
1920
|
+
export interface TypeOverrides {
|
|
1921
|
+
Complete: CompleteOverride;
|
|
1922
|
+
Streaming: StreamingOverride;
|
|
1923
|
+
Partial: PartialOverride;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
```
|
|
1927
|
+
|
|
1928
|
+
- [#12663](https://github.com/apollographql/apollo-client/pull/12663) [`01512f2`](https://github.com/apollographql/apollo-client/commit/01512f2429dd394fb72b8ba9284047a09ade666f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Deduplicating subscription operations is now supported. Previously it was possible to deduplicate a subscription only if the new subscription was created before a previously subscribed subscription emitted any values. As soon as a value was emitted from a subscription, new subscriptions would create new connections. Deduplication is now active for as long as a subscription connection is open (i.e. the source observable hasn't emitted a `complete` or `error` notification yet.)
|
|
1929
|
+
|
|
1930
|
+
To disable deduplication and force a new connection, use the `queryDeduplication` option in `context` like you would a query operation.
|
|
1931
|
+
|
|
1932
|
+
As a result of this change, calling the `restart` function returned from `useSubscription` will now restart the connection on deduplicated subscriptions.
|
|
1933
|
+
|
|
1934
|
+
- [#12438](https://github.com/apollographql/apollo-client/pull/12438) [`5089516`](https://github.com/apollographql/apollo-client/commit/5089516aa3ad140df22bb8a458faeeb884ed0388) Thanks [@phryneas](https://github.com/phryneas)! - Add `react-server` entry point with stubs for normal exports.
|
|
1935
|
+
|
|
1936
|
+
- [#12333](https://github.com/apollographql/apollo-client/pull/12333) [`3e4beaa`](https://github.com/apollographql/apollo-client/commit/3e4beaa8b768a893da80aae0428f79ee01d6aa38) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Deprecate the `partial` flag on `ApolloQueryResult` and make it a non-optional property. Previously `partial` was only set conditionally if the result emitted was partial. This value is now available with all results that return an `ApolloQueryResult`.
|
|
1937
|
+
|
|
1938
|
+
- [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - Add the new `ClientAwarenessLink`.
|
|
1939
|
+
|
|
1940
|
+
This link is already included in `HttpLink` and `BatchHttpLink` to enable the
|
|
1941
|
+
"client awareness" and "enhanced client awareness" features, but you can also use
|
|
1942
|
+
`ClientAwarenessLink` directly in your link chain to combine it with other
|
|
1943
|
+
terminating links.
|
|
1944
|
+
|
|
1945
|
+
If you want to save the bundle size that `ClientAwarenessLink` adds to `HttpLink`
|
|
1946
|
+
and `BatchHttpLink`, you can use `BaseHttpLink` or `BaseBatchHttpLink` instead.
|
|
1947
|
+
These links come without the `ClientAwarenessLink` included.
|
|
1948
|
+
|
|
1949
|
+
For example:
|
|
1950
|
+
|
|
1951
|
+
```diff
|
|
1952
|
+
import {
|
|
1953
|
+
ApolloClient,
|
|
1954
|
+
- HttpLink,
|
|
1955
|
+
} from "@apollo/client";
|
|
1956
|
+
+import { BaseHttpLink } from "@apollo/client/link/http";
|
|
1957
|
+
|
|
1958
|
+
const client = new ApolloClient({
|
|
1959
|
+
- link: new HttpLink({
|
|
1960
|
+
+ link: new BaseHttpLink({
|
|
1961
|
+
uri,
|
|
1962
|
+
}),
|
|
1963
|
+
cache: new InMemoryCache(),
|
|
1964
|
+
});
|
|
1965
|
+
```
|
|
1966
|
+
|
|
1967
|
+
- [#12647](https://github.com/apollographql/apollo-client/pull/12647) [`a70fac6`](https://github.com/apollographql/apollo-client/commit/a70fac6dd8f26b46c813723a7206e55bfb677690) Thanks [@phryneas](https://github.com/phryneas)! - Added a new `.stop` function on `ObservableQuery`.
|
|
1968
|
+
Calling this method will unsubscribe all current subscribers by sending a `complete` event from the observable and tear down the `ObservableQuery`.
|
|
1969
|
+
|
|
1970
|
+
- [#12576](https://github.com/apollographql/apollo-client/pull/12576) [`a92ff78`](https://github.com/apollographql/apollo-client/commit/a92ff780abee60896bb9632867e90c82d0829255) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a `client` property to the `operation` passed to the link chain. This `client` is set as the `client` making the request to the link chain.
|
|
1971
|
+
|
|
1972
|
+
- [#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.
|
|
1973
|
+
|
|
1974
|
+
**Global defaults**
|
|
1975
|
+
|
|
1976
|
+
```ts
|
|
1977
|
+
MockLink.defaultOptions = {
|
|
1978
|
+
// Use a default delay of 20ms for all mocks in all instances without a specified delay
|
|
1979
|
+
delay: 20,
|
|
1980
|
+
|
|
1981
|
+
// altenatively use a callback which will be executed for each mock
|
|
1982
|
+
delay: () => getRandomNumber(),
|
|
1983
|
+
|
|
1984
|
+
// or use the built-in `realisticDelay`. This is the default
|
|
1985
|
+
delay: realisticDelay(),
|
|
1986
|
+
};
|
|
1987
|
+
```
|
|
1988
|
+
|
|
1989
|
+
**Per-instance defaults**
|
|
1990
|
+
|
|
1991
|
+
```ts
|
|
1992
|
+
new MockLink(
|
|
1993
|
+
[
|
|
1994
|
+
// Use the default delay
|
|
1995
|
+
{
|
|
1996
|
+
request: { query },
|
|
1997
|
+
result: { data: { greeting: "Hello" } },
|
|
1998
|
+
},
|
|
1999
|
+
{
|
|
2000
|
+
request: { query },
|
|
2001
|
+
result: { data: { greeting: "Hello" } },
|
|
2002
|
+
// Override the default for this mock
|
|
2003
|
+
delay: 10,
|
|
2004
|
+
},
|
|
2005
|
+
],
|
|
2006
|
+
{
|
|
2007
|
+
defaultOptions: {
|
|
2008
|
+
// Use a default delay of 20ms for all mocks without a specified delay
|
|
2009
|
+
delay: 20,
|
|
2010
|
+
|
|
2011
|
+
// altenatively use a callback which will be executed for each mock
|
|
2012
|
+
delay: () => getRandomNumber(),
|
|
2013
|
+
|
|
2014
|
+
// or use the built-in `realisticDelay`. This is the default
|
|
2015
|
+
delay: realisticDelay(),
|
|
2016
|
+
},
|
|
2017
|
+
}
|
|
2018
|
+
);
|
|
2019
|
+
```
|
|
2020
|
+
|
|
2021
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Many of the types exported from `@apollo/client/link` now live on the `ApolloLink` namespace. The old types are now deprecated in favor of the namespaced types.
|
|
2022
|
+
|
|
2023
|
+
- `FetchResult` -> `ApolloLink.Result`
|
|
2024
|
+
- `GraphQLRequest` -> `ApolloLink.Request`
|
|
2025
|
+
- `NextLink` -> `ApolloLink.ForwardFunction`
|
|
2026
|
+
- `Operation` -> `ApolloLink.Operation`
|
|
2027
|
+
- `RequestHandler` -> `ApolloLink.RequestHandler`
|
|
2028
|
+
|
|
2029
|
+
- [#12714](https://github.com/apollographql/apollo-client/pull/12714) [`0e39469`](https://github.com/apollographql/apollo-client/commit/0e394692eaf0f8d8e506d8304935deafa952accf) Thanks [@phryneas](https://github.com/phryneas)! - The `FetchMoreQueryOptions` type has been inlined into `FetchMoreOptions`, and
|
|
2030
|
+
`FetchMoreQueryOptions` has been removed.
|
|
2031
|
+
|
|
2032
|
+
- [#12757](https://github.com/apollographql/apollo-client/pull/12757) [`5fd2e7c`](https://github.com/apollographql/apollo-client/commit/5fd2e7c15eecc6469ecf5f4fb116633b056ad103) Thanks [@phryneas](https://github.com/phryneas)! - Add `dataState` and overridable `DataValue` types to `useFragment`
|
|
2033
|
+
|
|
2034
|
+
- [#12757](https://github.com/apollographql/apollo-client/pull/12757) [`5fd2e7c`](https://github.com/apollographql/apollo-client/commit/5fd2e7c15eecc6469ecf5f4fb116633b056ad103) Thanks [@phryneas](https://github.com/phryneas)! - Add overridable `DataValue` types to `useSuspenseFragment`
|
|
2035
|
+
|
|
2036
|
+
- [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - Prioritize usage of `FormattedExecutionResult` over `FetchResult` where applicable.
|
|
2037
|
+
|
|
2038
|
+
Many APIs used `FetchResult` in place of `FormattedExecutionResult`, which could
|
|
2039
|
+
cause inconsistencies.
|
|
2040
|
+
|
|
2041
|
+
- `FetchResult` is now used to refer to an unhandled "raw" result as returned from
|
|
2042
|
+
a link.
|
|
2043
|
+
This can also include incremental results that use a different format.
|
|
2044
|
+
- `FormattedExecutionResult` from the `graphql` package is now used to represent
|
|
2045
|
+
the execution of a standard GraphQL request without incremental results.
|
|
2046
|
+
|
|
2047
|
+
If your custom links access the `data` property, you might need to first check if
|
|
2048
|
+
the result is a standard GraphQL result by using the `isFormattedExecutionResult`
|
|
2049
|
+
helper from `@apollo/client/utilities`.
|
|
2050
|
+
|
|
2051
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The static `ApolloLink.concat` method is now deprecated in favor of `ApolloLink.from`. `ApolloLink.concat` is now an alias for `ApolloLink.from` so prefer `ApolloLink.from` instead.
|
|
2052
|
+
|
|
2053
|
+
- [#12488](https://github.com/apollographql/apollo-client/pull/12488) [`c98b633`](https://github.com/apollographql/apollo-client/commit/c98b6335de5b15e546aa5db79a8cf2dc9d914dcf) Thanks [@phryneas](https://github.com/phryneas)! - Add a new method for static SSR of React components, `prerenderStatic`.
|
|
2054
|
+
The old methods, `getDataFromTree`, `getMarkupFromTree` and `renderToStringWithData`
|
|
2055
|
+
have been deprecated in favor of `prerenderStatic`.
|
|
2056
|
+
|
|
2057
|
+
If used with React 19 and the `prerender` or `prerenderToNodeStream` apis from
|
|
2058
|
+
`react-dom/static`, this method can now be used to SSR-prerender suspense-enabled
|
|
2059
|
+
hook APIs.
|
|
2060
|
+
|
|
2061
|
+
- [#12698](https://github.com/apollographql/apollo-client/pull/12698) [`be77d1a`](https://github.com/apollographql/apollo-client/commit/be77d1a6ddf719cab4780a0679fcd98556ac7f22) Thanks [@phryneas](https://github.com/phryneas)! - Adds an `accept` option to `HttpOptions` that allows to add additional `Accept` headers to be merged in without overriding user-specified or default accept headers.
|
|
2062
|
+
|
|
2063
|
+
- [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - The `mutationResult` option passed to the `updateQueries` callback now has an
|
|
2064
|
+
additional property, `dataState` with possible values of `"complete"` and `"streaming"`.
|
|
2065
|
+
This indicates whether the `data` value is of type
|
|
2066
|
+
|
|
2067
|
+
- `Unmasked<TData>` (if `"complete"`)
|
|
2068
|
+
- `Streaming<Unmasked<TData>>` (if `"streaming"`)
|
|
2069
|
+
|
|
2070
|
+
- [#12487](https://github.com/apollographql/apollo-client/pull/12487) [`b695e5e`](https://github.com/apollographql/apollo-client/commit/b695e5e10ab0eb47948e914b610f67c40267349e) Thanks [@phryneas](https://github.com/phryneas)! - Split out SSR-specific code from useQuery hook, remove RenderPromises
|
|
2071
|
+
|
|
2072
|
+
- [#12725](https://github.com/apollographql/apollo-client/pull/12725) [`89ac725`](https://github.com/apollographql/apollo-client/commit/89ac7256a34b3b04fe2cf83937b5494b375ce36d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `operationType` to `operation` in `ApolloLink`. This means that determining whether a `query` is a specific operation type can now be compared with this property instead of using `getMainDefinition`.
|
|
2073
|
+
|
|
2074
|
+
```diff
|
|
2075
|
+
- import { getMainDefinition } from "@apollo/client/utilities";
|
|
2076
|
+
+ import { OperationTypeNode } from "graphql";
|
|
2077
|
+
|
|
2078
|
+
ApolloLink.split(
|
|
2079
|
+
- ({ query }) => {
|
|
2080
|
+
- const definition = getMainDefinition(query);
|
|
2081
|
+
- return (
|
|
2082
|
+
- definition.kind === 'OperationDefinition' &&
|
|
2083
|
+
- definition.operation === 'subscription'
|
|
2084
|
+
- );
|
|
2085
|
+
- return
|
|
2086
|
+
- },
|
|
2087
|
+
+ ({ operationType }) => {
|
|
2088
|
+
+ return operationType === OperationTypeNode.SUBSCRIPTION;
|
|
2089
|
+
+ },
|
|
2090
|
+
conditionTrueLink,
|
|
2091
|
+
conditionFalseLink,
|
|
2092
|
+
);
|
|
2093
|
+
```
|
|
2094
|
+
|
|
2095
|
+
- [#12633](https://github.com/apollographql/apollo-client/pull/12633) [`9bfb51f`](https://github.com/apollographql/apollo-client/commit/9bfb51fdbca69560da71f9012c74ee172b6c2b69) Thanks [@phryneas](https://github.com/phryneas)! - `ObservableQuery.refetch` and `ObservableQuery.reobserve` and the `execute` function of `useLazyQuery` now return a
|
|
2096
|
+
`ResultPromise` with an additional `.retain` method.
|
|
2097
|
+
If this method is called, the underlying network operation will be kept running even if the `ObservableQuery` itself does
|
|
2098
|
+
not require the result anymore, and the Promise will resolve with the final result instead of resolving with an intermediate
|
|
2099
|
+
result in the case of early cancellation.
|
|
2100
|
+
|
|
2101
|
+
- [#12649](https://github.com/apollographql/apollo-client/pull/12649) [`0be92ad`](https://github.com/apollographql/apollo-client/commit/0be92ad51cf8de444fa1cc507bab2c21d230a44e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a new `dataState` property that determines the completeness of the `data` property. `dataState` helps narrow the type of `data`. `dataState` is now emitted from `ObservableQuery` and returned from all React hooks that return a `data` property.
|
|
2102
|
+
|
|
2103
|
+
The `dataState` values are:
|
|
2104
|
+
|
|
2105
|
+
- `empty`: No data could be fulfilled from the cache or the result is incomplete. `data` is `undefined`.
|
|
2106
|
+
- `partial`: Some data could be fulfilled from the cache but `data` is incomplete. This is only possible when `returnPartialData` is `true`.
|
|
2107
|
+
- `streaming`: `data` is incomplete as a result of a deferred query and the result is still streaming in.
|
|
2108
|
+
- `complete`: `data` is a fully satisfied query result fulfilled either from the cache or network.
|
|
2109
|
+
|
|
2110
|
+
Example:
|
|
2111
|
+
|
|
2112
|
+
```ts
|
|
2113
|
+
const { data, dataState } = useQuery<TData>(query);
|
|
2114
|
+
|
|
2115
|
+
if (dataState === "empty") {
|
|
2116
|
+
expectTypeOf(data).toEqualTypeOf<undefined>();
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2119
|
+
if (dataState === "partial") {
|
|
2120
|
+
expectTypeOf(data).toEqualTypeOf<DeepPartial<TData>>();
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
if (dataState === "streaming") {
|
|
2124
|
+
expectTypeOf(data).toEqualTypeOf<TData>();
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
if (dataState === "complete") {
|
|
2128
|
+
expectTypeOf(data).toEqualTypeOf<TData>();
|
|
2129
|
+
}
|
|
2130
|
+
```
|
|
2131
|
+
|
|
2132
|
+
</details>
|
|
2133
|
+
<details>
|
|
2134
|
+
|
|
2135
|
+
<summary>
|
|
2136
|
+
|
|
2137
|
+
### Patch Changes
|
|
2138
|
+
|
|
2139
|
+
</summary>
|
|
2140
|
+
|
|
2141
|
+
- [#12574](https://github.com/apollographql/apollo-client/pull/12574) [`0098ec9`](https://github.com/apollographql/apollo-client/commit/0098ec9f860e4e08a2070823f723dce401ae588a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Export `gql` from the `@apollo/client/react` entrypoint.
|
|
2142
|
+
|
|
2143
|
+
- [#12631](https://github.com/apollographql/apollo-client/pull/12631) [`b147cac`](https://github.com/apollographql/apollo-client/commit/b147cac5c96c44bfc3deb72c12c7521981584c12) Thanks [@phryneas](https://github.com/phryneas)! - When updating `skip` from `false` to `true` in `useQuery`, retain `data` if it is available rather than setting it to `undefined`.
|
|
2144
|
+
|
|
2145
|
+
- [#12822](https://github.com/apollographql/apollo-client/pull/12822) [`103664d`](https://github.com/apollographql/apollo-client/commit/103664dc93c0a7097eaec1a5144e769eb4fb7a31) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `HttpLink.ContextOptions` and `BatchHttpLink.ContextOptions` include `ClientAwarenessLink.ContextOptions`.
|
|
2146
|
+
|
|
2147
|
+
- [#12291](https://github.com/apollographql/apollo-client/pull/12291) [`ae5d06a`](https://github.com/apollographql/apollo-client/commit/ae5d06ac45ca6584d3c79aa417dae22f37a7d3b6) Thanks [@phryneas](https://github.com/phryneas)! - Remove deprecated `resetApolloContext` export
|
|
2148
|
+
|
|
2149
|
+
- [#12728](https://github.com/apollographql/apollo-client/pull/12728) [`07a0c8c`](https://github.com/apollographql/apollo-client/commit/07a0c8c52774793b254ecc91e5d4632bfdf48093) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Export the `IgnoreModifier` type from `@apollo/client/cache`.
|
|
2150
|
+
|
|
2151
|
+
- [#12776](https://github.com/apollographql/apollo-client/pull/12776) [`bce9b74`](https://github.com/apollographql/apollo-client/commit/bce9b7448a226b109cbe8f14911503fb09f37825) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `cache.watchFragment` now returns an `Unmasked<TData>` result since `cache.watchFragment` does not mask fragment spreads.
|
|
2152
|
+
|
|
2153
|
+
- [#12735](https://github.com/apollographql/apollo-client/pull/12735) [`5159880`](https://github.com/apollographql/apollo-client/commit/51598808851e16af722baaefbd1f90534332e07a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Change the `unsafePreviousData` argument on `UpdateQueryMapFn` and `SubscribeToMoreQueryFn` to a `DeepPartial` since the result may contain partial data.
|
|
2154
|
+
|
|
2155
|
+
- [#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.
|
|
2156
|
+
|
|
2157
|
+
- [#12748](https://github.com/apollographql/apollo-client/pull/12748) [`e1ca85e`](https://github.com/apollographql/apollo-client/commit/e1ca85eab181d8e16d945e849dfb13352902f197) Thanks [@phryneas](https://github.com/phryneas)! - Fix a bug where the new `operationType` property wasn't passed into `operation`.
|
|
2158
|
+
|
|
2159
|
+
- [#12709](https://github.com/apollographql/apollo-client/pull/12709) [`9d42e2a`](https://github.com/apollographql/apollo-client/commit/9d42e2a08d3ddfdfdfc7ac65bd66985da5642e7d) Thanks [@phryneas](https://github.com/phryneas)! - Remove these incremental-format-specific types:
|
|
2160
|
+
|
|
2161
|
+
- `ExecutionPatchIncrementalResult`
|
|
2162
|
+
- `ExecutionPatchInitialResult`
|
|
2163
|
+
- `ExecutionPatchResult`
|
|
2164
|
+
- `IncrementalPayload`
|
|
2165
|
+
- `Path`
|
|
2166
|
+
|
|
2167
|
+
- [#12618](https://github.com/apollographql/apollo-client/pull/12618) [`e4a3ecf`](https://github.com/apollographql/apollo-client/commit/e4a3ecfe50bc5b462067574a0ffb1951549fb60f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove code that strips `@client` fields in `HttpLink` and `BatchHttpLink`. This was unused code since core handles removing `@client` fields and should have no observable change.
|
|
2168
|
+
|
|
2169
|
+
- [#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.
|
|
2170
|
+
|
|
2171
|
+
- [#12677](https://github.com/apollographql/apollo-client/pull/12677) [`94e58ed`](https://github.com/apollographql/apollo-client/commit/94e58ed75fc547ff037d9efeeba929fd61b20c4c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Downgrade minimum supported `rxjs` peer dependency version to 7.3.0.
|
|
2172
|
+
|
|
2173
|
+
- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `variables` option used with various APIs are now enforced more consistently across the client when `TVariables` contains required variables. If required `variables` are not provided, TypeScript will now complain that it requires a `variables` option.
|
|
2174
|
+
|
|
2175
|
+
This change affects the following APIs:
|
|
2176
|
+
|
|
2177
|
+
- `client.query`
|
|
2178
|
+
- `client.mutate`
|
|
2179
|
+
- `client.subscribe`
|
|
2180
|
+
- `client.watchQuery`
|
|
2181
|
+
- `useBackgroundQuery`
|
|
2182
|
+
- `useQuery`
|
|
2183
|
+
- `useSubscription`
|
|
2184
|
+
- `useSuspenseQuery`
|
|
2185
|
+
|
|
2186
|
+
- [#12451](https://github.com/apollographql/apollo-client/pull/12451) [`77e1b13`](https://github.com/apollographql/apollo-client/commit/77e1b133bdba32c67b5a840090dbacb16282dee9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Default `TVariables` generic type to `OperationVariables` instead of `any` throughout the client in areas that did not yet have the default as such.
|
|
2187
|
+
|
|
2188
|
+
- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix type of `variables` returned from `useLazyQuery`. When `called` is `false`, `variables` is now `Partial<TVariables>` instead of `TVariables`.
|
|
2189
|
+
|
|
2190
|
+
- [#12402](https://github.com/apollographql/apollo-client/pull/12402) [`903c3ef`](https://github.com/apollographql/apollo-client/commit/903c3ef9f77280492c298b4d8e5f96f110e3cda1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Use an an empty object (`{}`) rather than an object with `null` prototype (`Object.create(null)`) in all areas that instantiate objects.
|
|
2191
|
+
|
|
2192
|
+
- [#12734](https://github.com/apollographql/apollo-client/pull/12734) [`037979d`](https://github.com/apollographql/apollo-client/commit/037979dc47ffb7125429707471d901a08db49283) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't warn about a missing resolver if a `@client` does not have a configured resolver. It is possible the cache contains a `read` function for the field and the warning added confusion.
|
|
2193
|
+
|
|
2194
|
+
Note that `read` functions without a defined resolver will receive the `existing` argument as `null` instead of `undefined` even when data hasn't been written to the cache. This is because `LocalState` sets a default value of `null` when a resolver is not defined to ensure that the field contains a value in case a `read` function is not defined rather than omitting the field entirely.
|
|
2195
|
+
|
|
2196
|
+
- [#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`.
|
|
2197
|
+
|
|
2198
|
+
- [#12370](https://github.com/apollographql/apollo-client/pull/12370) [`0517163`](https://github.com/apollographql/apollo-client/commit/05171634404a44231329bf63eee960db52d08b25) Thanks [@phryneas](https://github.com/phryneas)! - `InMemoryCache`: Fields with an empty argument object are now saved the same way as fields without arguments.
|
|
2199
|
+
|
|
2200
|
+
Previously, it was possible that the reponses for these two queries would be stored differently in the cache:
|
|
2201
|
+
|
|
2202
|
+
```gql
|
|
2203
|
+
query PlainAccess {
|
|
2204
|
+
myField
|
|
2205
|
+
}
|
|
2206
|
+
```
|
|
2207
|
+
|
|
2208
|
+
would be stored as `myField`
|
|
2209
|
+
and
|
|
2210
|
+
|
|
2211
|
+
```gql
|
|
2212
|
+
query AccessWithoutOptionalArgument($optional: String) {
|
|
2213
|
+
myField(optional: $optional)
|
|
2214
|
+
}
|
|
2215
|
+
```
|
|
2216
|
+
|
|
2217
|
+
would be stored as `myField({"optional":"Foo"})` if called with `{optional: "Foo"}` and as `myField({})` if called without the optional argument.
|
|
2218
|
+
|
|
2219
|
+
The cases `myField` and `myField({})` are equivalent from the perspective of a GraphQL server, and so in the future both of these will be stored as `myField` in the cache.
|
|
2220
|
+
|
|
2221
|
+
- [#12385](https://github.com/apollographql/apollo-client/pull/12385) [`cad5117`](https://github.com/apollographql/apollo-client/commit/cad511723a1b8b0ac2042cf49435f7affb0dc4e4) Thanks [@phryneas](https://github.com/phryneas)! - \* dropped the deprecated `DEV` export from `@apollo/client/utilities` and `@apollo/client/utilities/globals`
|
|
2222
|
+
|
|
2223
|
+
- moved the `__DEV__` export from `@apollo/client/utilities/globals` to `@apollo/client/utilities/environment`
|
|
2224
|
+
- moved the `invariant`, `newInvariantError` and `InvariantError` exports from `@apollo/client/utilities/globals` to `@apollo/client/utilities/invariant`
|
|
2225
|
+
|
|
2226
|
+
- [#12709](https://github.com/apollographql/apollo-client/pull/12709) [`9d42e2a`](https://github.com/apollographql/apollo-client/commit/9d42e2a08d3ddfdfdfc7ac65bd66985da5642e7d) Thanks [@phryneas](https://github.com/phryneas)! - Slightly rework multipart response parsing.
|
|
2227
|
+
|
|
2228
|
+
This removes last incremental-protocol-specific details from `HttpLink` and `BatchHttpLink`.
|
|
2229
|
+
|
|
2230
|
+
- [#12824](https://github.com/apollographql/apollo-client/pull/12824) [`0506f12`](https://github.com/apollographql/apollo-client/commit/0506f12936d3fe7c840e5d56a5efa20bbce1525e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `RetryLink` now emits a `next` event instead of an `error` event when encountering a protocol errors for multipart subscriptions when the operation is not retried. This ensures the observable notification remains the same as when `RetryLink` is not used.
|
|
2231
|
+
|
|
2232
|
+
- [#12487](https://github.com/apollographql/apollo-client/pull/12487) [`b695e5e`](https://github.com/apollographql/apollo-client/commit/b695e5e10ab0eb47948e914b610f67c40267349e) Thanks [@phryneas](https://github.com/phryneas)! - `useQuery` with `ssr: false` - previously, `skip` had a higher priortity than `ssr: false` while `ssr: false` had a higher priority than `fetchPolicy: "standby"` (which is roughly equivalent to `skip`).
|
|
2233
|
+
|
|
2234
|
+
This priority has been adjusted so now both `skip` and `fetchPolicy: "standby"` have a higher priority than `ssr: false` and will return `loading: false`, while `ssr: false` will only come after those and will return `loading: true` if those are not set.
|
|
2235
|
+
|
|
2236
|
+
- [#12725](https://github.com/apollographql/apollo-client/pull/12725) [`89ac725`](https://github.com/apollographql/apollo-client/commit/89ac7256a34b3b04fe2cf83937b5494b375ce36d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Export `getMainDefinition` from `@apollo/client/utilities`.
|
|
2237
|
+
|
|
2238
|
+
- [#12716](https://github.com/apollographql/apollo-client/pull/12716) [`ad88976`](https://github.com/apollographql/apollo-client/commit/ad889766882b4817e50e8e819044bc5ed772173b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump only to release latest as `rc`.
|
|
2239
|
+
|
|
2240
|
+
- [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where passing `onError` to `useMutation` would resolve the promise returned by the `mutate` function instead of rejecting when using an `errorPolicy` of `none`.
|
|
2241
|
+
|
|
2242
|
+
- [#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.
|
|
2243
|
+
|
|
2244
|
+
- [#12432](https://github.com/apollographql/apollo-client/pull/12432) [`c7c2f61`](https://github.com/apollographql/apollo-client/commit/c7c2f6122c874eed16d5621be26992f86d9756eb) Thanks [@phryneas](https://github.com/phryneas)! - ObservableQuery: implement the `rxjs` `InteropObservable` interface to ensure `from(observableQuery)` stays possible
|
|
2245
|
+
|
|
2246
|
+
- [#12775](https://github.com/apollographql/apollo-client/pull/12775) [`454ec78`](https://github.com/apollographql/apollo-client/commit/454ec78b751853da07243174a6f9bdc4535e7e8f) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Don't export `gql` from `@apollo/client/react` entrypoint. Import from `@apollo/client` instead.
|
|
2247
|
+
|
|
2248
|
+
- [#12385](https://github.com/apollographql/apollo-client/pull/12385) [`cad5117`](https://github.com/apollographql/apollo-client/commit/cad511723a1b8b0ac2042cf49435f7affb0dc4e4) Thanks [@phryneas](https://github.com/phryneas)! - `@apollo/client`, `@apollo/client/core` and `@apollo/client/cache` no longer export an empty `Cache` runtime object. This is meant to be a type-only namespace.
|
|
2249
|
+
|
|
2250
|
+
- [#12513](https://github.com/apollographql/apollo-client/pull/12513) [`9c3207c`](https://github.com/apollographql/apollo-client/commit/9c3207c44ddad1f8b845c09495d6c070ace8de7b) Thanks [@phryneas](https://github.com/phryneas)! - Removed the `parser` cache. The functionality has been replaced in a way that doesn't need caching.
|
|
2251
|
+
|
|
2252
|
+
- [#12465](https://github.com/apollographql/apollo-client/pull/12465) [`a132163`](https://github.com/apollographql/apollo-client/commit/a1321637cafb4023d6df416e9467294114d8346b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Rename all React hook result types and options. These types have all moved under a namespace that matches the hook name. For example, `useQuery` exports `useQuery.Options` and `useQuery.Result` types. As such, the old hook types have been deprecated and will be removed in v5.
|
|
2253
|
+
|
|
2254
|
+
- [#12739](https://github.com/apollographql/apollo-client/pull/12739) [`b184754`](https://github.com/apollographql/apollo-client/commit/b184754d08810df9a7838615990e90a960966037) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix type of `error` argument on the `onError` option for `subscribeToMore` to `ErrorLike`.
|
|
2255
|
+
|
|
2256
|
+
- [#12572](https://github.com/apollographql/apollo-client/pull/12572) [`3dc50e6`](https://github.com/apollographql/apollo-client/commit/3dc50e6476dcedf82ed3856bf9f4571a32a760a6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Adjust `useMutation` types to better handle required variables. When required variables are missing, TypeScript will now complain if they are not provided either to the hook or the returned `mutate` function. Providing required variables to `useMutation` will make them optional in the returned `mutate` function.
|
|
2257
|
+
|
|
2258
|
+
- [#12819](https://github.com/apollographql/apollo-client/pull/12819) [`7ff548d`](https://github.com/apollographql/apollo-client/commit/7ff548dab0f38bfe315fce6cc51105c93d112271) Thanks [@jerelmiller](https://github.com/jerelmiller)! - update type of `HttpLink.Options.fetchOptions` to `RequestInit`
|
|
2259
|
+
|
|
2260
|
+
- [#12761](https://github.com/apollographql/apollo-client/pull/12761) [`db6f7c3`](https://github.com/apollographql/apollo-client/commit/db6f7c3823aaf58ee403ef45f0e817241b1c56a2) Thanks [@phryneas](https://github.com/phryneas)! - Deprecate second argument to `readFragment` and `readQuery` - `optimistic` should be passed as part of the object in the first argument instead.
|
|
2261
|
+
|
|
2262
|
+
- [#12820](https://github.com/apollographql/apollo-client/pull/12820) [`fba3d9e`](https://github.com/apollographql/apollo-client/commit/fba3d9ec96cce9f1a89908e4f33361e27d1f52b4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The `fetchOptions` option provided to `HttpLink` and `BatchHttpLink` is now `RequestInit` instead of `any`. The `credentials` option is now a `RequestCredentials` type instead of a `string`.
|
|
2263
|
+
|
|
2264
|
+
- [#12650](https://github.com/apollographql/apollo-client/pull/12650) [`2a32ac6`](https://github.com/apollographql/apollo-client/commit/2a32ac6d38de2be0be6891a969ee4f5e3bbca629) Thanks [@phryneas](https://github.com/phryneas)! - Fix a situation where a passed-in `AbortSignal` would override internal unsubscription cancellation behaviour.
|
|
2265
|
+
|
|
2266
|
+
- [#12562](https://github.com/apollographql/apollo-client/pull/12562) [`90bf0e6`](https://github.com/apollographql/apollo-client/commit/90bf0e61516a382182f212ac8ab891099e2eb009) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `client.query` no longer supports `notifyOnNetworkStatusChange` in options. An error will be thrown if this option is set. The effects of this option were not observable by `client.query` since `client.query` emits a single result.
|
|
2267
|
+
|
|
2268
|
+
- [#12557](https://github.com/apollographql/apollo-client/pull/12557) [`51d26ae`](https://github.com/apollographql/apollo-client/commit/51d26ae631c6631a189c98ea9357b18e77a9a876) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Update format of the error message for `CombinedGraphQLErrors` and `CombinedProtocolErrors` to be more like v3.x.
|
|
2269
|
+
|
|
2270
|
+
```diff
|
|
2271
|
+
console.log(error.message);
|
|
2272
|
+
- `The GraphQL server returned with errors:
|
|
2273
|
+
- - Email not found
|
|
2274
|
+
- - Username already in use`
|
|
2275
|
+
+ `Email not found
|
|
2276
|
+
+ Username already in use`
|
|
2277
|
+
```
|
|
2278
|
+
|
|
2279
|
+
- [#12809](https://github.com/apollographql/apollo-client/pull/12809) [`e2a0be8`](https://github.com/apollographql/apollo-client/commit/e2a0be8c3f8b242706f90e0dcc022628992a8ae8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The individual `empty`, `concat`, `from` and `split` functions exported from `@apollo/client/link` are now deprecated in favor of using the static functions instead.
|
|
2280
|
+
|
|
2281
|
+
```diff
|
|
2282
|
+
import {
|
|
2283
|
+
ApolloLink,
|
|
2284
|
+
- concat,
|
|
2285
|
+
- empty,
|
|
2286
|
+
- from,
|
|
2287
|
+
- split,
|
|
2288
|
+
} from "@apollo/client/link";
|
|
2289
|
+
|
|
2290
|
+
- concat(first, second);
|
|
2291
|
+
+ ApolloLink.concat(first, second);
|
|
2292
|
+
|
|
2293
|
+
- empty();
|
|
2294
|
+
+ ApolloLink.empty();
|
|
2295
|
+
|
|
2296
|
+
- from([first, second]);
|
|
2297
|
+
+ ApolloLink.from([first, second]);
|
|
2298
|
+
|
|
2299
|
+
- split(
|
|
2300
|
+
+ ApolloLink.split(
|
|
2301
|
+
(operation) => /* */,
|
|
2302
|
+
first,
|
|
2303
|
+
second
|
|
2304
|
+
);
|
|
2305
|
+
```
|
|
2306
|
+
|
|
2307
|
+
- [#12700](https://github.com/apollographql/apollo-client/pull/12700) [`8e96e08`](https://github.com/apollographql/apollo-client/commit/8e96e0862c306df17c09c232704041196a72a466) Thanks [@phryneas](https://github.com/phryneas)! - The incremental delivery (`@defer` support) implementation is now pluggable.
|
|
2308
|
+
|
|
2309
|
+
`ApolloClient` now per default ships without an incremental format implementation
|
|
2310
|
+
and allows you to swap in the format that you want to use.
|
|
2311
|
+
|
|
2312
|
+
Usage looks like this:
|
|
2313
|
+
|
|
2314
|
+
```ts
|
|
2315
|
+
import {
|
|
2316
|
+
// this is the default
|
|
2317
|
+
NotImplementedHandler,
|
|
2318
|
+
// this implements the `@defer` transport format that ships with Apollo Router
|
|
2319
|
+
Defer20220824Handler,
|
|
2320
|
+
// this implements the `@defer` transport format that ships with GraphQL 17.0.0-alpha.2
|
|
2321
|
+
GraphQL17Alpha2Handler,
|
|
2322
|
+
} from "@apollo/client/incremental";
|
|
2323
|
+
|
|
2324
|
+
const client = new ApolloClient({
|
|
2325
|
+
cache: new InMemoryCache({
|
|
2326
|
+
/*...*/
|
|
2327
|
+
}),
|
|
2328
|
+
link: new HttpLink({
|
|
2329
|
+
/*...*/
|
|
2330
|
+
}),
|
|
2331
|
+
incrementalHandler: new Defer20220824Handler(),
|
|
2332
|
+
});
|
|
2333
|
+
```
|
|
2334
|
+
|
|
2335
|
+
We will add handlers for other response formats that can be swapped this way
|
|
2336
|
+
during the lifetime of Apollo Client 4.0.
|
|
2337
|
+
|
|
2338
|
+
- [#12454](https://github.com/apollographql/apollo-client/pull/12454) [`925548a`](https://github.com/apollographql/apollo-client/commit/925548a9baadb19b7bb78ee84c6f9e64b55c39e9) Thanks [@phryneas](https://github.com/phryneas)! - Fix up the 4.0 CommonJS build
|
|
2339
|
+
|
|
2340
|
+
- [#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`.
|
|
2341
|
+
|
|
2342
|
+
- [#12631](https://github.com/apollographql/apollo-client/pull/12631) [`b147cac`](https://github.com/apollographql/apollo-client/commit/b147cac5c96c44bfc3deb72c12c7521981584c12) Thanks [@phryneas](https://github.com/phryneas)! - The `error` property is no longer present when `skip` is `true` in `useQuery`.
|
|
2343
|
+
|
|
2344
|
+
- [#12559](https://github.com/apollographql/apollo-client/pull/12559) [`49ace0e`](https://github.com/apollographql/apollo-client/commit/49ace0e2119b7fd5997dcf051002ebd4ba2e0bc4) Thanks [@jerelmiller](https://github.com/jerelmiller)! - `ObservableQuery.variables` has been updated to return `TVariables` rather than `TVariables | undefined`. This is more consistent with the runtime value where an empty object (`{}`) will be returned when the `variables` option is not provided.
|
|
2345
|
+
|
|
2346
|
+
- [#12823](https://github.com/apollographql/apollo-client/pull/12823) [`19e315e`](https://github.com/apollographql/apollo-client/commit/19e315e316ae458913f4d11961b0a2a365df0a19) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix the type of the argument for the `sha256` function for `PersistedQueryLink` from `...any[]` to `string`.
|
|
2347
|
+
|
|
2348
|
+
- [#12729](https://github.com/apollographql/apollo-client/pull/12729) [`699c830`](https://github.com/apollographql/apollo-client/commit/699c8305639ff69bab36fd2214defbe1ac6f0b18) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `useQuery` rerenders when `notifyOnNetworkStatusChange` is `false` and a `refetch` that changes variables returns a result deeply equal to previous variables.
|
|
2349
|
+
|
|
2350
|
+
- [#12475](https://github.com/apollographql/apollo-client/pull/12475) [`3de63eb`](https://github.com/apollographql/apollo-client/commit/3de63ebcdf95a87adc31e6b4a39cae5391ed945a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where additional response properties were returned on the result returned from `client.mutate`, such as `@defer` payload fields. These properties are now stripped out to correspond to the TypeScript type.
|
|
2351
|
+
|
|
2352
|
+
- [#12821](https://github.com/apollographql/apollo-client/pull/12821) [`223a409`](https://github.com/apollographql/apollo-client/commit/223a4094f401bbe7fd3e4c249fa405843b63ba2e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add a deprecation warning to `WebSocketLink`.
|
|
2353
|
+
|
|
2354
|
+
- [#12782](https://github.com/apollographql/apollo-client/pull/12782) [`742b3a0`](https://github.com/apollographql/apollo-client/commit/742b3a0ed65d28818974e56225c86ab7e350e677) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Move `ApolloClient`, `ObservableQuery`, and `ApolloCache.watchFragment` method options and result types into namespaces. The old types are now exported as deprecated.
|
|
2355
|
+
|
|
2356
|
+
- [#12673](https://github.com/apollographql/apollo-client/pull/12673) [`cee90ab`](https://github.com/apollographql/apollo-client/commit/cee90abcd2a9c91c5fdf872cf2d1c12deaa6593e) Thanks [@phryneas](https://github.com/phryneas)! - Fixed a bug in `PersistedQueryLink` where the `persistedQuery` extension would still be sent after a `PersistedQueryNotSupported` if `includeExtensions` was enabled on `HttpLink`.
|
|
2357
|
+
|
|
2358
|
+
</details>
|
|
2359
|
+
|
|
2360
|
+
## 4.0.0-rc.13
|
|
2361
|
+
|
|
2362
|
+
### Major Changes
|
|
2363
|
+
|
|
2364
|
+
- [#12850](https://github.com/apollographql/apollo-client/pull/12850) [`268cd80`](https://github.com/apollographql/apollo-client/commit/268cd800a2d73305c0df8dd38b6bd1cee98f0fec) Thanks [@phryneas](https://github.com/phryneas)! - Introduce a versioning policy.
|
|
2365
|
+
|
|
2366
|
+
## 4.0.0-rc.12
|
|
2367
|
+
|
|
2368
|
+
### Minor Changes
|
|
2369
|
+
|
|
2370
|
+
- [#12838](https://github.com/apollographql/apollo-client/pull/12838) [`b005561`](https://github.com/apollographql/apollo-client/commit/b0055613c1f4837e994d2d0756348d553e2f302f) Thanks [@phryneas](https://github.com/phryneas)! - Add an entrypoint at `@apollo/client/v4-migration` that includes removed values and types. Each export includes doc blocks on how to migrate away from the removed type.
|
|
2371
|
+
|
|
2372
|
+
## 4.0.0-rc.11
|
|
2373
|
+
|
|
2374
|
+
### Major Changes
|
|
2375
|
+
|
|
2376
|
+
- [#12840](https://github.com/apollographql/apollo-client/pull/12840) [`83e132a`](https://github.com/apollographql/apollo-client/commit/83e132ab1bacb3293da61dd4519379e36a1fb090) Thanks [@phryneas](https://github.com/phryneas)! - If you use an incremental delivery handler, you now have to explicitly opt into adding the chunk types to the `ApolloLink.Result` type.
|
|
2377
|
+
|
|
2378
|
+
```ts title="apollo-client.d.ts
|
|
2379
|
+
import { Defer20220824Handler } from "@apollo/client/incremental";
|
|
2380
|
+
|
|
2381
|
+
declare module "@apollo/client" {
|
|
2382
|
+
export interface TypeOverrides extends Defer20220824Handler.TypeOverrides {}
|
|
2383
|
+
}
|
|
2384
|
+
```
|
|
2385
|
+
|
|
2386
|
+
- [#12841](https://github.com/apollographql/apollo-client/pull/12841) [`65b503f`](https://github.com/apollographql/apollo-client/commit/65b503fe4bfcf942e8f66f36f622f5f6448d6731) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the `DataMasking` interface exported from `@apollo/client` and `@apollo/client/masking`.
|
|
2387
|
+
|
|
2388
|
+
## 4.0.0-rc.10
|
|
2389
|
+
|
|
2390
|
+
### Major Changes
|
|
2391
|
+
|
|
2392
|
+
- [#12837](https://github.com/apollographql/apollo-client/pull/12837) [`7c49fdc`](https://github.com/apollographql/apollo-client/commit/7c49fdce2f40571d92c83602bbb1b5bd891f626b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - You must now opt in to use GraphQL Codegen data masking types when using Apollo Client's data masking feature. By default, Apollo Client now uses an identity type to apply to masked/unmasked types.
|
|
2393
|
+
|
|
2394
|
+
If you're using GraphQL Codegen to generate masked types, opt into the GraphQL Codegen masked types using declaration merging on the `TypeOverides` interface.
|
|
2395
|
+
|
|
2396
|
+
```ts title="apollo-client.d.ts
|
|
2397
|
+
import { GraphQLCodegenDataMasking } from "@apollo/client/masking";
|
|
2398
|
+
|
|
2399
|
+
declare module "@apollo/client" {
|
|
2400
|
+
export interface TypeOverrides
|
|
2401
|
+
extends GraphQLCodegenDataMasking.TypeOverrides {}
|
|
2402
|
+
}
|
|
2403
|
+
```
|
|
2404
|
+
|
|
2405
|
+
- [#12837](https://github.com/apollographql/apollo-client/pull/12837) [`7c49fdc`](https://github.com/apollographql/apollo-client/commit/7c49fdce2f40571d92c83602bbb1b5bd891f626b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - The types mode for data masking has been removed. Adding a types mode to the `DataMasking` interface has no effect. Remove the `mode` key in the module where you declare the `DataMasking` type for the `@apollo/client` module.
|
|
2406
|
+
|
|
2407
|
+
As a result, the `Masked` and `MaskedDocumentNode` types have also been removed since these have no effect when types are preserved.
|
|
2408
|
+
|
|
2409
|
+
## 4.0.0-rc.9
|
|
2410
|
+
|
|
2411
|
+
### Minor Changes
|
|
2412
|
+
|
|
2413
|
+
- [#12828](https://github.com/apollographql/apollo-client/pull/12828) [`81b03d8`](https://github.com/apollographql/apollo-client/commit/81b03d86ad7e7384124708477829bcbf63d4fa2c) Thanks [@phryneas](https://github.com/phryneas)! - `invariant.error` will now also log in production builds, not only dev builds
|
|
2414
|
+
|
|
2415
|
+
### Patch Changes
|
|
2416
|
+
|
|
2417
|
+
- [#12822](https://github.com/apollographql/apollo-client/pull/12822) [`103664d`](https://github.com/apollographql/apollo-client/commit/103664dc93c0a7097eaec1a5144e769eb4fb7a31) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `HttpLink.ContextOptions` and `BatchHttpLink.ContextOptions` include `ClientAwarenessLink.ContextOptions`.
|
|
2418
|
+
|
|
2419
|
+
- [#12650](https://github.com/apollographql/apollo-client/pull/12650) [`2a32ac6`](https://github.com/apollographql/apollo-client/commit/2a32ac6d38de2be0be6891a969ee4f5e3bbca629) Thanks [@phryneas](https://github.com/phryneas)! - Fix a situation where a passed-in `AbortSignal` would override internal unsubscription cancellation behaviour.
|
|
2420
|
+
|
|
3
2421
|
## 4.0.0-rc.8
|
|
4
2422
|
|
|
5
2423
|
### Major Changes
|
|
@@ -2155,6 +4573,76 @@
|
|
|
2155
4573
|
|
|
2156
4574
|
- [#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`.
|
|
2157
4575
|
|
|
4576
|
+
## 3.14.0
|
|
4577
|
+
|
|
4578
|
+
### Minor Changes
|
|
4579
|
+
|
|
4580
|
+
- [#12752](https://github.com/apollographql/apollo-client/pull/12752) [`8b779b4`](https://github.com/apollographql/apollo-client/commit/8b779b428b9dc9dad3e78f02bba6646ff415631d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings to remaining APIs changed in Apollo Client 4.0.
|
|
4581
|
+
|
|
4582
|
+
- [#12746](https://github.com/apollographql/apollo-client/pull/12746) [`0bcd2f4`](https://github.com/apollographql/apollo-client/commit/0bcd2f4ead372eb5928bbd5c00b0bd48e497a5e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add warnings and deprecations for options and methods for all React APIs.
|
|
4583
|
+
|
|
4584
|
+
- [#12751](https://github.com/apollographql/apollo-client/pull/12751) [`567cad8`](https://github.com/apollographql/apollo-client/commit/567cad8fcc30ac3b82560abc24970d33f160622e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `@deprecated` tags to all properties returned from any query API (e.g. `client.query`, `observableQuery.refetch`, etc.), `client.mutate`, and `client.subscribe` that are no longer available in Apollo Client 4.0.
|
|
4585
|
+
|
|
4586
|
+
- [#12746](https://github.com/apollographql/apollo-client/pull/12746) [`0bcd2f4`](https://github.com/apollographql/apollo-client/commit/0bcd2f4ead372eb5928bbd5c00b0bd48e497a5e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `preloadQuery.toPromise(queryRef)` as a replacement for `queryRef.toPromise()`. `queryRef.toPromise()` has been removed in Apollo Client 4.0 in favor of `preloadQuery.toPromise` and is now considered deprecated.
|
|
4587
|
+
|
|
4588
|
+
- [#12736](https://github.com/apollographql/apollo-client/pull/12736) [`ea89440`](https://github.com/apollographql/apollo-client/commit/ea8944013278060ef87dfa4de6663a21b5204880) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and deprecation warnings for `ApolloClient` options and methods.
|
|
4589
|
+
|
|
4590
|
+
- [#12763](https://github.com/apollographql/apollo-client/pull/12763) [`5de6a3d`](https://github.com/apollographql/apollo-client/commit/5de6a3d3189afa2a7c3bb2eb08d3c4394ae4a16d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump only to release latest as `rc`.
|
|
4591
|
+
|
|
4592
|
+
- [#12459](https://github.com/apollographql/apollo-client/pull/12459) [`1c5a031`](https://github.com/apollographql/apollo-client/commit/1c5a0313d388945aeda93b2c1992ad77f4416fa1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Reset `addTypenameTransform` and `fragments` caches when calling `cache.gc()` only when `resetResultCache` is `true`.
|
|
4593
|
+
|
|
4594
|
+
- [#12743](https://github.com/apollographql/apollo-client/pull/12743) [`92ad409`](https://github.com/apollographql/apollo-client/commit/92ad4097e5c83e0a780ede20db34e9e63fb98e8b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings for `addTypename` in `InMemoryCache` and `MockedProvider`.
|
|
4595
|
+
|
|
4596
|
+
- [#12743](https://github.com/apollographql/apollo-client/pull/12743) [`92ad409`](https://github.com/apollographql/apollo-client/commit/92ad4097e5c83e0a780ede20db34e9e63fb98e8b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings for `canonizeResults`.
|
|
4597
|
+
|
|
4598
|
+
- [#12751](https://github.com/apollographql/apollo-client/pull/12751) [`567cad8`](https://github.com/apollographql/apollo-client/commit/567cad8fcc30ac3b82560abc24970d33f160622e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Warn when using a `standby` fetch policy with `client.query`.
|
|
4599
|
+
|
|
4600
|
+
### Patch Changes
|
|
4601
|
+
|
|
4602
|
+
- [#12750](https://github.com/apollographql/apollo-client/pull/12750) [`ecf3de1`](https://github.com/apollographql/apollo-client/commit/ecf3de1cc9a2cf3aaeba0c945909324b9e4b478a) Thanks [@phryneas](https://github.com/phryneas)! - Prevent field policies from overwriting/merging into supertype field policies.
|
|
4603
|
+
|
|
4604
|
+
## 3.14.0-rc.0
|
|
4605
|
+
|
|
4606
|
+
### Minor Changes
|
|
4607
|
+
|
|
4608
|
+
- [#12763](https://github.com/apollographql/apollo-client/pull/12763) [`5de6a3d`](https://github.com/apollographql/apollo-client/commit/5de6a3d3189afa2a7c3bb2eb08d3c4394ae4a16d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump only to release latest as `rc`.
|
|
4609
|
+
|
|
4610
|
+
## 3.14.0-alpha.1
|
|
4611
|
+
|
|
4612
|
+
### Minor Changes
|
|
4613
|
+
|
|
4614
|
+
- [#12752](https://github.com/apollographql/apollo-client/pull/12752) [`8b779b4`](https://github.com/apollographql/apollo-client/commit/8b779b428b9dc9dad3e78f02bba6646ff415631d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings to remaining APIs changed in Apollo Client 4.0.
|
|
4615
|
+
|
|
4616
|
+
- [#12751](https://github.com/apollographql/apollo-client/pull/12751) [`567cad8`](https://github.com/apollographql/apollo-client/commit/567cad8fcc30ac3b82560abc24970d33f160622e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `@deprecated` tags to all properties returned from any query API (e.g. `client.query`, `observableQuery.refetch`, etc.), `client.mutate`, and `client.subscribe` that are no longer available in Apollo Client 4.0.
|
|
4617
|
+
|
|
4618
|
+
- [#12751](https://github.com/apollographql/apollo-client/pull/12751) [`567cad8`](https://github.com/apollographql/apollo-client/commit/567cad8fcc30ac3b82560abc24970d33f160622e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Warn when using a `standby` fetch policy with `client.query`.
|
|
4619
|
+
|
|
4620
|
+
## 3.14.0-alpha.0
|
|
4621
|
+
|
|
4622
|
+
### Minor Changes
|
|
4623
|
+
|
|
4624
|
+
- [#12746](https://github.com/apollographql/apollo-client/pull/12746) [`0bcd2f4`](https://github.com/apollographql/apollo-client/commit/0bcd2f4ead372eb5928bbd5c00b0bd48e497a5e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add warnings and deprecations for options and methods for all React APIs.
|
|
4625
|
+
|
|
4626
|
+
- [#12746](https://github.com/apollographql/apollo-client/pull/12746) [`0bcd2f4`](https://github.com/apollographql/apollo-client/commit/0bcd2f4ead372eb5928bbd5c00b0bd48e497a5e1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add `preloadQuery.toPromise(queryRef)` as a replacement for `queryRef.toPromise()`. `queryRef.toPromise()` has been removed in Apollo Client 4.0 in favor of `preloadQuery.toPromise` and is now considered deprecated.
|
|
4627
|
+
|
|
4628
|
+
- [#12736](https://github.com/apollographql/apollo-client/pull/12736) [`ea89440`](https://github.com/apollographql/apollo-client/commit/ea8944013278060ef87dfa4de6663a21b5204880) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and deprecation warnings for `ApolloClient` options and methods.
|
|
4629
|
+
|
|
4630
|
+
- [#12459](https://github.com/apollographql/apollo-client/pull/12459) [`1c5a031`](https://github.com/apollographql/apollo-client/commit/1c5a0313d388945aeda93b2c1992ad77f4416fa1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Reset `addTypenameTransform` and `fragments` caches when calling `cache.gc()` only when `resetResultCache` is `true`.
|
|
4631
|
+
|
|
4632
|
+
- [#12743](https://github.com/apollographql/apollo-client/pull/12743) [`92ad409`](https://github.com/apollographql/apollo-client/commit/92ad4097e5c83e0a780ede20db34e9e63fb98e8b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings for `addTypename` in `InMemoryCache` and `MockedProvider`.
|
|
4633
|
+
|
|
4634
|
+
- [#12743](https://github.com/apollographql/apollo-client/pull/12743) [`92ad409`](https://github.com/apollographql/apollo-client/commit/92ad4097e5c83e0a780ede20db34e9e63fb98e8b) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add deprecations and warnings for `canonizeResults`.
|
|
4635
|
+
|
|
4636
|
+
### Patch Changes
|
|
4637
|
+
|
|
4638
|
+
- [#12750](https://github.com/apollographql/apollo-client/pull/12750) [`ecf3de1`](https://github.com/apollographql/apollo-client/commit/ecf3de1cc9a2cf3aaeba0c945909324b9e4b478a) Thanks [@phryneas](https://github.com/phryneas)! - Prevent field policies from overwriting/merging into supertype field policies.
|
|
4639
|
+
|
|
4640
|
+
## 3.13.9
|
|
4641
|
+
|
|
4642
|
+
### Patch Changes
|
|
4643
|
+
|
|
4644
|
+
- [#12804](https://github.com/apollographql/apollo-client/pull/12804) [`32c9aa9`](https://github.com/apollographql/apollo-client/commit/32c9aa9215fab72e9ab68ee71198ce242157f855) Thanks [@phryneas](https://github.com/phryneas)! - Fix a possible race condition on queries that were reobserved before they were subscribed to the first time.
|
|
4645
|
+
|
|
2158
4646
|
## 3.13.8
|
|
2159
4647
|
|
|
2160
4648
|
### Patch Changes
|