Skip to content

feat(query): streamedOptions#516

Merged
dinwwwh merged 11 commits intomainfrom
feat/query/streamedOptions
May 20, 2025
Merged

feat(query): streamedOptions#516
dinwwwh merged 11 commits intomainfrom
feat/query/streamedOptions

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented May 19, 2025

Summary by CodeRabbit

  • New Features
    • Introduced experimental streamed query support in React, Solid, Svelte, and Vue Query integrations, enabling queries with async iterable/event iterator outputs.
    • Added experimental_streamedOptions method for configuring streamed queries with refetch modes and improved type inference.
    • Added a new documentation section detailing streamed query configuration and usage.
  • Tests
    • Added extensive tests validating type safety, runtime behavior, error handling, and integration of streamed query options across all supported frameworks.
  • Documentation
    • Expanded documentation with guidance on the new streamed query utilities.
  • Chores
    • Added exports and setup for streamed query clients and utilities in test and shared modules across frameworks.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 20, 2025 1:54am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2025

Walkthrough

A new experimental streamed query feature was added across React, Solid, Svelte, and Vue query packages. This includes a new .experimental_streamedOptions utility for configuring queries that return async iterators (event streams), supporting new query key types, refetch modes, and type inference. Extensive tests, documentation, and type definitions were added to validate and demonstrate the new streaming query capabilities.

Changes

File(s) / Area Change Summary
apps/content/docs/tanstack-query/basic.md Added documentation for the new .streamedOptions utility, showing usage, parameters, and example code for configuring streamed queries.
packages/client/tests/shared.ts, packages/react-query/tests/shared.tsx, packages/solid-query/tests/shared.tsx, packages/svelte-query/tests/shared.tsx, packages/vue-query/tests/shared.tsx Added new exported constants and client setup for streamedOrpc and related handlers to support streamed query testing in all frameworks.
packages/contract/tests/shared.ts, packages/server/tests/shared.ts Introduced new streamed contract procedures, schemas, and async generator handlers for use in streaming tests.
packages/react-query/src/key.ts, packages/solid-query/src/key.ts, packages/svelte-query/src/key.ts, packages/vue-query/src/key.ts Extended KeyType to include 'streamed' for new query key support. Updated buildKey logic as needed.
packages/react-query/src/procedure-utils.ts, packages/solid-query/src/procedure-utils.ts, packages/svelte-query/src/procedure-utils.ts, packages/vue-query/src/procedure-utils.ts Added .experimental_streamedOptions method to ProcedureUtils and its implementation, generating options for streamed queries using the respective framework's query utility. Includes input validation and async iterator checks.
packages/react-query/src/types.ts, packages/solid-query/src/types.ts, packages/svelte-query/src/types.ts, packages/vue-query/src/types.ts Introduced new types and interfaces for streamed query options, refetch modes, and output inference.
packages/react-query/src/procedure-utils.test-d.ts, packages/solid-query/src/procedure-utils.test-d.ts, packages/svelte-query/src/procedure-utils.test-d.ts, packages/vue-query/src/procedure-utils.test-d.ts Added type-level tests for .experimental_streamedOptions, verifying type inference, required/optional parameters, error handling, and integration with query hooks.
packages/react-query/src/procedure-utils.test.ts, packages/solid-query/src/procedure-utils.test.ts, packages/svelte-query/src/procedure-utils.test.tsx, packages/vue-query/src/procedure-utils.test.ts Added runtime tests for .experimental_streamedOptions, covering correct option generation, async iterator enforcement, skipToken handling, and error cases.
packages/react-query/tests/e2e.test-d.ts, packages/solid-query/tests/e2e.test-d.ts, packages/svelte-query/tests/e2e.test-d.ts, packages/vue-query/tests/e2e.test-d.ts Added end-to-end type tests for streamed queries with various hooks (useQuery, useQueries, fetchQuery), checking type inference, error handling, and invalid input detection.
packages/react-query/tests/e2e.test.tsx, packages/solid-query/tests/e2e.test.tsx, packages/svelte-query/tests/e2e.test.tsx, packages/vue-query/tests/e2e.test.tsx Added integration tests for streamed queries, verifying data accumulation, refetching, error handling, and skipToken behavior in each framework.

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
Loading

Poem

🐇
Streams of data, flowing free,
Across the frameworks, joyfully!
With .streamedOptions now in play,
Async iterators lead the way.
Tests and docs, all shining bright—
Rabbits cheer this streaming delight!
🌱✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit 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.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit 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 Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


📜 Recent 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

📥 Commits

Reviewing files that changed from the base of the PR and between febf6b1 and 8528a71.

