@apollo/client 4.3.0-alpha.1 → 4.3.0-alpha.3
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 +285 -0
- package/__cjs/cache/core/Scalar.cjs +36 -0
- package/__cjs/cache/core/Scalar.cjs.map +1 -0
- package/__cjs/cache/core/Scalar.d.cts +20 -0
- package/__cjs/cache/core/cache.cjs +8 -1
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +16 -0
- package/__cjs/cache/index.cjs +3 -1
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +3 -2
- package/__cjs/cache/inmemory/entityStore.cjs +45 -2
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +3 -0
- package/__cjs/cache/inmemory/helpers.d.cts +9 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +73 -4
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +35 -3
- package/__cjs/cache/inmemory/policies.cjs +8 -1
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +4 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +16 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +20 -4
- package/__cjs/cache/inmemory/writeToStore.cjs +10 -6
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +2 -2
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.cjs +1 -3
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryInfo.cjs +211 -37
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +5 -2
- package/__cjs/core/QueryManager.cjs +12 -18
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +1 -3
- package/__cjs/core/index.cjs +2 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +2 -2
- package/__cjs/invariantErrorCodes.cjs +12 -7
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +13 -13
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +1 -0
- package/__cjs/utilities/internal/collectSiblingFields.cjs +61 -0
- package/__cjs/utilities/internal/collectSiblingFields.cjs.map +1 -0
- package/__cjs/utilities/internal/collectSiblingFields.d.cts +21 -0
- package/__cjs/utilities/internal/getUnwrappedType.cjs +20 -0
- package/__cjs/utilities/internal/getUnwrappedType.cjs.map +1 -0
- package/__cjs/utilities/internal/getUnwrappedType.d.cts +8 -0
- package/__cjs/utilities/internal/index.cjs +10 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +6 -0
- package/__cjs/utilities/internal/isDeferredFragment.cjs +23 -0
- package/__cjs/utilities/internal/isDeferredFragment.cjs.map +1 -0
- package/__cjs/utilities/internal/isDeferredFragment.d.cts +4 -0
- package/__cjs/utilities/internal/isTypenameField.cjs +7 -0
- package/__cjs/utilities/internal/isTypenameField.cjs.map +1 -0
- package/__cjs/utilities/internal/isTypenameField.d.cts +3 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.cjs +3 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.cjs.map +1 -0
- package/__cjs/utilities/internal/types/IsLooselyEqual.d.cts +10 -0
- package/__cjs/utilities/policies/pagination.cjs.map +1 -1
- package/__cjs/utilities/policies/pagination.d.cts +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs +1 -0
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/version.cjs +1 -1
- package/cache/core/Scalar.d.ts +20 -0
- package/cache/core/Scalar.js +32 -0
- package/cache/core/Scalar.js.map +1 -0
- package/cache/core/cache.d.ts +16 -0
- package/cache/core/cache.js +8 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/index.d.ts +3 -2
- package/cache/index.js +1 -0
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +3 -0
- package/cache/inmemory/entityStore.js +46 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +9 -1
- package/cache/inmemory/inMemoryCache.d.ts +35 -3
- package/cache/inmemory/inMemoryCache.js +74 -5
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.d.ts +4 -1
- package/cache/inmemory/policies.js +8 -1
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +11 -2
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +20 -4
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +11 -7
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.js +2 -2
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +1 -3
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +5 -2
- package/core/QueryInfo.js +212 -38
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +1 -3
- package/core/QueryManager.js +12 -18
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +2 -2
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/invariantErrorCodes.js +12 -7
- package/package.json +1 -1
- package/react/hooks/useLazyQuery.d.ts +13 -13
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +13 -13
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/utilities/index.d.ts +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/internal/collectSiblingFields.d.ts +21 -0
- package/utilities/internal/collectSiblingFields.js +58 -0
- package/utilities/internal/collectSiblingFields.js.map +1 -0
- package/utilities/internal/getUnwrappedType.d.ts +8 -0
- package/utilities/internal/getUnwrappedType.js +17 -0
- package/utilities/internal/getUnwrappedType.js.map +1 -0
- package/utilities/internal/index.d.ts +6 -0
- package/utilities/internal/index.js +4 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/isDeferredFragment.d.ts +4 -0
- package/utilities/internal/isDeferredFragment.js +20 -0
- package/utilities/internal/isDeferredFragment.js.map +1 -0
- package/utilities/internal/isTypenameField.d.ts +3 -0
- package/utilities/internal/isTypenameField.js +4 -0
- package/utilities/internal/isTypenameField.js.map +1 -0
- package/utilities/internal/types/IsLooselyEqual.d.ts +10 -0
- package/utilities/internal/types/IsLooselyEqual.js +2 -0
- package/utilities/internal/types/IsLooselyEqual.js.map +1 -0
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/subscriptions/relay/index.js +1 -0
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/version.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,264 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 4.3.0-alpha.3
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#13324](https://github.com/apollographql/apollo-client/pull/13324) [`0abd8de`](https://github.com/apollographql/apollo-client/commit/0abd8de53a408c6b5925b2a909acde5179eaac46) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix the accuracy of `dataState` in complex incremental streaming scenarios, especially when combined with `returnPartialData: true`.
|
|
8
|
+
|
|
9
|
+
Prior to this change, all intermediate chunks used for both `@defer` and `@stream` directives returned a `dataState` of `streaming`, regardless of whether the actual data shape fit the definition of the `streaming` data state. The `streaming` data state represents an incomplete incremental response where the only holes in the data occur at `@defer` boundaries.
|
|
10
|
+
|
|
11
|
+
Let's use the following example of where the previous `dataState` fell down when combined with `returnPartialData`.
|
|
12
|
+
|
|
13
|
+
```gql
|
|
14
|
+
query GreetingQuery {
|
|
15
|
+
greeting {
|
|
16
|
+
message
|
|
17
|
+
... @defer {
|
|
18
|
+
recipient {
|
|
19
|
+
name
|
|
20
|
+
email
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
1. Scenario 1: partial data inside a `@defer` boundary written to the cache
|
|
28
|
+
|
|
29
|
+
Let's say the cache contained the following partial data:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
{
|
|
33
|
+
greeting: {
|
|
34
|
+
__typename: "Greeting",
|
|
35
|
+
recipient: {
|
|
36
|
+
__typename: "Person",
|
|
37
|
+
name: "John Doe",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
After the first chunk arrives from the server, the data looks like the following:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
{
|
|
47
|
+
greeting: {
|
|
48
|
+
__typename: "Greeting",
|
|
49
|
+
message: "Hello, John",
|
|
50
|
+
recipient: {
|
|
51
|
+
__typename: "Person",
|
|
52
|
+
name: "John Doe",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This data is not `complete` because `recipient.email` is missing. This data is also not `streaming` because the data requirements in the `@defer` boundary are partially fulfilled due to the existence of `recipient`. This could lead to runtime crashes on `recipient.email` if you use the existence of `recipient` to detect whether data in the `@defer` boundary has streamed in or not. This change now accurately reports this as `partial` to ensure the field is marked as a partial field in `recipient`.
|
|
59
|
+
|
|
60
|
+
2. Scenario 2: partial data written to the cache that fulfills the data requirements of the `@defer` boundary
|
|
61
|
+
|
|
62
|
+
Let's say the cache contained the following partial data:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
{
|
|
66
|
+
greeting: {
|
|
67
|
+
__typename: "Greeting",
|
|
68
|
+
recipient: {
|
|
69
|
+
__typename: "Person",
|
|
70
|
+
name: "John Doe",
|
|
71
|
+
email: "john@example.com",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
After the first chunk arrives from the server, the data looks like the following:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
{
|
|
81
|
+
greeting: {
|
|
82
|
+
__typename: "Greeting",
|
|
83
|
+
message: "Hello, John",
|
|
84
|
+
recipient: {
|
|
85
|
+
__typename: "Person",
|
|
86
|
+
name: "John Doe",
|
|
87
|
+
email: "john@example.com",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
In this case, the combination of the first chunk and the partial data in the cache now fulfills the data requirements of the query. Even though the server is still streaming data (`NetworkStatus.streaming`), we can report this as `dataState: "complete"` since it is safe to access data on all fields.
|
|
94
|
+
|
|
95
|
+
This change also means `@stream` queries by definition fulfill the data requirements of the query after the first chunk arrives since `@stream` operates on lists and contains no data holes. `@stream` queries now accurately report `dataState` as `complete` or `partial`, depending on whether the list mixes partial data with streamed list items.
|
|
96
|
+
|
|
97
|
+
As a result of this change, some cases where you'd previously see `dataState` reported as `"streaming"` are now reported as `partial` or `complete`.
|
|
98
|
+
|
|
99
|
+
If you use `dataState` to determine whether an incremental request is still in-flight, please use `networkStatus` instead to check for `NetworkStatus.streaming`. `dataState` is type narrowing feature and not intended to report the network status.
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- [#13324](https://github.com/apollographql/apollo-client/pull/13324) [`0abd8de`](https://github.com/apollographql/apollo-client/commit/0abd8de53a408c6b5925b2a909acde5179eaac46) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where field `read` functions were not applied to intermediate results while streaming `@defer` responses. `cache.diff` ran the `read` functions, but the transformed values were only applied to the emitted result when the updated cache result was considered complete. Intermediate chunks whose only holes were at `@defer` boundaries now correctly return the result of field `read` functions.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
new InMemoryCache({
|
|
107
|
+
typePolicies: {
|
|
108
|
+
Greeting: {
|
|
109
|
+
fields: {
|
|
110
|
+
message: {
|
|
111
|
+
read: (message) => message.toUpperCase(),
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// query GreetingQuery {
|
|
119
|
+
// greeting {
|
|
120
|
+
// message
|
|
121
|
+
// ... @defer {
|
|
122
|
+
// recipient { name }
|
|
123
|
+
// }
|
|
124
|
+
// }
|
|
125
|
+
// }
|
|
126
|
+
|
|
127
|
+
// First chunk previously returned:
|
|
128
|
+
// { greeting: { message: "Hello world" } }
|
|
129
|
+
//
|
|
130
|
+
// Now correctly returns while still streaming:
|
|
131
|
+
// { greeting: { message: "HELLO WORLD" } }
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- [#13324](https://github.com/apollographql/apollo-client/pull/13324) [`0abd8de`](https://github.com/apollographql/apollo-client/commit/0abd8de53a408c6b5925b2a909acde5179eaac46) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue with `@stream` queries when using `returnPartialData: true` where the streamed list was truncated after the first incremental chunk when the list contained partial cache data. The list is no longer truncated and partial list items are now retained as incremental chunks arrive. The `dataState` is now reported as `partial` until the server has streamed enough of the list so that each list item fully satisfies the query.
|
|
135
|
+
|
|
136
|
+
This change also updates `@stream` queries so that they reported with `dataState: "complete` instead of `"streaming"` since it is safe to access all fields in the response.
|
|
137
|
+
|
|
138
|
+
## 4.3.0-alpha.2
|
|
139
|
+
|
|
140
|
+
### Minor Changes
|
|
141
|
+
|
|
142
|
+
- [#13274](https://github.com/apollographql/apollo-client/pull/13274) [`7b10078`](https://github.com/apollographql/apollo-client/commit/7b10078f4bcd8d82890ca438bf7355677fe2f841) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Adds `Scalar.fromGraphQLScalarType` helper to create a `Scalar` instance from an existing graphql.js `GraphQLScalarType`.
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { GraphQLScalarType } from "graphql";
|
|
146
|
+
import { Scalar } from "@apollo/client";
|
|
147
|
+
|
|
148
|
+
const dateTimeScalarType = new GraphQLScalarType<Date, string>({
|
|
149
|
+
// ...
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const dateTimeScalar = Scalar.fromGraphQLScalarType(dateTimeScalarType, {
|
|
153
|
+
is: (value) => value instanceof Date,
|
|
154
|
+
});
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
- [#13252](https://github.com/apollographql/apollo-client/pull/13252) [`ed86234`](https://github.com/apollographql/apollo-client/commit/ed8623485683c38982c87278d1381412ef39a9db) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Adds the plumbing and types implementation for declaring custom scalars and configuring custom scalars in `InMemoryCache`.
|
|
158
|
+
|
|
159
|
+
You can declare custom scalar types with declaration merging on the `ApolloCache.Scalars` interface:
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
// apollo.d.ts
|
|
163
|
+
import "@apollo/client";
|
|
164
|
+
|
|
165
|
+
declare module "@apollo/client" {
|
|
166
|
+
namespace ApolloCache {
|
|
167
|
+
interface Scalars {
|
|
168
|
+
Date: { serialized: string; parsed: Date };
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
This enables the `scalars` option in `InMemoryCache`:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
import { Scalar } from "@apollo/client";
|
|
178
|
+
|
|
179
|
+
const cache = new InMemoryCache({
|
|
180
|
+
scalars: {
|
|
181
|
+
Date: new Scalar({
|
|
182
|
+
parse: (dateString) => new Date(dateString),
|
|
183
|
+
serialize: (date) => date.toISOString(),
|
|
184
|
+
is: (value) => value instanceof Date,
|
|
185
|
+
}),
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
- [#13259](https://github.com/apollographql/apollo-client/pull/13259) [`ccaf686`](https://github.com/apollographql/apollo-client/commit/ccaf6867be15e413f08594b54b3516003e28c108) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Adds a `scalar` option to `InMemoryCache` field policies that tells the cache which scalar to use when parsing or serializing the field value.
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
import { Scalar } from "@apollo/client";
|
|
194
|
+
|
|
195
|
+
new InMemoryCache({
|
|
196
|
+
scalars: {
|
|
197
|
+
DateTime: new Scalar({
|
|
198
|
+
parse: (dateString) => new Date(dateString),
|
|
199
|
+
serialize: (date) => date.toISOString(),
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
typePolicies: {
|
|
203
|
+
Event: {
|
|
204
|
+
fields: {
|
|
205
|
+
startTime: {
|
|
206
|
+
// Parse this field using the DateTime scalar
|
|
207
|
+
scalar: "DateTime",
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
This scalar definition is now used to properly parse or serialize the field value for cache reads and writes as well as `cache.extract()` and `cache.restore()`.
|
|
216
|
+
|
|
217
|
+
- [#13273](https://github.com/apollographql/apollo-client/pull/13273) [`0886de1`](https://github.com/apollographql/apollo-client/commit/0886de19ed67ca24bbcc075dcf5a94ba01589902) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Automatically serialize variables that include custom scalar values. This includes cache reads and writes as well as requests to the network.
|
|
218
|
+
|
|
219
|
+
For more complex input objects, a new `inputObjects` option is available to `InMemoryCache` that specifies where nested scalar fields are found.
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
const cache = new InMemoryCache({
|
|
223
|
+
scalars: {
|
|
224
|
+
DateTime: new Scalar({
|
|
225
|
+
parse: (value) => new Date(value),
|
|
226
|
+
serialize: (value) => value.toISOString(),
|
|
227
|
+
is: (value) => value instanceof Date,
|
|
228
|
+
}),
|
|
229
|
+
},
|
|
230
|
+
inputObjects: {
|
|
231
|
+
EventFilter: {
|
|
232
|
+
fields: {
|
|
233
|
+
date: "DateTime",
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
const client = new ApolloClient({ cache, link });
|
|
240
|
+
|
|
241
|
+
await client.query({
|
|
242
|
+
query: gql`
|
|
243
|
+
query Event($filter: EventFilter!) {
|
|
244
|
+
event(filter: $filter) {
|
|
245
|
+
name
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
`,
|
|
249
|
+
variables: {
|
|
250
|
+
filter: {
|
|
251
|
+
date: new Date("2026-01-01T00:00:00.000Z"),
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// The link receives:
|
|
257
|
+
// { filter: { date: "2026-01-01T00:00:00.000Z" } }
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
- [#13252](https://github.com/apollographql/apollo-client/pull/13252) [`ed86234`](https://github.com/apollographql/apollo-client/commit/ed8623485683c38982c87278d1381412ef39a9db) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Adds the `getScalar` abstract method to `ApolloCache` that cache subclasses override to provide scalar behavior to Apollo Client. Defaults to unconditionally return `undefined` if not specified.
|
|
261
|
+
|
|
3
262
|
## 4.3.0-alpha.1
|
|
4
263
|
|
|
5
264
|
### Patch Changes
|
|
@@ -41,6 +300,32 @@
|
|
|
41
300
|
> [!NOTE]
|
|
42
301
|
> Setting a cache type enforces that cache type in the `cache` option for the `ApolloClient` constructor.
|
|
43
302
|
|
|
303
|
+
## 4.2.7
|
|
304
|
+
|
|
305
|
+
### Patch Changes
|
|
306
|
+
|
|
307
|
+
- [#13320](https://github.com/apollographql/apollo-client/pull/13320) [`538c906`](https://github.com/apollographql/apollo-client/commit/538c906143c18dcc4fd9c29427413451fcd72c22) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Cleanup some unused internals. Please file an issue if you notice anything change.
|
|
308
|
+
|
|
309
|
+
## 4.2.6
|
|
310
|
+
|
|
311
|
+
### Patch Changes
|
|
312
|
+
|
|
313
|
+
- [#13315](https://github.com/apollographql/apollo-client/pull/13315) [`a406cc9`](https://github.com/apollographql/apollo-client/commit/a406cc9669246972a8f067462422aec716b6213b) Thanks [@fallintoplace](https://github.com/fallintoplace)! - Prevent relay multipart subscriptions from issuing a fetch request after serializing the request body fails.
|
|
314
|
+
|
|
315
|
+
- [#13307](https://github.com/apollographql/apollo-client/pull/13307) [`abd0781`](https://github.com/apollographql/apollo-client/commit/abd07814bbe80d9307458a450dd28addf1d38ef1) Thanks [@wolfie](https://github.com/wolfie)! - Speed up cache writes by avoiding a full AST `visit` of every written field to detect `@stream`. The check now runs only when the result carries stream info, and only inspects the field node's own directives. As a result, fields that merely contain `@stream` on a nested field are no longer treated as streamed themselves and now overwrite existing lists like regular fields instead of merging chunk-wise.
|
|
316
|
+
|
|
317
|
+
## 4.2.5
|
|
318
|
+
|
|
319
|
+
### Patch Changes
|
|
320
|
+
|
|
321
|
+
- [#13302](https://github.com/apollographql/apollo-client/pull/13302) [`bb75dd3`](https://github.com/apollographql/apollo-client/commit/bb75dd3a42bab21a0ff14c4482a5cb99a61843eb) Thanks [@tpict](https://github.com/tpict)! - Export `KeyArgsFunction` and `RelayFieldPolicy` types from public entrypoints.
|
|
322
|
+
|
|
323
|
+
## 4.2.4
|
|
324
|
+
|
|
325
|
+
### Patch Changes
|
|
326
|
+
|
|
327
|
+
- [#13281](https://github.com/apollographql/apollo-client/pull/13281) [`e4df809`](https://github.com/apollographql/apollo-client/commit/e4df809e87a1d2b72728df53327f531f65411ed3) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fixes an issue where `client.readFragment` and `client.readQuery` ignored the `optimistic` option when passed in the options object.
|
|
328
|
+
|
|
44
329
|
## 4.2.3
|
|
45
330
|
|
|
46
331
|
### Patch Changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scalar = void 0;
|
|
4
|
+
class Scalar {
|
|
5
|
+
options;
|
|
6
|
+
static fromGraphQLScalarType(scalarType, options) {
|
|
7
|
+
return new Scalar({
|
|
8
|
+
...options,
|
|
9
|
+
parse: scalarType.parseValue,
|
|
10
|
+
serialize: scalarType.serialize,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.options = options;
|
|
15
|
+
}
|
|
16
|
+
parse(value) {
|
|
17
|
+
return this.options.parse(value);
|
|
18
|
+
}
|
|
19
|
+
serialize(value) {
|
|
20
|
+
return this.options.serialize(value);
|
|
21
|
+
}
|
|
22
|
+
coerceToParsed(value) {
|
|
23
|
+
return this.is(value) ? value : this.parse(value);
|
|
24
|
+
}
|
|
25
|
+
coerceToSerialized(value) {
|
|
26
|
+
return this.is(value) ? this.serialize(value) : value;
|
|
27
|
+
}
|
|
28
|
+
is(value) {
|
|
29
|
+
if (this.options.is) {
|
|
30
|
+
return this.options.is(value);
|
|
31
|
+
}
|
|
32
|
+
return typeof value === "object" && value !== null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.Scalar = Scalar;
|
|
36
|
+
//# sourceMappingURL=Scalar.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scalar.cjs","sources":["../../../../src/cache/core/Scalar.ts"],"sourcesContent":["import type { GraphQLScalarType } from \"graphql\";\n\nimport type { NoInfer } from \"@apollo/client/utilities/internal\";\n\nexport declare namespace Scalar {\n export interface Options<TSerialized, TParsed> {\n // We use method syntax to ensure the functions are bivariant. This lets\n // users declare scalars using\n // `extends Record<string, { serialized: unknown; parsed: unknown }>` while\n // allowing specific scalar overrides.\n parse(serializedValue: TSerialized): NoInfer<TParsed>;\n serialize(parsedValue: TParsed): NoInfer<TSerialized>;\n is?(value: TSerialized | TParsed): boolean;\n }\n}\n\nexport class Scalar<TSerialized, TParsed> {\n private options: Scalar.Options<TSerialized, TParsed>;\n\n static fromGraphQLScalarType<TSerialized, TParsed>(\n scalarType: GraphQLScalarType<TParsed, TSerialized>,\n options?: Pick<Scalar.Options<NoInfer<TSerialized>, NoInfer<TParsed>>, \"is\">\n ): Scalar<TSerialized, TParsed> {\n return new Scalar<TSerialized, TParsed>({\n ...options,\n parse: scalarType.parseValue,\n serialize: scalarType.serialize,\n });\n }\n\n constructor(options: Scalar.Options<TSerialized, TParsed>) {\n this.options = options;\n }\n\n parse(value: TSerialized): TParsed {\n return this.options.parse(value);\n }\n\n serialize(value: TParsed): TSerialized {\n return this.options.serialize(value);\n }\n\n coerceToParsed(value: TSerialized | TParsed): TParsed {\n return this.is(value) ? value : this.parse(value);\n }\n\n coerceToSerialized(value: TSerialized | TParsed): TSerialized {\n return this.is(value) ? this.serialize(value) : value;\n }\n\n is(value: TSerialized | TParsed): value is TParsed {\n if (this.options.is) {\n return this.options.is(value);\n }\n\n return typeof value === \"object\" && value !== null;\n }\n}\n"],"names":[],"mappings":";;;AAgBA,CAAA,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,EAAA;IACU,CAAV,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB;IAEf,CAAF,CAAA,CAAA,CAAA,CAAA,EAAS,CAAT,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA8B,CAC1B,CADJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CACuD,EACnD,CAFJ,CAAA,CAAA,CAAA,CAAA,CAAA,CAEgF,EAFhF;QAII,CAAJ,CAAA,CAAA,CAAA,CAAA,EAAW,CAAX,CAAA,EAAe,CA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B,EAAE;YACnB,CAAN,CAAA,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAiB,CAAC,CAAlB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAyB,CAAC,CAA1B,CAA4B,CAAC,CAA7B,CAAA,CAAA,CAAA,CAAkC,CAAC;QAC/B;QAEA,CAAJ,CAAA,CAAA,CAAA,CAAA,EAAW,CAAX,CAAA,CAAA,CAAA,CAAA,EAAkB,CAAlB,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAA4B,CAA5B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,EAAwC,CAAxC,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAkD,CAAlD,CAAA,CAAA,CAAsD;IACpD;AACF;AAzCA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { GraphQLScalarType } from "graphql";
|
|
2
|
+
import type { NoInfer } from "@apollo/client/utilities/internal";
|
|
3
|
+
export declare namespace Scalar {
|
|
4
|
+
interface Options<TSerialized, TParsed> {
|
|
5
|
+
parse(serializedValue: TSerialized): NoInfer<TParsed>;
|
|
6
|
+
serialize(parsedValue: TParsed): NoInfer<TSerialized>;
|
|
7
|
+
is?(value: TSerialized | TParsed): boolean;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare class Scalar<TSerialized, TParsed> {
|
|
11
|
+
private options;
|
|
12
|
+
static fromGraphQLScalarType<TSerialized, TParsed>(scalarType: GraphQLScalarType<TParsed, TSerialized>, options?: Pick<Scalar.Options<NoInfer<TSerialized>, NoInfer<TParsed>>, "is">): Scalar<TSerialized, TParsed>;
|
|
13
|
+
constructor(options: Scalar.Options<TSerialized, TParsed>);
|
|
14
|
+
parse(value: TSerialized): TParsed;
|
|
15
|
+
serialize(value: TParsed): TSerialized;
|
|
16
|
+
coerceToParsed(value: TSerialized | TParsed): TParsed;
|
|
17
|
+
coerceToSerialized(value: TSerialized | TParsed): TSerialized;
|
|
18
|
+
is(value: TSerialized | TParsed): value is TParsed;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Scalar.d.cts.map
|
|
@@ -22,6 +22,13 @@ class ApolloCache {
|
|
|
22
22
|
lookupFragment(fragmentName) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
+
// Custom scalars API
|
|
26
|
+
getScalar(key) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
serializeVariables(document, variables) {
|
|
30
|
+
return variables;
|
|
31
|
+
}
|
|
25
32
|
// Transactional API
|
|
26
33
|
/**
|
|
27
34
|
* Executes multiple cache operations as a single batch, ensuring that
|
|
@@ -140,7 +147,7 @@ class ApolloCache {
|
|
|
140
147
|
if (environment_1.__DEV__) {
|
|
141
148
|
const actualFragmentName = fragmentName || (0, internal_1.getFragmentDefinition)(fragment).name.value;
|
|
142
149
|
if (id === undefined) {
|
|
143
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
150
|
+
__DEV__ && invariant_1.invariant.warn(119, actualFragmentName);
|
|
144
151
|
}
|
|
145
152
|
}
|
|
146
153
|
return id;
|