Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughA new experimental streamed query feature was added across React, Solid, Svelte, and Vue query packages. This includes a new Changes
Sequence Diagram(s)sequenceDiagram
participant UI
participant QueryUtils
participant Client
participant Server
UI->>QueryUtils: .experimental_streamedOptions({ input, context, refetchMode })
QueryUtils->>Client: client(input, { context, signal })
Client->>Server: Request with input/context
Server-->>Client: AsyncIterator (streamed output)
Client-->>QueryUtils: AsyncIterator
QueryUtils-->>UI: Array of streamed results
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. Note ⚡️ Faster reviews with cachingCodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (12)
🚧 Files skipped from review as they are similar to previous changes (12)
⏰ Context from checks skipped due to timeout of 90000ms (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
More templates
@orpc/arktype
@orpc/client
@orpc/nest
@orpc/openapi
@orpc/contract
@orpc/openapi-client
@orpc/react
@orpc/react-query
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (17)
packages/vue-query/src/types.ts (1)
46-48: Consider documenting empty interface.The
experimental_StreamedOptionsBaseinterface extendsQueryOptionsBasewithout adding any properties. Consider adding a comment explaining its purpose if it's intended as a placeholder for future extensions.+/** + * Base interface for streamed query options. Currently identical to QueryOptionsBase, + * but separated to allow for future streamed-specific additions. + */ export interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> { }packages/svelte-query/tests/e2e.test.tsx (1)
101-111: Consider using streamedOrpc key in skipToken test.The test correctly verifies the skipToken behavior, but on lines 105 and 109 it checks fetching status using
orpc.key()rather thanstreamedOrpc.key(), which would be more consistent with the query being tested.expect(get(query).status).toEqual('pending') - expect(queryClient.isFetching({ queryKey: orpc.key() })).toEqual(0) + expect(queryClient.isFetching({ queryKey: streamedOrpc.key() })).toEqual(0) await new Promise(resolve => setTimeout(resolve, 10)) - expect(queryClient.isFetching({ queryKey: orpc.key() })).toEqual(0) + expect(queryClient.isFetching({ queryKey: streamedOrpc.key() })).toEqual(0) expect(get(query).status).toEqual('pending')packages/react-query/src/types.ts (1)
25-27: Empty marker interface – remove or document its purpose
export interface experimental_StreamedOptionsBase<TOutput, TError> extends QueryOptionsBase<TOutput, TError> {}
An empty interface that just re-exports another one increases surface area with no added semantics.
If it exists for future extension, add a brief comment; otherwise consider deleting it.packages/react-query/src/procedure-utils.test-d.ts (1)
195-199: Stronger negative test could assert method absenceThe current test only checks that
query.dataextendsundefined.
A stricter guarantee would be to assert thatexperimental_streamedOptionsitself is not present on a non-streamed utils instance:// @ts-expect-error method should not exist for non-iterator outputs utils.experimental_streamedOptions()That way accidental exposure is caught at compile time rather than relying on the return type.
packages/solid-query/src/procedure-utils.ts (1)
28-33: Typo in JSDoc link – “steamedQuery” → “streamedQuery”* Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)Nit: “streamedQuery” is misspelled as “steamedQuery”.
This breaks the rendered documentation link.packages/react-query/src/procedure-utils.ts (1)
106-112:awaiting an async iterator is a no-op
await client(...)returns the iterator unchanged because an async generator is notthenable.
The extraawaitdoes not harm, but it adds confusion: readers may assume the call resolves the stream before it is consumed.Recommend dropping the
awaitfor clarity:- const output = await client(optionsIn.input, { signal, context: optionsIn.context }) + const output = client(optionsIn.input, { signal, context: optionsIn.context })packages/react-query/src/procedure-utils.test.ts (2)
6-13: Mock only what you need – avoid executing the originalexperimental_streamedQueryThe current stub wraps the real implementation:
experimental_streamedQuery: vi.fn(original.experimental_streamedQuery),That means real logic still runs inside the test environment, making the test slower and coupling it to TanStack internals.
A safer pattern is to supply a lightweight fake that mimics the public contract you rely on (returning aqueryFnthat aggregates iterator values), e.g.:experimental_streamedQuery: vi.fn(({ queryFn }) => { return async (ctx: any) => { const out: any[] = [] for await (const item of await queryFn(ctx)) out.push(item) return out } }),That keeps tests hermetic and future-proof against upstream changes.
81-89: Brittle assertion onmock.resultsUsing
vi.mocked(streamedQuery).mock.results[0]!.valueties the test to the internal layout of Vitest’s mock object.
Capturing the return value directly is clearer and more resilient:const streamedFn = vi.mocked(streamedQuery).mock.results[0]!.value expect(options.queryFn).toBe(streamedFn)—or even better, return the fake from your custom mock and assert with
toBe(streamedFn)without indexing intomock.results.packages/svelte-query/src/procedure-utils.test.tsx (2)
6-13: Use a lightweight stub forexperimental_streamedQuerySame rationale as in the React counterpart: wrapping the real implementation pulls heavyweight code into unit tests and risks brittle failures on upstream changes.
Consider replacing the current spy with a minimal deterministic fake that fulfils just the contract you verify in the tests.
81-89: Reduce coupling to Vitest internalsAs in the React tests, prefer storing the returned function in a variable instead of poking into
mock.results[0].
This makes the intent obvious and shields the test from changes in mock internals.packages/solid-query/src/procedure-utils.test.ts (2)
61-63: Misleading describe title vs. method nameThe
describeblock is named.streamedOptions, yet the method under test isexperimental_streamedOptions. This can become confusing when scanning test output or searching for failures.-describe('.streamedOptions', () => { +describe('.experimental_streamedOptions', () => {
81-87: Assertion is brittle – relies on internal mock call index
options.queryFnis compared againstvi.mocked(experimental_streamedQuery).mock.results[0]!.value.
If another call toexperimental_streamedQueryis ever introduced (e.g., in a testbeforeAll) the index0will shift and silently break the assertion.Prefer an intent–driven assertion such as checking that
experimental_streamedQueryreturned the value assigned tooptions.queryFn:expect(experimental_streamedQuery).toHaveReturnedWith(options.queryFn)This removes the hidden dependency on the order of mock invocations.
packages/vue-query/src/procedure-utils.test.ts (2)
89-91: Same naming mismatch as in Solid testsThe
describelabel should referenceexperimental_streamedOptionsfor clarity and parity with the code under test.-describe('.streamedOptions', async () => { +describe('.experimental_streamedOptions', async () => {
110-115: Brittle assertion patternIdentical to the Solid test: avoid hard-coding
mock.results[0].
Use an assertion that confirms some call returnedoptions.queryFn, e.g.:expect(experimental_streamedQuery.mock.results.some(r => r.value === options.queryFn)).toBe(true)or
toHaveReturnedWith.packages/svelte-query/src/procedure-utils.ts (1)
28-32: Typo in JSDoc –steamedQuery
steamedQueryshould bestreamedQuery.- * Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery) + * Built on top of [streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)packages/vue-query/src/procedure-utils.ts (2)
30-35: Typo in JSDoc link – “steamedQuery” → “streamedQuery”The documentation block references
steamedQuery; looks like a missing “r”.
Fixing it keeps IDE hovers and generated docs accurate.- * Built on top of [steamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery) + * Built on top of [streamedQuery](https://tanstack.com/query/latest/docs/reference/streamedQuery)
104-106: Uncovered branch – consider adding a negative-case testThe safety check that throws when the procedure does not return an async iterator
(currently uncovered per Codecov) is valuable.
Adding a unit test that mocks a non-iterator response will keep this guard from being
accidentally removed.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 105-105: packages/vue-query/src/procedure-utils.ts#L105
Added line #L105 was not covered by tests
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (36)
apps/content/docs/tanstack-query/basic.md(1 hunks)packages/client/tests/shared.ts(2 hunks)packages/contract/tests/shared.ts(2 hunks)packages/react-query/src/key.ts(2 hunks)packages/react-query/src/procedure-utils.test-d.ts(1 hunks)packages/react-query/src/procedure-utils.test.ts(2 hunks)packages/react-query/src/procedure-utils.ts(3 hunks)packages/react-query/src/types.ts(2 hunks)packages/react-query/tests/e2e.test-d.ts(3 hunks)packages/react-query/tests/e2e.test.tsx(2 hunks)packages/react-query/tests/shared.tsx(1 hunks)packages/server/tests/shared.ts(2 hunks)packages/solid-query/src/key.ts(1 hunks)packages/solid-query/src/procedure-utils.test-d.ts(1 hunks)packages/solid-query/src/procedure-utils.test.ts(2 hunks)packages/solid-query/src/procedure-utils.ts(3 hunks)packages/solid-query/src/types.ts(2 hunks)packages/solid-query/tests/e2e.test-d.ts(2 hunks)packages/solid-query/tests/e2e.test.tsx(2 hunks)packages/solid-query/tests/shared.tsx(1 hunks)packages/svelte-query/src/key.ts(1 hunks)packages/svelte-query/src/procedure-utils.test-d.ts(1 hunks)packages/svelte-query/src/procedure-utils.test.tsx(2 hunks)packages/svelte-query/src/procedure-utils.ts(3 hunks)packages/svelte-query/src/types.ts(2 hunks)packages/svelte-query/tests/e2e.test-d.ts(2 hunks)packages/svelte-query/tests/e2e.test.tsx(2 hunks)packages/svelte-query/tests/shared.tsx(1 hunks)packages/vue-query/src/key.ts(1 hunks)packages/vue-query/src/procedure-utils.test-d.ts(1 hunks)packages/vue-query/src/procedure-utils.test.ts(2 hunks)packages/vue-query/src/procedure-utils.ts(3 hunks)packages/vue-query/src/types.ts(2 hunks)packages/vue-query/tests/e2e.test-d.ts(2 hunks)packages/vue-query/tests/e2e.test.tsx(2 hunks)packages/vue-query/tests/shared.tsx(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (15)
packages/react-query/tests/shared.tsx (1)
packages/client/tests/shared.ts (2)
orpc(32-32)streamedOrpc(36-45)
packages/vue-query/src/procedure-utils.test-d.ts (4)
packages/vue-query/src/procedure-utils.ts (1)
ProcedureUtils(11-59)packages/contract/src/error.ts (1)
ErrorFromErrorMap(49-49)packages/contract/tests/shared.ts (1)
baseErrorMap(12-17)packages/vue-query/tests/shared.tsx (1)
queryClient(8-14)
packages/server/tests/shared.ts (3)
packages/contract/tests/shared.ts (4)
streamed(62-73)inputSchema(6-6)streamedOutputSchema(60-60)baseErrorMap(12-17)packages/server/src/procedure.ts (1)
Procedure(55-71)packages/server/src/context.ts (1)
Context(1-1)
packages/solid-query/src/procedure-utils.test-d.ts (4)
packages/solid-query/src/procedure-utils.ts (1)
ProcedureUtils(9-57)packages/contract/src/error.ts (1)
ErrorFromErrorMap(49-49)packages/contract/tests/shared.ts (1)
baseErrorMap(12-17)packages/solid-query/tests/shared.tsx (1)
queryClient(8-14)
packages/solid-query/tests/e2e.test.tsx (2)
packages/solid-query/tests/shared.tsx (3)
streamedOrpc(6-6)queryClient(8-14)orpc(5-5)packages/server/tests/shared.ts (1)
streamedHandler(56-62)
packages/vue-query/tests/e2e.test-d.ts (4)
packages/vue-query/tests/shared.tsx (3)
streamedOrpc(6-6)orpc(5-5)queryClient(8-14)packages/client/tests/shared.ts (2)
streamedOrpc(36-45)orpc(32-32)playgrounds/nuxt/lib/orpc.ts (1)
orpc(16-16)packages/client/tests/helpers.ts (1)
orpc(151-151)
packages/svelte-query/tests/e2e.test.tsx (3)
packages/svelte-query/tests/shared.tsx (3)
streamedOrpc(6-6)queryClient(8-14)orpc(5-5)packages/server/tests/shared.ts (1)
streamedHandler(56-62)playgrounds/svelte-kit/src/lib/orpc.ts (1)
orpc(16-16)
packages/solid-query/tests/e2e.test-d.ts (1)
packages/solid-query/tests/shared.tsx (3)
streamedOrpc(6-6)orpc(5-5)queryClient(8-14)
packages/solid-query/src/types.ts (2)
packages/react-query/src/types.ts (5)
experimental_InferStreamedOutput(19-19)experimental_StreamedOptionsIn(21-23)QueryOptionsIn(5-8)experimental_StreamedOptionsBase(25-26)QueryOptionsBase(10-15)packages/client/src/types.ts (1)
ClientContext(6-6)
packages/svelte-query/tests/e2e.test-d.ts (2)
packages/svelte-query/tests/shared.tsx (3)
streamedOrpc(6-6)orpc(5-5)queryClient(8-14)playgrounds/svelte-kit/src/lib/orpc.ts (1)
orpc(16-16)
packages/solid-query/src/procedure-utils.test.ts (1)
packages/solid-query/tests/shared.tsx (1)
queryClient(8-14)
packages/svelte-query/src/procedure-utils.test.tsx (1)
packages/svelte-query/tests/shared.tsx (1)
queryClient(8-14)
packages/vue-query/src/procedure-utils.test.ts (1)
packages/vue-query/tests/shared.tsx (1)
queryClient(8-14)
packages/vue-query/src/procedure-utils.ts (5)
packages/vue-query/src/types.ts (3)
experimental_InferStreamedOutput(40-40)experimental_StreamedOptionsIn(42-44)experimental_StreamedOptionsBase(46-47)packages/shared/src/args.ts (1)
MaybeOptionalOptions(1-3)packages/vue-query/src/utils.ts (1)
unrefDeep(12-29)packages/vue-query/src/key.ts (1)
buildKey(13-24)packages/shared/src/iterator.ts (1)
isAsyncIteratorObject(3-9)
packages/svelte-query/src/procedure-utils.ts (5)
packages/svelte-query/src/types.ts (3)
experimental_InferStreamedOutput(27-27)experimental_StreamedOptionsIn(29-31)experimental_StreamedOptionsBase(33-34)packages/shared/src/args.ts (1)
MaybeOptionalOptions(1-3)packages/svelte-query/src/key.ts (1)
buildKey(11-22)playgrounds/svelte-kit/src/lib/orpc.ts (1)
client(14-14)packages/shared/src/iterator.ts (1)
isAsyncIteratorObject(3-9)
🪛 GitHub Check: codecov/patch
packages/vue-query/src/procedure-utils.ts
[warning] 105-105: packages/vue-query/src/procedure-utils.ts#L105
Added line #L105 was not covered by tests
🔇 Additional comments (74)
packages/solid-query/src/key.ts (1)
4-4: Enable streamed query key type. Adding'streamed'toKeyTypeproperly extends the union to support streamed queries across Solid Query.packages/vue-query/src/key.ts (1)
6-6: Enable streamed query key type. Including'streamed'inKeyTypealigns this package with the new streamed query feature.packages/svelte-query/src/key.ts (1)
4-4: Enable streamed query key type. The addition of'streamed'toKeyTypesupports the experimental streamedOptions feature in Svelte Query.packages/svelte-query/tests/shared.tsx (2)
2-2: Import streamed client for Svelte tests. The newstreamedClientimport provides the necessary fixture to exercise streamed queries in Svelte Query tests.
6-6: ExportstreamedOrpcutility. The newstreamedOrpcinstance is correctly instantiated for creating streamed query options in tests.apps/content/docs/tanstack-query/basic.md (2)
34-37: Add Streamed Query Options section. The new heading and description clearly introduce the.streamedOptionsutility for Event Iterator–based queries.
38-45: Verify code snippet matches API. The example usesorpc.streamed.experimental_streamedOptions, but in code it may be exposed differently (e.g.,orpc.<procedure>.experimental_streamedOptionsor via astreamedOrpcclient). Please confirm the correct invocation path and update the snippet accordingly.packages/react-query/tests/shared.tsx (1)
2-2: Well structured addition of streamed client supportThe import and export of the streamedOrpc client follows the same pattern as the existing orpc client, providing a consistent interface for testing the new streamed query capabilities.
Also applies to: 6-6
packages/vue-query/tests/shared.tsx (1)
2-2: Consistent implementation of streamed client for Vue QueryThe addition of streamedOrpc client in the Vue Query tests mirrors the implementation in other framework adapters, ensuring consistent testing of the streamed query feature across frameworks.
Also applies to: 6-6
packages/solid-query/tests/shared.tsx (1)
2-2: Consistently implemented streamed client for Solid QueryThe streamedOrpc implementation for Solid Query follows the same pattern as other framework adapters, providing a consistent interface for testing the new streamed query capabilities.
Also applies to: 6-6
packages/client/tests/shared.ts (2)
3-3: Appropriately updated import to include streamed routerThe import has been correctly updated to include the streamed router alongside the existing router import.
34-45:Details
❓ Verification inconclusive
Properly implemented streamedOrpc client with appropriate error handling
The implementation of the streamedOrpc client follows a clear pattern, using a dedicated handler for streamed queries and providing appropriate error handling when no response is returned.
Note that the error handling differs slightly from the regular client - this one returns a 404 response when no response is found, whereas the regular client throws an error. This might be an intentional difference based on how streamed queries work.
🏁 Script executed:
#!/bin/bash # Check if there are any tests that rely on the error handling behavior of streamedOrpc echo "Looking for references to streamedOrpc client error handling in tests..." rg "streamedOrpc.*error" --type tsLength of output: 191
Confirm streamedOrpc error-handling behavior and test coverage
I searched the test suite and didn’t find any references to the streamedOrpc client’s error path. Absence of matches isn’t proof there are no dependent tests or expectations around this 404-on-missing-response behavior. Please manually verify that returning a 404 here is intentional and update or add tests as needed to cover this scenario.packages/contract/tests/shared.ts (3)
4-4: Well-structured import addition.The imports are properly extended to include
ContractProcedureandeventIteratorwhich are needed for the new streamed query functionality.
60-60: Good use of event iterator pattern.Creating a streamed version of the output schema by wrapping it with
eventIteratorfollows a clean approach to enable async iteration over individual events.
62-73: Proper implementation of streamed procedure.The new
streamedprocedure is correctly defined with:
- The same input schema as existing procedures
- The newly created streamed output schema
- Proper error handling through the base error map
- Empty metadata and routing objects as appropriate for tests
This establishes the contract foundation needed for the streamed query feature.
packages/solid-query/tests/e2e.test.tsx (3)
5-6: Appropriate imports for streamed testing.Importing
streamedHandlerandstreamedOrpccorrectly sets up the dependencies needed for the streamed query tests.
61-94: Comprehensive streamed query test implementation.This test thoroughly validates the streamed query functionality with:
- Correct query key generation and fetching state verification
- Data accumulation from the streamed response
- Refetch behavior with append mode
- Proper error handling with ORPCError
The test ensures that all aspects of the streamed query feature work as expected.
96-106: Good skipToken handling for streamed queries.This test correctly verifies that when using
skipTokenwith a streamed query:
- The query remains in a pending state
- No fetching occurs on any keys
- The state persists after a delay
This ensures proper integration with TanStack Query's skipToken functionality.
packages/server/tests/shared.ts (4)
2-2: Appropriate type imports.The type imports are correctly extended to include
streamedOutputSchemafor type definitions in this file.
4-4: Good import structure.Importing
streamed as streamedContractmaintains a clean pattern consistent with how other contract procedures are imported.
56-62: Well-implemented async generator.The
streamedHandleris properly implemented as an async generator function that:
- Takes an input and yields values incrementally
- Returns a final value when complete
- Is wrapped with vi.fn() for testing purposes
This provides a realistic simulation of a streaming data source for tests.
64-77: Correct procedure setup for streamed handling.The
streamedprocedure is properly configured with:
- Appropriate generic types matching the contract
- Zero validation indices (appropriate for tests)
- Empty middleware array
- The async generator handler
- Contract metadata properly inherited
This creates a complete server-side implementation of the streamed feature.
packages/vue-query/src/procedure-utils.test-d.ts (8)
155-157: Good test structure for streamed options.The test structure follows the established pattern of other method tests, providing consistency and clarity.
158-184: Thorough type testing for optional parameters.This test correctly verifies that:
- Options can be optional with the standard utils
- Options are correctly required with the required utils
- Type errors are properly triggered when required options are missing
This ensures proper type safety for the API.
186-193: Good input type inference verification.These tests properly verify that the input types are correctly inferred and type errors are triggered for invalid inputs.
195-199: Proper context type checking.These tests correctly verify that the context types are properly inferred and validated.
201-218: Correct Vue reactivity integration.This test verifies that the streamed options work correctly with Vue's reactivity system:
- It handles computed properties and refs as inputs
- It properly validates types within reactive wrappers
- It correctly identifies type errors in reactive expressions
This ensures the feature works well in Vue's reactive context.
220-247: Comprehensive useQuery integration testing.These tests thoroughly verify that
experimental_streamedOptionsworks correctly withuseQuery:
- It handles selection transforms
- It handles error typing
- It properly types the data result with and without initial data
This ensures type safety when using the streamed options with Vue Query hooks.
249-267: Good useQueries integration testing.This test verifies that the streamed options work correctly with
useQueries:
- Multiple queries can be configured with different options
- Data and error types are correctly inferred for each query
Ensuring type safety for advanced query use cases.
269-275: Proper fetchQuery integration testing.This test verifies that the return type from
fetchQueryis correctly inferred when using streamed options.packages/svelte-query/src/procedure-utils.test-d.ts (1)
137-225: The tests for streamed options look comprehensive and well-structured.The new test suite for
experimental_streamedOptionscovers all essential scenarios:
- Optional vs. required inputs and context
- Type inference for input and context parameters
- Behavior with non-event iterator outputs
- Integration with
createQueryandfetchQuery- Error handling
The test structure follows the established pattern of the existing tests, which ensures consistency and completeness.
packages/solid-query/src/procedure-utils.test-d.ts (1)
136-224: Solid implementation tests match the Svelte implementation pattern.The test suite for
experimental_streamedOptionsin Solid Query correctly mirrors the equivalent tests in Svelte Query, while accounting for the framework-specific differences (such as usinguseQueryinstead ofcreateQuery). This ensures consistent behavior across frameworks.packages/react-query/src/key.ts (2)
4-4: Added 'streamed' to KeyType options to support new feature.The
KeyTypenow includes 'streamed' alongside the existing query types, which is necessary for the streamed query options feature.
11-17: Improved options handling with default parameter and simplified logic.The changes to
buildKey:
- Add a default empty object for the options parameter
- Simplify the logic for conditionally including input and type properties
This refactoring makes the code cleaner while maintaining functionality.
packages/vue-query/tests/e2e.test.tsx (3)
5-6: Updated imports to support streamed query testing.Added imports for
streamedHandlerandstreamedOrpcwhich are necessary for the new streamed query tests.
67-101: Comprehensive test for streamed query functionality.This test verifies key aspects of streamed queries:
- Proper fetching state tracking with correct query keys
- Data accumulation from the event stream
- 'append' refetch mode behavior
- Error propagation and handling
The test structure follows the pattern of existing tests while adding the necessary assertions for stream-specific behavior.
103-113: Validates skipToken behavior with streamed queries.This test verifies that the query remains in a pending state and no fetching occurs when
skipTokenis provided - ensuring that the streamed query options correctly handle disabled queries.packages/react-query/tests/e2e.test-d.ts (7)
5-5: LGTM on import statement.Correctly imports the new
streamedOrpcalong with existing imports from the shared file.
140-189: Well-structured tests for streamed options.The test suite for
.streamedOptionsfollows the established pattern for testing query options. The implementation validates type checking for inputs, outputs, error handling, and retry functionality.
157-159: Correct array typing for streamed data.Good type assertion for streamed query results as an array, which properly reflects how streamed data accumulates over time.
161-175: Effective type error tests.The type error tests effectively validate that incorrect inputs and invalid context configurations are properly caught at compile time.
211-247: Comprehensive testing of useQueries with mixed query types.The test includes both streamed and regular queries in the same useQueries call, thoroughly verifying type inference for different query result shapes.
231-234: Maintained consistency with existing FIXME comments.The FIXME comment about useQueries not inferring error types is properly maintained in the new test, ensuring consistency with the existing test patterns.
249-255: Concise fetchQuery test.The fetchQuery test effectively verifies that the streamed query result is correctly typed as an array.
packages/vue-query/tests/e2e.test-d.ts (5)
6-6: LGTM on Vue import update.Correctly imports the new
streamedOrpcalong with existing imports.
109-142: Well-structured useQuery test for Vue streamed options.The test follows Vue Query patterns with reactive properties and correctly tests the streamed query options with Vue-specific constructs like
computedrefs.
126-126: Correct type checking for Vue reactive streamed data.Appropriate type assertion for the streamed query result:
{ output: string }[] | undefined. Theundefinedis included to handle Vue's reactivity model, which is correct.
144-180: Thorough useQueries test for Vue.The test verifies multiple queries including a mix of streamed and regular queries. The FIXME comment matches the existing pattern in the codebase.
182-188: Concise fetchQuery test for Vue.Tests the fetchQuery functionality with streamed options and verifies the correct array return type.
packages/vue-query/src/types.ts (3)
3-3: LGTM on import update.The import statement correctly adds
experimental_streamedQueryto support the new streamed query functionality.
38-40: Good type utility for streamed queries.The
experimental_StreamedRefetchModecorrectly extracts the refetch mode parameter type fromexperimental_streamedQuery. Theexperimental_InferStreamedOutpututility type provides clean type inference for streamed query results.
42-45: Well-designed streamed options input type.The
experimental_StreamedOptionsIntype extends the existing query options with the refetch mode parameter, maintaining type consistency with other query option types.packages/svelte-query/tests/e2e.test.tsx (3)
5-6: LGTM on import updates.Correctly imports the new
streamedHandlerandstreamedOrpcrequired for streamed query testing.
66-99: Comprehensive streamed query test case.Excellent test for streamed query functionality that verifies:
- Correct fetching indicators for various query keys
- Accurate data accumulation from the streamed source
- Proper append behavior when refetching
- Error handling with custom ORPCError
The test is thorough and well-structured, following the established patterns in the file.
87-90: Good verification of append refetch mode.The test specifically checks that the refetch operation correctly appends new data to the existing results, which is a key feature of streamed queries.
packages/react-query/tests/e2e.test.tsx (3)
5-6: Import changes align with the new streaming feature.The new imports provide access to the
streamedHandlerfrom server tests andstreamedOrpcclient from shared test utilities, which are essential for testing the new streamed query functionality.
61-94: Comprehensive test coverage for streamed query functionality.This test case thoroughly validates the new streaming features with solid test coverage for:
- Query key hierarchical fetching states
- Data accumulation from the stream
- Append-mode refetch behavior
- Error handling with proper ORPCError propagation
The test structure is consistent with existing tests and follows the same pattern for thorough validation.
96-106: Proper handling of skipToken in streamed queries.This test correctly verifies that using
skipTokenwith streamed queries behaves as expected:
- The query remains in pending state
- No fetching operations occur
- Status remains pending even after a delay
This ensures consistent behavior with the existing skipToken patterns in regular queries.
packages/solid-query/tests/e2e.test-d.ts (5)
5-5: Import updated to include streamedOrpc client.The import now includes the
streamedOrpcclient needed for testing the new streaming functionality.
112-132: Well-structured type tests for useQuery with streamed options.The test correctly validates type inference and error handling for streamed queries, ensuring:
- Proper type inference for error data when using the retry callback
- Correct typing of success data as an array of outputs (
{ output: string }[])- Type safety for error objects
This approach is consistent with existing type tests for regular queries.
149-185: Type tests for useQueries with streamed options.The test properly validates the type behavior of streamed options with
useQueries:
- Correct typing for mapped data in success state
- Proper error type handling
- Type checking for the second query
The commented-out code about useQueries not being able to infer error types matches the pattern in the existing tests, showing consistency in approach.
187-194: Type tests for fetchQuery with streamed options.The test correctly validates that
fetchQueryreturns the expected array type for streamed queries. This completes the coverage of all query methods with the new streaming functionality.
133-146:Details
✅ Verification successful
Inconsistent client usage in type tests.
The test uses
orpc.ping.experimental_streamedOptionsinstead ofstreamedOrpc.streamed.experimental_streamedOptionswhich was used in the previous test. This inconsistency may be intentional to test both clients, but it could lead to confusion.Check if this is an intentional test case or if it should be using the
streamedOrpcclient consistently:
🏁 Script executed:
#!/bin/bash # Check if orpc.ping has experimental_streamedOptions method rg "experimental_streamedOptions" "packages/solid-query/" -A 2 -B 2Length of output: 11405
Tests Intentionally Cover Both Clients
The mixed use of
streamedOrpc.streamed.experimental_streamedOptions(for valid streaming-client cases) andorpc.ping.experimental_streamedOptions(for non-streamed client type-error checks) in packages/solid-query/tests/e2e.test-d.ts is deliberate—these lines independently verify typing behavior on both client variants. No change is required.packages/svelte-query/src/types.ts (4)
7-7: Added import for experimental_streamedQuery.The import of
experimental_streamedQueryfrom@tanstack/svelte-queryis necessary to support the new streaming functionality.
25-27: Well-defined utility types for streamed queries.The type definition extracts the refetch mode from the experimental API parameters, ensuring type safety when this option is used. The
experimental_InferStreamedOutpututility type elegantly infers the element type from an AsyncIterable and converts it to an array type.
29-32: Type-safe options for streamed queries.The
experimental_StreamedOptionsIntype properly extends the existing query options with the streaming-specificrefetchModeproperty while preserving all the type safety of the base options.
33-35: Base interface for streamed options.This interface extends the base query options without adding new members, providing a proper foundation for streamed queries that maintains compatibility with the existing query structure.
packages/solid-query/src/types.ts (3)
10-10: Import with alias for experimental_streamedQuery.Importing
experimental_streamedQuerywith the aliasstreamedQuerymakes the code more readable while still clearly indicating this is an experimental API.
25-28: Consistent type definitions for streamed queries.These types mirror those in the Svelte Query implementation, maintaining consistency across framework implementations:
experimental_StreamedRefetchModeextracts the refetch mode from parametersexperimental_InferStreamedOutputproperly infers element types from AsyncIterablesThis consistency helps developers who work across multiple frameworks.
29-35: Type-safe options for Solid streamed queries.The streamed options types extend the base query options with streaming-specific properties while preserving type safety. The empty interface extension pattern for
experimental_StreamedOptionsBaseis clean and consistent with the implementation in other framework packages.packages/svelte-query/tests/e2e.test-d.ts (1)
140-148: Potentially incorrect utility –orpc.ping.experimental_streamedOptionsis probably not a streamed procedureThe previous tests invoke
streamedOrpc.streamed.experimental_streamedOptions, which clearly belongs to a streamed procedure returning anAsyncIterable.
Switching back to the non-streamed client (orpc.ping) here is surprising; unlesspingreally does return an event iterator, this will silently compile but never yield streamed data at runtime.Please double-check the contract for
ping. If it is not streamed, consider either:-createQuery(orpc.ping.experimental_streamedOptions({ +// Was this intended to be the streamed variant? +createQuery(streamedOrpc.streamed.experimental_streamedOptions({or prepend
// @ts-expect-errorif the intention is to assert that the call must fail at type-level.packages/react-query/src/types.ts (1)
17-24:experimental_StreamedRefetchModederivation may break on TanStack upgradesExtracting the type via
type experimental_StreamedRefetchMode = Exclude<Parameters<typeof experimental_streamedQuery>[0]['refetchMode'], undefined>couples our public API to TanStack’s internal parameter order & naming.
If TanStack refactors that signature the type will silently turn intonever, cascading through user code.Consider shielding against this with an explicit re-export type guard, e.g.:
// Narrow to the string/enum union we actually support today export type experimental_StreamedRefetchMode = 'on-window-focus' | 'always' | 'never';and update manually when upstream changes instead of relying on structural inference.
packages/react-query/src/procedure-utils.test-d.ts (1)
152-178:requiredUtils.experimental_streamedOptionscompiles for non-iterator output – is that intentional?
requiredUtilsis typed with a plainUtilsOutput, yet the call toexperimental_streamedOptionsis not annotated with@ts-expect-error.
Given the “not usable in non event iterator output” test below, allowing the overload here dilutes the assertion.If the intent is really to forbid this usage, add the expectation:
// @ts-expect-error output is not an AsyncIterable requiredUtils.experimental_streamedOptions({ ... })to make the contract explicit.
packages/vue-query/src/procedure-utils.ts (1)
4-6:Details
❓ Verification inconclusive
Confirm availability of
experimental_streamedQueryin@tanstack/vue-queryThe Vue-Query wrapper only recently adopted the streamed APIs and – depending on the exact version pinned in
package.json–experimental_streamedQuerymay still live in@tanstack/query-coreand not be re-exported by@tanstack/vue-query.
A missing export will surface as a run-timeundefined is not a functionerror.Please double-check that the project depends on a commit / tag that does export this helper (or adjust the import path).
You can verify quickly with:
🏁 Script executed:
#!/usr/bin/env bash grep -R --line-number "export .*experimental_streamedQuery" "$(npm root)/@tanstack" || echo "export not found"Length of output: 687
Confirm that
experimental_streamedQueryis actually exported by your pinned@tanstack/vue-queryversionThe sandboxed grep didn’t find any
experimental_streamedQueryexport (likely becausenode_moduleswasn’t populated here), so please verify against your installed package:• Check which version of
@tanstack/vue-queryyou have in yourpackage.json.
• Inspect your local install for the export, e.g.:grep -R "experimental_streamedQuery" -n node_modules/@tanstack/vue-query # or check the TypeScript typings: grep -R "export .*experimental_streamedQuery" -n node_modules/@tanstack/vue-query/dist• If it’s not re-exported by
vue-query, either bump to a version that does or import directly from@tanstack/query-coreinstead.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/vue-query/src/procedure-utils.test.ts (2)
116-117: Consider verifying the final return value from the async generator.The test verifies that
['__1__', '__2__']are collected from yields, but doesn't check if the final return value'__3__'is handled. Consider adding a test case to verify how return values from async generators are processed, or document why they're intentionally excluded.
91-95: Consider testing different stream patterns.The current tests use a simple pattern of two yields and a return. Consider adding tests with:
- Empty streams
- Streams with errors
- Streams with more complex data structures
This would ensure the streaming functionality is robust across various scenarios.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
📒 Files selected for processing (1)
packages/vue-query/src/procedure-utils.test.ts(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/vue-query/src/procedure-utils.test.ts (1)
packages/vue-query/tests/shared.tsx (1)
queryClient(8-14)
🔇 Additional comments (8)
packages/vue-query/src/procedure-utils.test.ts (8)
1-1: Appropriate import for the new experimental feature.The import of
experimental_streamedQueryfrom '@tanstack/vue-query' is correctly added to support the new streamed options functionality being tested.
3-3: Proper test dependency import.Importing
queryClientfrom shared test utilities ensures consistent query client usage across tests.
7-14: Well-structured mock for testing.Good approach using vi.mock to spy on the
experimental_streamedQueryfunction while preserving the original implementation. This allows verification of how the function is called during tests.
19-19: Good test hygiene with queryClient clearing.Adding
queryClient.clear()ensures tests start with a clean state, preventing cross-test contamination.
89-121: Comprehensive test case for streamed options without skipToken.The test correctly:
- Mocks an async generator client returning stream values
- Verifies the options are enabled
- Confirms the query key is built with type 'streamed'
- Validates the streamed query function is called with expected parameters
- Verifies query results contain the streamed values
- Checks the query client cache is properly updated
123-134: Proper handling of skipToken in streamed options.Test correctly verifies that:
- Options are disabled when skipToken is provided
- Query key is built correctly with skipToken
- Query function appropriately rejects when called with skipToken
136-178: Excellent reactive ref handling in streamed options.This comprehensive test verifies the reactive behavior:
- With skipToken initially (disabled options)
- After changing to valid input (enabled options)
- Proper query key updates
- Correct streamed query execution
- Expected cache updates
This is crucial for Vue's reactivity system integration.
180-187: Good error handling test for unsupported outputs.The test correctly verifies that non-iterable outputs are rejected with an appropriate error message, ensuring the API is used correctly with async iterators only.
Summary by CodeRabbit
experimental_streamedOptionsmethod for configuring streamed queries with refetch modes and improved type inference.