📒 Files selected for processing (12)
  • 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/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/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/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)
🚧 Files skipped from review as they are similar to previous changes (12)
  • packages/react-query/src/types.ts
  • packages/vue-query/src/types.ts
  • packages/svelte-query/src/types.ts
  • packages/solid-query/src/procedure-utils.ts
  • packages/solid-query/src/types.ts
  • packages/react-query/src/procedure-utils.test.ts
  • packages/react-query/src/procedure-utils.ts
  • packages/vue-query/src/procedure-utils.test.ts
  • packages/svelte-query/src/procedure-utils.test.tsx
  • packages/solid-query/src/procedure-utils.test.ts
  • packages/svelte-query/src/procedure-utils.ts
  • packages/vue-query/src/procedure-utils.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: publish-commit
  • GitHub Check: lint
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 19, 2025

More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@516

@orpc/client

npm i https://pkg.pr.new/@orpc/client@516

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@516

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@516

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@516

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@516

@orpc/react

npm i https://pkg.pr.new/@orpc/react@516

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@516

@orpc/server

npm i https://pkg.pr.new/@orpc/server@516

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@516

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@516

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@516

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@516

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@516

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@516

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@516

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@516

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@516

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@516

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@516

commit: 8528a71

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (17)
packages/vue-query/src/types.ts (1)

46-48: Consider documenting empty interface.

The experimental_StreamedOptionsBase interface extends QueryOptionsBase without 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 than streamedOrpc.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 absence

The current test only checks that query.data extends undefined.
A stricter guarantee would be to assert that experimental_streamedOptions itself 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 not thenable.
The extra await does not harm, but it adds confusion: readers may assume the call resolves the stream before it is consumed.

Recommend dropping the await for 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 original experimental_streamedQuery

The 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 a queryFn that 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 on mock.results

Using vi.mocked(streamedQuery).mock.results[0]!.value ties 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 into mock.results.

packages/svelte-query/src/procedure-utils.test.tsx (2)

6-13: Use a lightweight stub for experimental_streamedQuery

Same 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 internals

As 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 name

The describe block is named .streamedOptions, yet the method under test is experimental_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.queryFn is compared against vi.mocked(experimental_streamedQuery).mock.results[0]!.value.
If another call to experimental_streamedQuery is ever introduced (e.g., in a test beforeAll) the index 0 will shift and silently break the assertion.

Prefer an intent–driven assertion such as checking that experimental_streamedQuery returned the value assigned to options.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 tests

The describe label should reference experimental_streamedOptions for clarity and parity with the code under test.

