Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
49873cb
Add stream tests
jerelmiller Sep 9, 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
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
562e219
Add changeset
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
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
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
17 changes: 14 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
2 changes: 1 addition & 1 deletion .api-reports/api-report-utilities_internal.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,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
8 changes: 8 additions & 0 deletions .changeset/six-islands-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@apollo/client": minor
---

Add support for the `@stream` directive on both the `Defer20220824Handler` and the `GraphQL17Alpha2Handler`.

> [!NOTE]
> 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.
8 changes: 4 additions & 4 deletions .size-limits.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 44206,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 39060,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33462,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27490
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 44194,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 39041,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33526,
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27519
}
6 changes: 6 additions & 0 deletions src/__tests__/__snapshots__/exports.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,21 @@ Array [
"ObservableStream",
"actAsync",
"addDelayToMocks",
"asyncIterableSubject",
"createClientWrapper",
"createMockWrapper",
"createOperationWithDefaultContext",
"enableFakeTimers",
"executeSchemaGraphQL17Alpha2",
"executeSchemaGraphQL17Alpha9",
"executeWithDefaultContext",
"friendListSchemaGraphQL17Alpha2",
"friendListSchemaGraphQL17Alpha9",
"markAsStreaming",
"mockDefer20220824",
"mockDeferStreamGraphQL17Alpha9",
"mockMultipartSubscriptionStream",
"promiseWithResolvers",
"renderAsync",
"renderHookAsync",
"resetApolloContext",
Expand Down
43 changes: 43 additions & 0 deletions src/cache/inmemory/__tests__/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,49 @@ describe("Cache", () => {
});
}
);

it("does not write @stream directive as part of the cache key", () => {
const cache = new InMemoryCache();

cache.writeQuery({
data: {
list: [{ __typename: "Item", id: "1", value: 1 }],
},
query: gql`
query {
list @stream(initialCount: 1) {
id
value
}
}
`,
});

expect(cache.extract()).toStrictEqualTyped({
ROOT_QUERY: {
__typename: "Query",
list: [{ __ref: "Item:1" }],
},
"Item:1": { __typename: "Item", id: "1", value: 1 },
});

// We should be able to read the list without the `@stream` directive and
// get back results
expect(
cache.readQuery({
query: gql`
query {
list {
id
value
}
}
`,
})
).toStrictEqualTyped({
list: [{ __typename: "Item", id: "1", value: 1 }],
});
});
});

describe("writeFragment", () => {
Expand Down
Loading