Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
250 commits
Select commit Hold shift + click to select a range
217905c
[WIP] copy over alpha.9 tests
jerelmiller Sep 4, 2025
66d6c9b
Update the remaining tests to work with the handler
jerelmiller Sep 4, 2025
12a710c
Add additional tests
jerelmiller Sep 4, 2025
225edff
Create stub of GraphQL17Alpha9Handler
jerelmiller Sep 4, 2025
fbbd08e
Add chunk types for alpha9
jerelmiller Sep 4, 2025
1626cf6
Add stub implementations for abstract methods
jerelmiller Sep 4, 2025
f1b483d
Enter prerelease mode
github-actions[bot] Sep 4, 2025
2d6610d
Add graphql-alpha.9 as dev dependency
jerelmiller Sep 4, 2025
2681c69
Update types to be more compatible with graphql-js
jerelmiller Sep 4, 2025
6cb1c20
Fix type of completed result
jerelmiller Sep 4, 2025
ba85d93
Add initial implementation of merging
jerelmiller Sep 4, 2025
6d8c443
Add patch for types in v17-alpha9
jerelmiller Sep 4, 2025
9cd60c4
Add return type for async generator for run function
jerelmiller Sep 4, 2025
b039ee4
Add errors when merging
jerelmiller Sep 4, 2025
74cb0a4
Ensure errors are merged from incremental results
jerelmiller Sep 4, 2025
c17707f
Iterate completed after merging all incremental items
jerelmiller Sep 4, 2025
e7e11b7
Remove locations from error
jerelmiller Sep 4, 2025
21042b9
Fix incorrect data merged in
jerelmiller Sep 4, 2025
53bd6ce
Merge errors in completed array
jerelmiller Sep 4, 2025
978228a
Remove locations in error tests
jerelmiller Sep 4, 2025
706bda0
Fix incorrect assertion
jerelmiller Sep 4, 2025
e6731f8
Fix missing assertion in test
jerelmiller Sep 4, 2025
dba62d4
Fix incorrect assertion
jerelmiller Sep 4, 2025
ee5cb45
Update test to use actual schema fields
jerelmiller Sep 4, 2025
33ba203
Yield a regular result instead of return
jerelmiller Sep 4, 2025
11823bd
Ensure errors are serialized from helper
jerelmiller Sep 4, 2025
40213fa
Update test to match incremental behavior
jerelmiller Sep 4, 2025
6e6ff31
Update how path is calculated
jerelmiller Sep 4, 2025
fa0b687
Temp skip test
jerelmiller Sep 4, 2025
ec9792f
Move test to /defer.test.ts
jerelmiller Sep 4, 2025
8d61c1d
Update extractErrors
jerelmiller Sep 4, 2025
2610442
Rename merge
jerelmiller Sep 4, 2025
dbf5b7f
Make types mirror defer implementation
jerelmiller Sep 4, 2025
723c163
Update exports snapshot
jerelmiller Sep 4, 2025
a12de86
Split out helper for mocking an incremental stream
jerelmiller Sep 4, 2025
df5b353
Rename helper
jerelmiller Sep 4, 2025
f4a4a9f
Use updated helper in incremental utils
jerelmiller Sep 4, 2025
ba1f15e
Move mockDeferStream to own file
jerelmiller Sep 4, 2025
12e8ddb
Rename mockDeferStream to mockDefer20220824 everywhere
jerelmiller Sep 4, 2025
3ed6eb4
Rename file
jerelmiller Sep 4, 2025
b35c6e0
Add helper to mock newer defer implementation
jerelmiller Sep 4, 2025
260d296
Rename folder to multipart
jerelmiller Sep 4, 2025
dc0d1fd
Move mulipart subscription mock to own file
jerelmiller Sep 4, 2025
7b51170
Import directly to avoid another barrel file
jerelmiller Sep 4, 2025
005aa27
Format test files with typescript parser
jerelmiller Sep 4, 2025
4e36d7c
Update exports snapshot
jerelmiller Sep 4, 2025
8b9b314
Move useQuery defer tests to own file
jerelmiller Sep 4, 2025
66986d4
Replace MockSubscriptionLink with mock helper
jerelmiller Sep 4, 2025
0612a52
Add tests for useQuery with the new defer spec
jerelmiller Sep 5, 2025
af769e7
Port first defer test for useSuspenseQuery to own file
jerelmiller Sep 5, 2025
45bf6ab
Extract render helper
jerelmiller Sep 5, 2025
ae21e84
Migrate useSuspenseQuery defer tests to own file with renderStream
jerelmiller Sep 5, 2025
fec5d76
Ignore useSuspenseQuery subfile tests
jerelmiller Sep 5, 2025
0064d8f
Remove unneeded heck for React 19 in test
jerelmiller Sep 5, 2025
1d61c48
Remove unneeded non-null assertion
jerelmiller Sep 5, 2025
74ab3ca
Rename ErrorFallback to ErrorBoundary
jerelmiller Sep 5, 2025
7826689
Remove unneeded non-null assertion
jerelmiller Sep 5, 2025
51e9ff3
Add useSuspenseQuery tets for GraphQL17Alpha9Handler
jerelmiller Sep 5, 2025
61736c0
Copy useBackgroundQuery defer tests to own file
jerelmiller Sep 5, 2025
aa17427
Use the new helpers
jerelmiller Sep 5, 2025
da0113c
Use a pattern similar to useSuspenseQuery tests in useBackgroundQuery…
jerelmiller Sep 5, 2025
9ae7fa3
Use createClientWrapper helper in the defer test files
jerelmiller Sep 5, 2025
27e5faf
Add useBackgroundQuery tests for defer with updated spec
jerelmiller Sep 5, 2025
7f7f72c
Move useMutation defer tests to own file
jerelmiller Sep 5, 2025
013c568
Move useLoadableQuery defer tests to own file
jerelmiller Sep 5, 2025
3e0d4de
Move createQueryPreloader tests to own file
jerelmiller Sep 5, 2025
6b0e002
Use defer helpers instead of mock subscription link
jerelmiller Sep 5, 2025
560824e
Use render helper in useLoadableQuery similar to other tests
jerelmiller Sep 5, 2025
fe18741
Remove unused import
jerelmiller Sep 5, 2025
01d4325
Add a useLoadableQuery test suite for deferGraphQL17Alpha9
jerelmiller Sep 5, 2025
6e4ad15
Add a createQueryPreloader test suite for deferGraphQL17Alpha9
jerelmiller Sep 5, 2025
c217efa
Add a doc block
jerelmiller Sep 5, 2025
93ef59d
Mark methods as internal
jerelmiller Sep 5, 2025
102756e
Run extract api
jerelmiller Sep 5, 2025
16b4457
Update size limits
jerelmiller Sep 5, 2025
108e9f0
Formatting
jerelmiller Sep 5, 2025
bfacd3e
Fix lint errors
jerelmiller Sep 5, 2025
5c51186
Remove unused imports
jerelmiller Sep 5, 2025
cb0e021
Fix useSuspenseQuery test that just emitted errors
jerelmiller Sep 5, 2025
8a8927f
Move `@defer` tests from ApolloClient/* to client.watchQuery/defer202…
jerelmiller Sep 5, 2025
a8231c0
Restore multiple-results test
jerelmiller Sep 6, 2025
5e85248
Remove multiple-results tests from defer tests
jerelmiller Sep 6, 2025
bb6dd71
Add new spec format tests
jerelmiller Sep 6, 2025
a9c5e7d
Remove defer in tests that don't test defer
jerelmiller Sep 6, 2025
8de4546
Exclude useBackgroundQuery/useLoadableQuery subfolder tests from Reac…
jerelmiller Sep 8, 2025
7512b6b
Update test with new test utils
jerelmiller Sep 8, 2025
96120c5
Update error message
jerelmiller Sep 8, 2025
0772538
Use filter instead of indexOf and splice
jerelmiller Sep 8, 2025
b72deb0
Add tests for the new format for useMutation
jerelmiller Sep 8, 2025
b674efa
First implementation of stream
jerelmiller Sep 9, 2025
dbd6eda
Enable all tests
jerelmiller Sep 9, 2025
b3f35f4
Fix some incorrect assertions on hasIncrementalChunks
jerelmiller Sep 9, 2025
886be17
Remove locations from errors in assertions
jerelmiller Sep 9, 2025
503951e
Formatting
jerelmiller Sep 9, 2025
5f29b63
Merge errors for streamed results
jerelmiller Sep 9, 2025
ad1276f
Fix incorrect assertions
jerelmiller Sep 9, 2025
226a6ef
Remove assertions on hasIncrementalChunks
jerelmiller Sep 9, 2025
b53ce0d
Remove export/check for hasIncrementalChunks
jerelmiller Sep 9, 2025
6b69a4e
Add necessary changes to writeToStore to handle stream
jerelmiller Sep 9, 2025
8c86479
Add tests for stream with the full client
jerelmiller Sep 9, 2025
f82c785
Move most stream tests to client.watchQuery folder
jerelmiller Sep 9, 2025
51b0bc3
Fix issue with frozen arrays
jerelmiller Sep 9, 2025
ab5b085
Simplify
jerelmiller Sep 9, 2025
2dda3d1
Revert "Add necessary changes to writeToStore to handle stream"
jerelmiller Sep 9, 2025
292b5b3
Don't add stream directive to field name
jerelmiller Sep 9, 2025
17b0baf
Add test for writing stream field to cache
jerelmiller Sep 9, 2025
64ed794
Add stream to known directives
jerelmiller Sep 9, 2025
0bea917
Remove check in storeKeyNameFromField
jerelmiller Sep 9, 2025
7853aa8
Remove unused imports
jerelmiller Sep 9, 2025
240bf89
Add more tests for different scenarios
jerelmiller Sep 9, 2025
91e7e3c
Rerun api report
jerelmiller Sep 9, 2025
d9d657e
Formatting
jerelmiller Sep 9, 2025
ce8b922
More stream tests
jerelmiller Sep 9, 2025
34f846b
Use toEmitSimilarValue
jerelmiller Sep 9, 2025
c0824bc
Add test for nested stream with defer
jerelmiller Sep 9, 2025
65b9949
Add test for defer inside stream
jerelmiller Sep 9, 2025
923b340
Add promiseWithResolvers to testing utils
jerelmiller Sep 9, 2025
5050441
Use shared promiseWithResolvers helper
jerelmiller Sep 9, 2025
fbde032
Temp rename
jerelmiller Sep 9, 2025
d32ef43
Fix rename
jerelmiller Sep 9, 2025
2b336ce
Add tests for stream with defer20220824
jerelmiller Sep 10, 2025
41ae981
Move defer20220824 defer tests to subfolder
jerelmiller Sep 10, 2025
aa3924a
Update types for defer20220824 handler
jerelmiller Sep 10, 2025
020ba18
Fix assertion on test
jerelmiller Sep 10, 2025
4fbec80
First pass at implementing stream for old format
jerelmiller Sep 10, 2025
d6a051b
Fix more incorrect assertions
jerelmiller Sep 10, 2025
99bc51f
Remove locations from errors in assertions
jerelmiller Sep 10, 2025
347eb20
Handle merging null from stream
jerelmiller Sep 10, 2025
0d271ef
Fix more incorrect assertions
jerelmiller Sep 10, 2025
7d1cc64
Initialize merger on class initialization. Rename to merge
jerelmiller Sep 10, 2025
85a1dcc
Add test file for client.watchQuery with stream on old format
jerelmiller Sep 10, 2025
73d7da2
Set test to failing to determine what we should do later
jerelmiller Sep 10, 2025
6271687
Update assertions based on behavior of old implementation
jerelmiller Sep 10, 2025
3ac5544
Rerun api report
jerelmiller Sep 10, 2025
c7fba99
Add changeset
jerelmiller Sep 10, 2025
562e219
Add changeset
jerelmiller Sep 10, 2025
c4a4228
Update size limits
jerelmiller Sep 10, 2025
9dcbd37
Update size limits
jerelmiller Sep 10, 2025
3aa091c
Ensure multipart/mixed header is set when using stream
jerelmiller Sep 10, 2025
802c7d9
Add tests for alpha.9 in HttpLink
jerelmiller Sep 10, 2025
86e0025
Update exports snapshot
jerelmiller Sep 10, 2025
c398a55
Always create a new DeepMerger
jerelmiller Sep 10, 2025
8052f24
Fix name of test file
jerelmiller Sep 10, 2025
e0890e6
Initialize a new DeepMerger each time
jerelmiller Sep 10, 2025
d59dd30
Fix incorrect assertion for useQuery test due to bug in handler
jerelmiller Sep 10, 2025
27fc9dc
Update size limits
jerelmiller Sep 10, 2025
b204d22
Add test helpers to execute schema incrementally
jerelmiller Sep 10, 2025
2f620ef
Add enableEarlyExecution option
jerelmiller Sep 10, 2025
6b4156c
Update existing tests to use new execute helpers
jerelmiller Sep 10, 2025
1d3f36c
Simplify link in tests
jerelmiller Sep 10, 2025
7d238ff
Add schemas for the friend list
jerelmiller Sep 10, 2025
fc671ff
Add helper to emit values in async iterable
jerelmiller Sep 10, 2025
1e3e80c
Add offset arg to friendList
jerelmiller Sep 10, 2025
c22394b
Add dom.asyncIterable to tests
jerelmiller Sep 11, 2025
38b24c7
Add tests for useSuspenseQuery with @stream
jerelmiller Sep 11, 2025
02bde88
Fix eslint issue
jerelmiller Sep 11, 2025
ef6f5b8
WIP cache stream update
jerelmiller Sep 11, 2025
208ddd0
Don't set this.data to cacheData and instead merge at the end
jerelmiller Sep 11, 2025
6e72cfa
Extract helper to deep merge
jerelmiller Sep 11, 2025
9961449
Add additional test cases
jerelmiller Sep 11, 2025
b87639a
Re-enable most tests
jerelmiller Sep 11, 2025
1addfc1
Maintain a queue of the last delivery in case there are no listeners
jerelmiller Sep 11, 2025
172da1c
Enable some failing tests
jerelmiller Sep 11, 2025
f58d724
Use subject to control last test
jerelmiller Sep 11, 2025
52aff04
Use test helpers
jerelmiller Sep 11, 2025
d4dca15
Fix comment
jerelmiller Sep 11, 2025
65d04e5
Remove unused import
jerelmiller Sep 11, 2025
8a62e8a
Change expect to assert to fix ts error
jerelmiller Sep 11, 2025
a439d54
Update exports snapshot
jerelmiller Sep 11, 2025
ad7a87e
Copy useSuspenseQuery stream tests for older spec
jerelmiller Sep 11, 2025
27bc219
Update details for older spec
jerelmiller Sep 11, 2025
77eb9c5
Revert to older implementation
jerelmiller Sep 11, 2025
fbb2f38
Inline deepMerge
jerelmiller Sep 11, 2025
198279c
Fix missing default from change to shared function
jerelmiller Sep 11, 2025
356bfe7
Fix most cases of merging cache with streamed chunks
jerelmiller Sep 11, 2025
1fdd487
Fix issue with non-zero lists sent with defer chunk
jerelmiller Sep 11, 2025
d366dc1
Add additional test to check non-zero length array in defer chunk
jerelmiller Sep 11, 2025
853b2d7
Add failing test for merging cache data on defer chunk
jerelmiller Sep 11, 2025
90c7e46
Fix the failing test
jerelmiller Sep 11, 2025
b5581e1
Rename property
jerelmiller Sep 11, 2025
ae31314
Add comment
jerelmiller Sep 11, 2025
e67eab2
Update comment
jerelmiller Sep 11, 2025
12a89fc
it -> test
jerelmiller Sep 11, 2025
d6198ae
Use shared schema
jerelmiller Sep 11, 2025
01cdf3e
Add cache tests for defer20220824 stream
jerelmiller Sep 11, 2025
1635680
Update stream tests to better handle React 18/19 differences
jerelmiller Sep 11, 2025
e723622
Simplify merge function
jerelmiller Sep 11, 2025
447dd7d
Add missing args for friendList in alpha2 schema
jerelmiller Sep 11, 2025
2ab4a55
Update useSuspenseQuery tests to be more friendly between react versions
jerelmiller Sep 11, 2025
c954d25
Add useQuery stream tests for GraphQL17Alpha9Handler
jerelmiller Sep 12, 2025
1206a77
Add useQuery stream tests for Defer20220824Handler
jerelmiller Sep 12, 2025
b05df03
Add stream tests for useBackgroundQuery
jerelmiller Sep 12, 2025
1a2c04d
Add array merge strategy to deep merger
jerelmiller Sep 12, 2025
92078c6
Default DeepMerger generic argument
jerelmiller Sep 12, 2025
308702a
WIP truncate merge arrays
jerelmiller Sep 12, 2025
67161f6
Check length before truncating
jerelmiller Sep 15, 2025
16bf7bc
Add another test for truncate merge
jerelmiller Sep 15, 2025
8442c84
Add past copies instead of copying twice
jerelmiller Sep 15, 2025
2f00a39
Inline new merger
jerelmiller Sep 15, 2025
05f9085
Move type to namespace
jerelmiller Sep 15, 2025
07567ef
Use dynamic array merge strategies
jerelmiller Sep 15, 2025
21a1928
Use property type for array merge
jerelmiller Sep 15, 2025
296dc9a
Truncate arrays in defer20220824 handler
jerelmiller Sep 15, 2025
156fa22
Update useBackgroundQuery tests to reflect updated nature on lists
jerelmiller Sep 15, 2025
58b5269
Combine array items if merging defer arrays
jerelmiller Sep 15, 2025
ede1476
Make graphql17Alpha9 more like Defer20220824 when determining arrayMe…
jerelmiller Sep 15, 2025
64d8536
Update useSuspenseQuery stream tests with updated behavior of list me…
jerelmiller Sep 15, 2025
5d7626a
Update spyOnConsole statement
jerelmiller Sep 15, 2025
32ad13a
Remove todo in useBackgroundQuery tests
jerelmiller Sep 15, 2025
ac33578
Update useQuery stream tests
jerelmiller Sep 15, 2025
3715a17
Remove unneeded arg
jerelmiller Sep 15, 2025
f9e176b
Add test to ensure custom merge function can be used to combine cache…
jerelmiller Sep 15, 2025
2aa31c7
Add changeset
jerelmiller Sep 15, 2025
6dddd33
Update size limits
jerelmiller Sep 15, 2025
1780c72
Add tests for refetches with defer arrays
jerelmiller Sep 15, 2025
f63c2b2
Fix changeset version type
jerelmiller Sep 15, 2025
dc712e7
Print object as array in warning
jerelmiller Sep 15, 2025
01cace0
Add changeset
jerelmiller Sep 15, 2025
31e405e
Update api report
jerelmiller Sep 15, 2025
c496039
Fix tag mix in api report
jerelmiller Sep 15, 2025
000cef4
Fix duplicate errors in extractErrors from initial chunk
jerelmiller Sep 16, 2025
14e5a98
Update size limits
jerelmiller Sep 16, 2025
49873cb
Add stream tests
jerelmiller Sep 9, 2025
3cb80fc
Turn off non tracking renders
jerelmiller Sep 16, 2025
2179c8f
Remove duplicate test and enable failing test
jerelmiller Sep 16, 2025
4226a2e
it -> test
jerelmiller Sep 16, 2025
571d835
Fix fetchMore with incremental results by emitting incremental results
jerelmiller Sep 16, 2025
39d08d9
Use ===
jerelmiller Sep 16, 2025
bdb5de0
Re-enable fetchMore with incremental results for defer20220824 tests
jerelmiller Sep 16, 2025
4874229
Ensure stream results that emit hasNext: false only set network status
jerelmiller Sep 16, 2025
0c48f0a
Enable stream tests with fetchMore incremental rendering
jerelmiller Sep 16, 2025
f538a83
Add changeset
jerelmiller Sep 16, 2025
38fdfb6
Update size limits
jerelmiller Sep 16, 2025
d7bda3c
Remove unused import
jerelmiller Sep 16, 2025
fc11c65
Remove commented code
jerelmiller Sep 16, 2025
982a0b6
Tweak to be more like original
jerelmiller Sep 16, 2025
c361a8c
Remove unneeded markAsStreaming
jerelmiller Sep 17, 2025
f429722
Reset wasUpdated only on processed messages
jerelmiller Sep 17, 2025
fc0ad32
Use filter
jerelmiller Sep 17, 2025
23a21d8
Update api report
jerelmiller Sep 17, 2025
8493681
Add private get for cache in ObservableQuery
jerelmiller Sep 17, 2025
dfc1670
Let cache watch handle final result
jerelmiller Sep 17, 2025
6ddb8f8
Update api report
jerelmiller Sep 17, 2025
36e2413
Version Packages (alpha) (#12928)
github-actions[bot] Sep 17, 2025
c97b145
Create mechanism to add experimental features to Apollo Client (#12915)
phryneas Sep 24, 2025
54ab6d9
More robust handling of local state default value when read function …
jerelmiller Sep 26, 2025
c5d5630
Version Packages (alpha) (#12940)
github-actions[bot] Sep 26, 2025
1c82eaf
Throw an error when using `@stream` without a configured `incremental…
jerelmiller Oct 10, 2025
556e837
Add `context` as callback to `useMutation` `mutate` function (#12959)
jerelmiller Oct 10, 2025
f8dab9d
Version Packages (alpha) (#12962)
github-actions[bot] Oct 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .api-reports/api-report-cache.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export abstract class ApolloCache {
abstract removeOptimistic(id: string): void;
// (undocumented)
abstract reset(options?: Cache_2.ResetOptions): Promise<void>;
resolvesClientField?(typename: string, fieldName: string): boolean;
abstract restore(serializedState: unknown): this;
// (undocumented)
transformDocument(document: DocumentNode): DocumentNode;
Expand Down Expand Up @@ -544,6 +545,8 @@ export class InMemoryCache extends ApolloCache {
// (undocumented)
reset(options?: Cache_2.ResetOptions): Promise<void>;
// (undocumented)
resolvesClientField(typename: string, fieldName: string): boolean;
// (undocumented)
restore(data: NormalizedCacheObject): this;
// (undocumented)
retain(rootId: string, optimistic?: boolean): number;
Expand Down
12 changes: 10 additions & 2 deletions .api-reports/api-report-core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ export namespace ApolloClient {
}
}
// (undocumented)
export interface Experiment {
// (undocumented)
(this: ApolloClient, options: ApolloClient.Options): void;
// (undocumented)
v: 1;
}
// (undocumented)
export type MutateOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache> = {
optimisticResponse?: Unmasked<NoInfer<TData>> | ((vars: TVariables, { IGNORE }: {
IGNORE: IgnoreModifier;
Expand Down Expand Up @@ -231,6 +238,7 @@ export namespace ApolloClient {
documentTransform?: DocumentTransform;
// (undocumented)
enhancedClientAwareness?: ClientAwarenessLink.EnhancedClientAwarenessOptions;
experiments?: ApolloClient.Experiment[];
incrementalHandler?: Incremental.Handler<any>;
link: ApolloLink;
// (undocumented)
Expand Down Expand Up @@ -1132,8 +1140,8 @@ export type WatchQueryOptions<TVariables extends OperationVariables = OperationV

// Warnings were encountered during analysis:
//
// src/core/ApolloClient.ts:353:5 - (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:361:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ApolloClient.ts:362:5 - (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:368:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:180:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)
Expand Down
121 changes: 118 additions & 3 deletions .api-reports/api-report-incremental.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,38 @@ namespace Defer20220824Handler {
return: Defer20220824Handler.Chunk<Record<string, unknown>>;
}
// (undocumented)
type IncrementalDeferPayload<TData = Record<string, unknown>> = {
data?: TData | null | undefined;
type IncrementalDeferResult<TData = Record<string, unknown>> = {
data?: TData | null;
errors?: ReadonlyArray<GraphQLFormattedError>;
extensions?: Record<string, unknown>;
path?: Incremental.Path;
label?: string;
};
// (undocumented)
type IncrementalResult<TData = Record<string, unknown>> = IncrementalDeferResult<TData> | IncrementalStreamResult<TData>;
// (undocumented)
type IncrementalStreamResult<TData = Array<unknown>> = {
errors?: ReadonlyArray<GraphQLFormattedError>;
items?: TData;
path?: Incremental.Path;
label?: string;
extensions?: Record<string, unknown>;
};
// (undocumented)
type InitialResult<TData = Record<string, unknown>> = {
data?: TData | null | undefined;
errors?: ReadonlyArray<GraphQLFormattedError>;
extensions?: Record<string, unknown>;
hasNext: boolean;
incremental?: ReadonlyArray<IncrementalResult<TData>>;
};
// (undocumented)
type SubsequentResult<TData = Record<string, unknown>> = {
data?: TData | null | undefined;
errors?: ReadonlyArray<GraphQLFormattedError>;
extensions?: Record<string, unknown>;
hasNext: boolean;
incremental?: Array<IncrementalDeferPayload<TData>>;
incremental?: Array<IncrementalResult<TData>>;
};
// (undocumented)
interface TypeOverrides {
Expand Down Expand Up @@ -80,6 +91,102 @@ class DeferRequest<TData extends Record<string, unknown>> implements Incremental
hasNext: boolean;
}

// @public (undocumented)
export namespace GraphQL17Alpha9Handler {
// (undocumented)
export type Chunk<TData> = InitialResult<TData> | SubsequentResult<TData>;
// (undocumented)
export interface CompletedResult {
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
id: string;
}
// (undocumented)
export interface GraphQL17Alpha9Result extends HKT {
// (undocumented)
arg1: unknown;
// (undocumented)
arg2: unknown;
// (undocumented)
return: GraphQL17Alpha9Handler.Chunk<Record<string, unknown>>;
}
// (undocumented)
export interface IncrementalDeferResult<TData = Record<string, unknown>> {
// (undocumented)
data: TData;
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: Record<string, unknown>;
// (undocumented)
id: string;
// (undocumented)
subPath?: Incremental.Path;
}
// (undocumented)
export type IncrementalResult<TData = unknown> = IncrementalDeferResult<TData> | IncrementalStreamResult<TData>;
// (undocumented)
export interface IncrementalStreamResult<TData = ReadonlyArray<unknown>> {
// (undocumented)
errors?: ReadonlyArray<GraphQLFormattedError>;
// (undocumented)
extensions?: Record<string, unknown>;
// (undocumented)
id: string;
// (undocumented)
items: TData;
// (undocumented)
subPath?: Incremental.Path;
}
// (undocumented)
export type InitialResult<TData = Record<string, unknown>> = {
data: TData;
errors?: ReadonlyArray<GraphQLFormattedError>;
pending: ReadonlyArray<PendingResult>;
hasNext: boolean;
extensions?: Record<string, unknown>;
};
// (undocumented)
export interface PendingResult {
// (undocumented)
id: string;
// (undocumented)
label?: string;
// (undocumented)
path: Incremental.Path;
}
// (undocumented)
export type SubsequentResult<TData = unknown> = {
hasNext: boolean;
pending?: ReadonlyArray<PendingResult>;
incremental?: ReadonlyArray<IncrementalResult<TData>>;
completed?: ReadonlyArray<CompletedResult>;
extensions?: Record<string, unknown>;
};
// (undocumented)
export interface TypeOverrides {
// (undocumented)
AdditionalApolloLinkResultTypes: GraphQL17Alpha9Result;
}
}

// @public
export class GraphQL17Alpha9Handler implements Incremental.Handler<GraphQL17Alpha9Handler.Chunk<any>> {
// @internal @deprecated (undocumented)
extractErrors(result: ApolloLink.Result<any>): GraphQLFormattedError[] | undefined;
// @internal @deprecated (undocumented)
isIncrementalResult(result: ApolloLink.Result<any>): result is GraphQL17Alpha9Handler.InitialResult | GraphQL17Alpha9Handler.SubsequentResult;
// @internal @deprecated (undocumented)
prepareRequest(request: ApolloLink.Request): ApolloLink.Request;
// Warning: (ae-forgotten-export) The symbol "IncrementalRequest" needs to be exported by the entry point index.d.ts
//
// @internal @deprecated (undocumented)
startRequest<TData>(_: {
query: DocumentNode;
}): IncrementalRequest<TData>;
}

// @public (undocumented)
export namespace Incremental {
// @internal @deprecated (undocumented)
Expand All @@ -106,6 +213,14 @@ export namespace Incremental {
export type Path = ReadonlyArray<string | number>;
}

// @public (undocumented)
class IncrementalRequest<TData> implements Incremental.IncrementalRequest<GraphQL17Alpha9Handler.Chunk<TData>, TData> {
// (undocumented)
handle(cacheData: TData | DeepPartial<TData> | null | undefined, chunk: GraphQL17Alpha9Handler.Chunk<TData>): FormattedExecutionResult<TData>;
// (undocumented)
hasNext: boolean;
}

// @public (undocumented)
export namespace NotImplementedHandler {
// (undocumented)
Expand Down
4 changes: 3 additions & 1 deletion .api-reports/api-report-local-state.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { NoInfer as NoInfer_2 } from '@apollo/client/utilities/internal';
import type { OperationVariables } from '@apollo/client';
import type { RemoveIndexSignature } from '@apollo/client/utilities/internal';
import type { TypedDocumentNode } from '@apollo/client';
import type { WatchQueryFetchPolicy } from '@apollo/client';

// @public (undocumented)
type InferContextValueFromResolvers<TResolvers> = TResolvers extends {
Expand Down Expand Up @@ -91,14 +92,15 @@ export class LocalState<TResolvers extends LocalState.Resolvers = LocalState.Res
]);
addResolvers(resolvers: TResolvers): void;
// (undocumented)
execute<TData = unknown, TVariables extends OperationVariables = OperationVariables>({ document, client, context, remoteResult, variables, onlyRunForcedResolvers, returnPartialData, }: {
execute<TData = unknown, TVariables extends OperationVariables = OperationVariables>({ document, client, context, remoteResult, variables, onlyRunForcedResolvers, returnPartialData, fetchPolicy, }: {
document: DocumentNode | TypedDocumentNode<TData, TVariables>;
client: ApolloClient;
context: DefaultContext | undefined;
remoteResult: FormattedExecutionResult<any> | undefined;
variables: TVariables | undefined;
onlyRunForcedResolvers?: boolean;
returnPartialData?: boolean;
fetchPolicy: WatchQueryFetchPolicy;
}): Promise<FormattedExecutionResult<TData>>;
// (undocumented)
getExportedVariables<TVariables extends OperationVariables = OperationVariables>({ document, client, context, variables, }: {
Expand Down
4 changes: 3 additions & 1 deletion .api-reports/api-report-react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,9 @@ export namespace useMutation {
}
]) => Promise<ApolloClient.MutateResult<MaybeMasked<TData>>>;
// (undocumented)
export type MutationFunctionOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache> = Options<TData, TVariables, TCache>;
export type MutationFunctionOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache> = Options<TData, TVariables, TCache> & {
context?: DefaultContext | ((hookContext: DefaultContext | undefined) => DefaultContext);
};
// (undocumented)
export interface Options<TData = unknown, TVariables extends OperationVariables = OperationVariables, TCache extends ApolloCache = ApolloCache, TConfiguredVariables extends Partial<TVariables> = Partial<TVariables>> {
awaitRefetchQueries?: boolean;
Expand Down
17 changes: 14 additions & 3 deletions .api-reports/api-report-utilities_internal.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,20 @@ export type DecoratedPromise<TValue> = PendingPromise<TValue> | FulfilledPromise
export function decoratePromise<TValue>(promise: Promise<TValue>): DecoratedPromise<TValue>;

// @internal @deprecated (undocumented)
export class DeepMerger<TContextArgs extends any[]> {
export namespace DeepMerger {
// (undocumented)
export type ArrayMergeStrategy = "truncate" | "combine";
// (undocumented)
export interface Options {
// (undocumented)
arrayMerge?: DeepMerger.ArrayMergeStrategy;
}
}

// @internal @deprecated (undocumented)
export class DeepMerger<TContextArgs extends any[] = any[]> {
// Warning: (ae-forgotten-export) The symbol "ReconcilerFunction" needs to be exported by the entry point index.d.ts
constructor(reconciler?: ReconcilerFunction<TContextArgs>);
constructor(reconciler?: ReconcilerFunction<TContextArgs>, options?: DeepMerger.Options);
// (undocumented)
isObject: typeof isNonNullObject;
// (undocumented)
Expand Down Expand Up @@ -449,7 +460,7 @@ export type VariablesOption<TVariables extends OperationVariables> = {} extends

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

// (No @packageDocumentation comment for this package)

Expand Down
26 changes: 19 additions & 7 deletions .api-reports/api-report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export abstract class ApolloCache {
abstract removeOptimistic(id: string): void;
// (undocumented)
abstract reset(options?: Cache_2.ResetOptions): Promise<void>;
resolvesClientField?(typename: string, fieldName: string): boolean;
abstract restore(serializedState: unknown): this;
// (undocumented)
transformDocument(document: DocumentNode): DocumentNode;
Expand Down Expand Up @@ -201,6 +202,13 @@ export namespace ApolloClient {
variables?: TVariables;
}
}
// (undocumented)
export interface Experiment {
// (undocumented)
(this: ApolloClient, options: ApolloClient.Options): void;
// (undocumented)
v: 1;
}
// Warning: (ae-forgotten-export) The symbol "VariablesOption" needs to be exported by the entry point index.d.ts
//
// (undocumented)
Expand Down Expand Up @@ -242,6 +250,7 @@ export namespace ApolloClient {
documentTransform?: DocumentTransform;
// (undocumented)
enhancedClientAwareness?: ClientAwarenessLink.EnhancedClientAwarenessOptions;
experiments?: ApolloClient.Experiment[];
// Warning: (ae-forgotten-export) The symbol "Incremental" needs to be exported by the entry point index.d.ts
incrementalHandler?: Incremental.Handler<any>;
link: ApolloLink;
Expand Down Expand Up @@ -1373,6 +1382,8 @@ export class InMemoryCache extends ApolloCache {
// (undocumented)
reset(options?: Cache_2.ResetOptions): Promise<void>;
// (undocumented)
resolvesClientField(typename: string, fieldName: string): boolean;
// (undocumented)
restore(data: NormalizedCacheObject): this;
// (undocumented)
retain(rootId: string, optimistic?: boolean): number;
Expand Down Expand Up @@ -1569,14 +1580,15 @@ class LocalState<TResolvers extends LocalState.Resolvers = LocalState.Resolvers<
]);
addResolvers(resolvers: TResolvers): void;
// (undocumented)
execute<TData = unknown, TVariables extends OperationVariables = OperationVariables>({ document, client, context, remoteResult, variables, onlyRunForcedResolvers, returnPartialData, }: {
execute<TData = unknown, TVariables extends OperationVariables = OperationVariables>({ document, client, context, remoteResult, variables, onlyRunForcedResolvers, returnPartialData, fetchPolicy, }: {
document: DocumentNode | TypedDocumentNode<TData, TVariables>;
client: ApolloClient;
context: DefaultContext | undefined;
remoteResult: FormattedExecutionResult<any> | undefined;
variables: TVariables | undefined;
onlyRunForcedResolvers?: boolean;
returnPartialData?: boolean;
fetchPolicy: WatchQueryFetchPolicy;
}): Promise<FormattedExecutionResult<TData>>;
// (undocumented)
getExportedVariables<TVariables extends OperationVariables = OperationVariables>({ document, client, context, variables, }: {
Expand Down Expand Up @@ -2711,13 +2723,13 @@ interface WriteContext extends ReadMergeModifyContext {
// src/cache/inmemory/policies.ts:167:3 - (ae-forgotten-export) The symbol "KeySpecifier" needs to be exported by the entry point index.d.ts
// src/cache/inmemory/policies.ts:167:3 - (ae-forgotten-export) The symbol "KeyArgsFunction" needs to be exported by the entry point index.d.ts
// src/cache/inmemory/types.ts:134:3 - (ae-forgotten-export) The symbol "KeyFieldsFunction" needs to be exported by the entry point index.d.ts
// src/core/ApolloClient.ts:159:5 - (ae-forgotten-export) The symbol "IgnoreModifier" needs to be exported by the entry point index.d.ts
// src/core/ApolloClient.ts:353:5 - (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:361:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/ApolloClient.ts:168:5 - (ae-forgotten-export) The symbol "IgnoreModifier" needs to be exported by the entry point index.d.ts
// src/core/ApolloClient.ts:362:5 - (ae-forgotten-export) The symbol "NextFetchPolicyContext" needs to be exported by the entry point index.d.ts
// src/core/ObservableQuery.ts:368:5 - (ae-forgotten-export) The symbol "QueryManager" needs to be exported by the entry point index.d.ts
// src/core/QueryManager.ts:180:5 - (ae-forgotten-export) The symbol "MutationStoreValue" needs to be exported by the entry point index.d.ts
// src/local-state/LocalState.ts:147:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/local-state/LocalState.ts:200:7 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/local-state/LocalState.ts:243:7 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/local-state/LocalState.ts:149:5 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/local-state/LocalState.ts:202:7 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts
// src/local-state/LocalState.ts:245:7 - (ae-forgotten-export) The symbol "LocalState" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
23 changes: 23 additions & 0 deletions .changeset/big-flowers-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
"@apollo/client": minor
---

You can now provide a callback function as the `context` option on the `mutate` function returned by `useMutation`. The callback function is called with the value of the `context` option provided to the `useMutation` hook. This is useful if you'd like to merge the context object provided to the `useMutation` hook with a value provided to the `mutate` function.


```ts
function MyComponent() {
const [mutate, result] = useMutation(MUTATION, {
context: { foo: true }
});

async function runMutation() {
await mutate({
// sends context as { foo: true, bar: true }
context: (hookContext) => ({ ...hookContext, bar: true })
});
}

// ...
}
```
5 changes: 5 additions & 0 deletions .changeset/cold-kiwis-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": minor
---

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.
7 changes: 7 additions & 0 deletions .changeset/flat-worms-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@apollo/client": minor
---

Don't set the fallback value of a `@client` field to `null` when a `read` function is defined. Instead the `read` function will be called with an `existing` value of `undefined` to allow default arguments to be used to set the returned value.

When a `read` function is not defined nor is there a defined resolver for the field, warn and set the value to `null` only in that instance.
5 changes: 5 additions & 0 deletions .changeset/funny-bats-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Fix an issue where calling `fetchMore` with `@defer` or `@stream` would not rerender incremental results as they were streamed.
Loading