-describe('.streamedOptions', async () => {
+describe('.experimental_streamedOptions', async () => {

110-115: Brittle assertion pattern

Identical to the Solid test: avoid hard-coding mock.results[0].
Use an assertion that confirms some call returned options.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

steamedQuery should be streamedQuery.

- * 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 test

The 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

📥 Commits

Reviewing files that changed from the base of the PR and between f4ed9ab and 7953361.

📒 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' to KeyType properly 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' in KeyType aligns 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' to KeyType supports the experimental streamedOptions feature in Svelte Query.

packages/svelte-query/tests/shared.tsx (2)

2-2: Import streamed client for Svelte tests. The new streamedClient import provides the necessary fixture to exercise streamed queries in Svelte Query tests.


6-6: Export streamedOrpc utility. The new streamedOrpc instance 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 .streamedOptions utility for Event Iterator–based queries.


38-45: Verify code snippet matches API. The example uses orpc.streamed.experimental_streamedOptions, but in code it may be exposed differently (e.g., orpc.<procedure>.experimental_streamedOptions or via a streamedOrpc client). 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 support

The 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 Query

The 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 Query

The 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 router

The 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 ts

Length 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 ContractProcedure and eventIterator which 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 eventIterator follows a clean approach to enable async iteration over individual events.


62-73: Proper implementation of streamed procedure.

The new streamed procedure 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 streamedHandler and streamedOrpc correctly 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 skipToken with 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 streamedOutputSchema for type definitions in this file.


4-4: Good import structure.

Importing streamed as streamedContract maintains a clean pattern consistent with how other contract procedures are imported.


56-62: Well-implemented async generator.

The streamedHandler is 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 streamed procedure 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_streamedOptions works correctly with useQuery:

  • 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 fetchQuery is 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_streamedOptions covers all essential scenarios:

  • Optional vs. required inputs and context
  • Type inference for input and context parameters
  • Behavior with non-event iterator outputs
  • Integration with createQuery and fetchQuery
  • 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_streamedOptions in Solid Query correctly mirrors the equivalent tests in Svelte Query, while accounting for the framework-specific differences (such as using useQuery instead of createQuery). 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 KeyType now 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:

  1. Add a default empty object for the options parameter
  2. 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 streamedHandler and streamedOrpc which 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 skipToken is 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 streamedOrpc along with existing imports from the shared file.


140-189: Well-structured tests for streamed options.

The test suite for .streamedOptions follows 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 streamedOrpc along 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 computed refs.


126-126: Correct type checking for Vue reactive streamed data.

Appropriate type assertion for the streamed query result: { output: string }[] | undefined. The undefined is 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_streamedQuery to support the new streamed query functionality.


38-40: Good type utility for streamed queries.

The experimental_StreamedRefetchMode correctly extracts the refetch mode parameter type from experimental_streamedQuery. The experimental_InferStreamedOutput utility type provides clean type inference for streamed query results.


42-45: Well-designed streamed options input type.

The experimental_StreamedOptionsIn type 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 streamedHandler and streamedOrpc required 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 streamedHandler from server tests and streamedOrpc client 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 skipToken with 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 streamedOrpc client 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 fetchQuery returns 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_streamedOptions instead of streamedOrpc.streamed.experimental_streamedOptions which 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 streamedOrpc client consistently:


🏁 Script executed:

#!/bin/bash
# Check if orpc.ping has experimental_streamedOptions method
rg "experimental_streamedOptions" "packages/solid-query/" -A 2 -B 2

Length of output: 11405


Tests Intentionally Cover Both Clients

The mixed use of streamedOrpc.streamed.experimental_streamedOptions (for valid streaming-client cases) and orpc.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_streamedQuery from @tanstack/svelte-query is 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_InferStreamedOutput utility 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_StreamedOptionsIn type properly extends the existing query options with the streaming-specific refetchMode property 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_streamedQuery with the alias streamedQuery makes 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_StreamedRefetchMode extracts the refetch mode from parameters
  • experimental_InferStreamedOutput properly infers element types from AsyncIterables

This 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_StreamedOptionsBase is 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_streamedOptions is probably not a streamed procedure

The previous tests invoke streamedOrpc.streamed.experimental_streamedOptions, which clearly belongs to a streamed procedure returning an AsyncIterable.
Switching back to the non-streamed client (orpc.ping) here is surprising; unless ping really 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-error if the intention is to assert that the call must fail at type-level.

packages/react-query/src/types.ts (1)

17-24: experimental_StreamedRefetchMode derivation may break on TanStack upgrades

Extracting 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 into never, 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_streamedOptions compiles for non-iterator output – is that intentional?

requiredUtils is typed with a plain UtilsOutput, yet the call to experimental_streamedOptions is 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_streamedQuery in @tanstack/vue-query

The Vue-Query wrapper only recently adopted the streamed APIs and – depending on the exact version pinned in package.jsonexperimental_streamedQuery may still live in @tanstack/query-core and not be re-exported by @tanstack/vue-query.
A missing export will surface as a run-time undefined is not a function error.

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_streamedQuery is actually exported by your pinned @tanstack/vue-query version

The sandboxed grep didn’t find any experimental_streamedQuery export (likely because node_modules wasn’t populated here), so please verify against your installed package:

• Check which version of @tanstack/vue-query you have in your package.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-core instead.

Comment thread packages/solid-query/src/procedure-utils.ts
Comment thread packages/react-query/src/procedure-utils.ts
Comment thread packages/svelte-query/src/procedure-utils.ts
Comment thread packages/vue-query/src/procedure-utils.ts Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Empty streams
  2. Streams with errors
  3. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7953361 and 3d6ec42.

📒 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_streamedQuery from '@tanstack/vue-query' is correctly added to support the new streamed options functionality being tested.


3-3: Proper test dependency import.

Importing queryClient from 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_streamedQuery function 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:

  1. Mocks an async generator client returning stream values
  2. Verifies the options are enabled
  3. Confirms the query key is built with type 'streamed'
  4. Validates the streamed query function is called with expected parameters
  5. Verifies query results contain the streamed values
  6. Checks the query client cache is properly updated

123-134: Proper handling of skipToken in streamed options.

Test correctly verifies that:

  1. Options are disabled when skipToken is provided
  2. Query key is built correctly with skipToken
  3. Query function appropriately rejects when called with skipToken

136-178: Excellent reactive ref handling in streamed options.

This comprehensive test verifies the reactive behavior:

  1. With skipToken initially (disabled options)
  2. After changing to valid input (enabled options)
  3. Proper query key updates
  4. Correct streamed query execution
  5. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant