Skip to content

Commit e78107d

Browse files
authored
Merge branch 'release-4.1' into pr/experiments
2 parents 5a67855 + 36e2413 commit e78107d

File tree

77 files changed

+26762
-5648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+26762
-5648
lines changed

.api-reports/api-report-core.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@ export type WatchQueryOptions<TVariables extends OperationVariables = OperationV
11331133
// Warnings were encountered during analysis:
11341134
//
11351135
// src/core/ApolloClient.ts:353:5 - (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
1136-
// src/core/ObservableQuery.ts:361:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
1136+
// src/core/ObservableQuery.ts:368:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
11371137
// src/core/QueryManager.ts:180:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
11381138

11391139
// (No @packageDocumentation comment for this package)

.api-reports/api-report-incremental.api.md

Lines changed: 118 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,38 @@ namespace Defer20220824Handler {
2525
return: Defer20220824Handler.Chunk<Record<string, unknown>>;
2626
}
2727
// (undocumented)
28-
type IncrementalDeferPayload<TData = Record<string, unknown>> = {
29-
data?: TData | null | undefined;
28+
type IncrementalDeferResult<TData = Record<string, unknown>> = {
29+
data?: TData | null;
3030
errors?: ReadonlyArray<GraphQLFormattedError>;
3131
extensions?: Record<string, unknown>;
3232
path?: Incremental.Path;
3333
label?: string;
3434
};
3535
// (undocumented)
36+
type IncrementalResult<TData = Record<string, unknown>> = IncrementalDeferResult<TData> | IncrementalStreamResult<TData>;
37+
// (undocumented)
38+
type IncrementalStreamResult<TData = Array<unknown>> = {
39+
errors?: ReadonlyArray<GraphQLFormattedError>;
40+
items?: TData;
41+
path?: Incremental.Path;
42+
label?: string;
43+
extensions?: Record<string, unknown>;
44+
};
45+
// (undocumented)
3646
type InitialResult<TData = Record<string, unknown>> = {
3747
data?: TData | null | undefined;
3848
errors?: ReadonlyArray<GraphQLFormattedError>;
3949
extensions?: Record<string, unknown>;
4050
hasNext: boolean;
51+
incremental?: ReadonlyArray<IncrementalResult<TData>>;
4152
};
4253
// (undocumented)
4354
type SubsequentResult<TData = Record<string, unknown>> = {
4455
data?: TData | null | undefined;
4556
errors?: ReadonlyArray<GraphQLFormattedError>;
4657
extensions?: Record<string, unknown>;
4758
hasNext: boolean;
48-
incremental?: Array<IncrementalDeferPayload<TData>>;
59+
incremental?: Array<IncrementalResult<TData>>;
4960
};
5061
// (undocumented)
5162
interface TypeOverrides {
@@ -80,6 +91,102 @@ class DeferRequest<TData extends Record<string, unknown>> implements Incremental
8091
hasNext: boolean;
8192
}
8293

94+
// @public (undocumented)
95+
export namespace GraphQL17Alpha9Handler {
96+
// (undocumented)
97+
export type Chunk<TData> = InitialResult<TData> | SubsequentResult<TData>;
98+
// (undocumented)
99+
export interface CompletedResult {
100+
// (undocumented)
101+
errors?: ReadonlyArray<GraphQLFormattedError>;
102+
// (undocumented)
103+
id: string;
104+
}
105+
// (undocumented)
106+
export interface GraphQL17Alpha9Result extends HKT {
107+
// (undocumented)
108+
arg1: unknown;
109+
// (undocumented)
110+
arg2: unknown;
111+
// (undocumented)
112+
return: GraphQL17Alpha9Handler.Chunk<Record<string, unknown>>;
113+
}
114+
// (undocumented)
115+
export interface IncrementalDeferResult<TData = Record<string, unknown>> {
116+
// (undocumented)
117+
data: TData;
118+
// (undocumented)
119+
errors?: ReadonlyArray<GraphQLFormattedError>;
120+
// (undocumented)
121+
extensions?: Record<string, unknown>;
122+
// (undocumented)
123+
id: string;
124+
// (undocumented)
125+
subPath?: Incremental.Path;
126+
}
127+
// (undocumented)
128+
export type IncrementalResult<TData = unknown> = IncrementalDeferResult<TData> | IncrementalStreamResult<TData>;
129+
// (undocumented)
130+
export interface IncrementalStreamResult<TData = ReadonlyArray<unknown>> {
131+
// (undocumented)
132+
errors?: ReadonlyArray<GraphQLFormattedError>;
133+
// (undocumented)
134+
extensions?: Record<string, unknown>;
135+
// (undocumented)
136+
id: string;
137+
// (undocumented)
138+
items: TData;
139+
// (undocumented)
140+
subPath?: Incremental.Path;
141+
}
142+
// (undocumented)
143+
export type InitialResult<TData = Record<string, unknown>> = {
144+
data: TData;
145+
errors?: ReadonlyArray<GraphQLFormattedError>;
146+
pending: ReadonlyArray<PendingResult>;
147+
hasNext: boolean;
148+
extensions?: Record<string, unknown>;
149+
};
150+
// (undocumented)
151+
export interface PendingResult {
152+
// (undocumented)
153+
id: string;
154+
// (undocumented)
155+
label?: string;
156+
// (undocumented)
157+
path: Incremental.Path;
158+
}
159+
// (undocumented)
160+
export type SubsequentResult<TData = unknown> = {
161+
hasNext: boolean;
162+
pending?: ReadonlyArray<PendingResult>;
163+
incremental?: ReadonlyArray<IncrementalResult<TData>>;
164+
completed?: ReadonlyArray<CompletedResult>;
165+
extensions?: Record<string, unknown>;
166+
};
167+
// (undocumented)
168+
export interface TypeOverrides {
169+
// (undocumented)
170+
AdditionalApolloLinkResultTypes: GraphQL17Alpha9Result;
171+
}
172+
}
173+
174+
// @public
175+
export class GraphQL17Alpha9Handler implements Incremental.Handler<GraphQL17Alpha9Handler.Chunk<any>> {
176+
// @internal @deprecated (undocumented)
177+
extractErrors(result: ApolloLink.Result<any>): GraphQLFormattedError[] | undefined;
178+
// @internal @deprecated (undocumented)
179+
isIncrementalResult(result: ApolloLink.Result<any>): result is GraphQL17Alpha9Handler.InitialResult | GraphQL17Alpha9Handler.SubsequentResult;
180+
// @internal @deprecated (undocumented)
181+
prepareRequest(request: ApolloLink.Request): ApolloLink.Request;
182+
// Warning: (ae-forgotten-export) The symbol "IncrementalRequest" needs to be exported by the entry point index.d.ts
183+
//
184+
// @internal @deprecated (undocumented)
185+
startRequest<TData>(_: {
186+
query: DocumentNode;
187+
}): IncrementalRequest<TData>;
188+
}
189+
83190
// @public (undocumented)
84191
export namespace Incremental {
85192
// @internal @deprecated (undocumented)
@@ -106,6 +213,14 @@ export namespace Incremental {
106213
export type Path = ReadonlyArray<string | number>;
107214
}
108215

216+
// @public (undocumented)
217+
class IncrementalRequest<TData> implements Incremental.IncrementalRequest<GraphQL17Alpha9Handler.Chunk<TData>, TData> {
218+
// (undocumented)
219+
handle(cacheData: TData | DeepPartial<TData> | null | undefined, chunk: GraphQL17Alpha9Handler.Chunk<TData>): FormattedExecutionResult<TData>;
220+
// (undocumented)
221+
hasNext: boolean;
222+
}
223+
109224
// @public (undocumented)
110225
export namespace NotImplementedHandler {
111226
// (undocumented)

.api-reports/api-report-utilities_internal.api.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,20 @@ export type DecoratedPromise<TValue> = PendingPromise<TValue> | FulfilledPromise
100100
export function decoratePromise<TValue>(promise: Promise<TValue>): DecoratedPromise<TValue>;
101101

102102
// @internal @deprecated (undocumented)
103-
export class DeepMerger<TContextArgs extends any[]> {
103+
export namespace DeepMerger {
104+
// (undocumented)
105+
export type ArrayMergeStrategy = "truncate" | "combine";
106+
// (undocumented)
107+
export interface Options {
108+
// (undocumented)
109+
arrayMerge?: DeepMerger.ArrayMergeStrategy;
110+
}
111+
}
112+
113+
// @internal @deprecated (undocumented)
114+
export class DeepMerger<TContextArgs extends any[] = any[]> {
104115
// Warning: (ae-forgotten-export) The symbol "ReconcilerFunction" needs to be exported by the entry point index.d.ts
105-
constructor(reconciler?: ReconcilerFunction<TContextArgs>);
116+
constructor(reconciler?: ReconcilerFunction<TContextArgs>, options?: DeepMerger.Options);
106117
// (undocumented)
107118
isObject: typeof isNonNullObject;
108119
// (undocumented)
@@ -449,7 +460,7 @@ export type VariablesOption<TVariables extends OperationVariables> = {} extends
449460

450461
// Warnings were encountered during analysis:
451462
//
452-
// src/utilities/internal/getStoreKeyName.ts:88:1 - (ae-forgotten-export) The symbol "storeKeyNameStringify" needs to be exported by the entry point index.d.ts
463+
// src/utilities/internal/getStoreKeyName.ts:89:1 - (ae-forgotten-export) The symbol "storeKeyNameStringify" needs to be exported by the entry point index.d.ts
453464

454465
// (No @packageDocumentation comment for this package)
455466

.api-reports/api-report.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,7 @@ interface WriteContext extends ReadMergeModifyContext {
27132713
// src/cache/inmemory/types.ts:134:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts
27142714
// src/core/ApolloClient.ts:159:5 - (ae-forgotten-export) The symbol "IgnoreModifier" needs to be exported by the entry point index.d.ts
27152715
// src/core/ApolloClient.ts:353:5 - (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
2716-
// src/core/ObservableQuery.ts:361:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
2716+
// src/core/ObservableQuery.ts:368:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
27172717
// src/core/QueryManager.ts:180:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
27182718
// src/local-state/LocalState.ts:147:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
27192719
// src/local-state/LocalState.ts:200:7 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts

.changeset/cold-kiwis-give.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": minor
3+
---
4+
5+
Fix an issue where deferred payloads that reteurned arrays with fewer items than the original cached array would retain items from the cached array. This change includes `@stream` arrays where stream arrays replace the cached arrays.

.changeset/funny-bats-hammer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": patch
3+
---
4+
5+
Fix an issue where calling `fetchMore` with `@defer` or `@stream` would not rerender incremental results as they were streamed.

.changeset/little-yaks-decide.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
"@apollo/client": minor
3+
---
4+
5+
Support the newer incremental delivery format for the `@defer` directive implemented in `[email protected]`. Import the `GraphQL17Alpha9Handler` to use the newer incremental delivery format with `@defer`.
6+
7+
```ts
8+
import { GraphQL17Alpha9Handler } from "@apollo/client/incremental";
9+
10+
const client = new ApolloClient({
11+
// ...
12+
incrementalHandler: new GraphQL17Alpha9Handler(),
13+
});
14+
```
15+
16+
> [!NOTE]
17+
> In order to use the `GraphQL17Alpha9Handler`, the GraphQL server MUST implement the newer incremental delivery format. You may see errors or unusual behavior if you use the wrong handler. If you are using Apollo Router, continue to use the `Defer20220824Handler` because Apollo Router does not yet support the newer incremental delivery format.

.changeset/neat-lemons-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@apollo/client": patch
3+
---
4+
5+
Improve the cache data loss warning message when `existing` or `incoming` is an array.

.changeset/pre.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,11 @@
66
"@apollo/client-graphql-codegen": "1.0.0",
77
"@apollo/client-codemod-migrate-3-to-4": "1.0.2"
88
},
9-
"changesets": []
9+
"changesets": [
10+
"cold-kiwis-give",
11+
"funny-bats-hammer",
12+
"little-yaks-decide",
13+
"neat-lemons-shave",
14+
"six-islands-drum"
15+
]
1016
}

.changeset/six-islands-drum.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@apollo/client": minor
3+
---
4+
5+
Add support for the `@stream` directive on both the `Defer20220824Handler` and the `GraphQL17Alpha2Handler`.
6+
7+
> [!NOTE]
8+
> The implementations of `@stream` differ in the delivery of incremental results between the different GraphQL spec versions. If you upgrading from the older format to the newer format, expect the timing of some incremental results to change.

0 commit comments

Comments
 (0)