Skip to content

feat(tanstack-query): live query options#721

Merged
dinwwwh merged 5 commits into
mainfrom
feat/tanstack-query/live-options
Jul 3, 2025
Merged

feat(tanstack-query): live query options#721
dinwwwh merged 5 commits into
mainfrom
feat/tanstack-query/live-options

Conversation

@dinwwwh
Copy link
Copy Markdown
Member

@dinwwwh dinwwwh commented Jul 3, 2025

Use .liveOptions to configure live queries for Event Iterator. Unlike .streamedOptions which accumulates chunks, live queries replace the entire result with each new chunk received

const query = useQuery(orpc.live.experimental_liveOptions({
  input: { id: 123 }, // Specify input if needed
  context: { cache: true }, // Provide client context if needed
  // additional options...
}))

Summary by CodeRabbit

  • New Features

    • Introduced experimental support for "live queries," enabling real-time data updates that replace the entire result with each new chunk.
    • Added new utility methods for generating live query keys and options, compatible with popular query hooks (e.g., useQuery, prefetchQuery).
    • Enhanced documentation with detailed explanations and examples for live queries.
  • Bug Fixes

    • Improved error handling for invalid or unsupported live query outputs.
  • Tests

    • Added comprehensive test suites for live query utilities across React, Solid, Svelte, Vue, and Angular integrations, ensuring correct behavior and type inference.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jul 3, 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 Jul 3, 2025 3:52am

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jul 3, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 3, 2025

Walkthrough

This update introduces "live query" support to the TanStack Query integration. It adds new utilities, types, and documentation for live queries, including experimental_liveKey and experimental_liveOptions methods, a type for extracting live query output, and a core experimental_liveQuery function. Comprehensive type and runtime tests for all supported frameworks (React, Vue, Svelte, Solid, Angular) are included, and documentation is updated with usage examples and clarifications.

Changes

File(s) Change Summary
packages/tanstack-query/src/procedure-utils.ts, packages/tanstack-query/src/types.ts Added live query support: new methods (experimental_liveKey, experimental_liveOptions), type alias, and operation type.
packages/tanstack-query/src/live-query.ts Introduced experimental_liveQuery function for handling async iterable live queries.
apps/content/docs/integrations/tanstack-query.md Enhanced documentation: clarified streamed options, added live options section, updated code examples.
packages/tanstack-query/src/procedure-utils.test.ts Added runtime tests for live query utilities and error handling.
packages/tanstack-query/src/procedure-utils.test-d.ts Added type-level tests for .liveKey and .liveOptions methods.
packages/tanstack-query/src/procedure-utils.react.test-d.ts,
...vue.test-d.ts,
...svelte.test-d.ts,
...solid.test-d.ts,
...angular.test-d.ts
Added type-level tests for .liveOptions with framework-specific query utilities, focusing on type inference and behavior.
packages/tanstack-query/src/live-query.test.ts,
packages/tanstack-query/tests/live-query.test.tsx
Added runtime tests for experimental_liveQuery in Node and React environments.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Hook as Query Hook (e.g., useQuery)
    participant Utils as ProcedureUtils.experimental_liveOptions
    participant Client as Query Client
    participant LiveQuery as experimental_liveQuery

    User->>Hook: Calls useQuery with liveOptions
    Hook->>Utils: Requests liveOptions (input, context)
    Utils->>Client: Prepares queryFn (expects async iterable)
    Hook->>LiveQuery: Calls queryFn (via experimental_liveQuery)
    LiveQuery->>Client: Invokes client with input/context
    Client-->>LiveQuery: Returns async iterable
    loop For each chunk
        LiveQuery->>Hook: Updates query cache with chunk
    end
    LiveQuery->>Hook: Returns last chunk as result
Loading

Poem

A live query hopped into view,
Streaming fresh data, not just a few!
With every chunk, the cache renews,
And tests abound in every hue.
Now TanStack’s garden grows more bright,
With live updates, day and night!
🥕✨
✨ 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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the TanStack Query integration by introducing a new "live query" mechanism. This feature enables applications to consume real-time data streams where each new data point completely replaces the previous one, offering a distinct and powerful alternative to the existing streamed queries that accumulate data. The changes include core implementation, comprehensive documentation, and extensive testing across multiple frontend frameworks to ensure broad compatibility and stability.

Highlights

  • New Live Query Functionality: Introduced experimental_liveQuery and experimental_liveOptions to support real-time data updates. Unlike streamed queries that accumulate chunks, live queries replace the entire query result with each new chunk received from an Event Iterator, providing immediate reflection of the latest state.
  • Comprehensive Documentation: Added a new section in the tanstack-query.md documentation detailing the usage and behavior of .liveOptions, including code examples and notes on integration with Client Retry for enhanced reliability.
  • Cross-Framework Integration: Extended type definition tests and utility functions to ensure seamless integration and correct type inference for live queries across various frontend frameworks, including React, Angular, Solid.js, Svelte, and Vue.js.
  • Robust Testing: Introduced new unit tests for experimental_liveQuery and experimental_liveOptions, covering core functionality, abort signal handling, skipToken behavior, and error handling for unsupported output types, ensuring the reliability of the new feature.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces liveOptions for live queries with TanStack Query. I've found one critical issue that could lead to a runtime error and a few medium-severity suggestions to improve test clarity. Once these are addressed, this will be a solid contribution.

Comment thread packages/tanstack-query/src/live-query.ts Outdated
Comment thread packages/tanstack-query/src/procedure-utils.test-d.ts Outdated
Comment thread packages/tanstack-query/src/procedure-utils.test-d.ts Outdated
Comment thread packages/tanstack-query/src/procedure-utils.test-d.ts Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jul 3, 2025

More templates

@orpc/arktype

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

@orpc/client

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

@orpc/contract

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

@orpc/experimental-durable-event-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-event-iterator@721

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@721

@orpc/nest

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

@orpc/openapi

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

@orpc/openapi-client

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

@orpc/react

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

@orpc/react-query

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

@orpc/server

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

@orpc/shared

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

@orpc/solid-query

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

@orpc/standard-server

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

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@721

@orpc/standard-server-fetch

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

@orpc/standard-server-node

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

@orpc/standard-server-peer

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

@orpc/svelte-query

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

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@721

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@721

@orpc/valibot

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

@orpc/vue-colada

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

@orpc/vue-query

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

@orpc/zod

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

commit: 9765bc0

@dinwwwh dinwwwh requested a review from Copilot July 3, 2025 03:18
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 (1)
packages/tanstack-query/src/live-query.ts (1)

12-24: Solid implementation with minor safety concerns.

The core logic correctly implements live query behavior:

  • Proper async iteration with abort signal checking
  • Cache updates on each chunk (replacing vs accumulating)
  • Clean integration with TanStack Query's QueryFunction interface

However, consider these improvements:

  return async (context) => {
    const stream = await queryFn(context)

+   let lastData: TQueryFnData | undefined
    for await (const chunk of stream) {
      if (context.signal.aborted) {
        break
      }

+     lastData = chunk
      context.client.setQueryData<TQueryFnData>(context.queryKey, chunk)
    }

-   return context.client.getQueryData(context.queryKey)!
+   return lastData ?? context.client.getQueryData(context.queryKey) as TQueryFnData
  }

This ensures we return the last emitted value even if cache retrieval fails, and removes the unsafe non-null assertion.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b782987 and 69c8401.

📒 Files selected for processing (13)
  • apps/content/docs/integrations/tanstack-query.md (3 hunks)
  • packages/tanstack-query/src/live-query.test.ts (1 hunks)
  • packages/tanstack-query/src/live-query.ts (1 hunks)
  • packages/tanstack-query/src/procedure-utils.angular.test-d.ts (1 hunks)
  • packages/tanstack-query/src/procedure-utils.react.test-d.ts (1 hunks)
  • packages/tanstack-query/src/procedure-utils.solid.test-d.ts (1 hunks)
  • packages/tanstack-query/src/procedure-utils.svelte.test-d.ts (1 hunks)
  • packages/tanstack-query/src/procedure-utils.test-d.ts (1 hunks)
  • packages/tanstack-query/src/procedure-utils.test.ts (3 hunks)
  • packages/tanstack-query/src/procedure-utils.ts (5 hunks)
  • packages/tanstack-query/src/procedure-utils.vue.test-d.ts (1 hunks)
  • packages/tanstack-query/src/types.ts (1 hunks)
  • packages/tanstack-query/tests/live-query.test.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (9)
packages/tanstack-query/src/procedure-utils.solid.test-d.ts (1)
packages/tanstack-query/tests/shared.tsx (1)
  • queryClient (8-14)
packages/tanstack-query/src/procedure-utils.svelte.test-d.ts (1)
packages/tanstack-query/tests/shared.tsx (1)
  • queryClient (8-14)
packages/tanstack-query/src/procedure-utils.react.test-d.ts (1)
packages/tanstack-query/tests/shared.tsx (1)
  • queryClient (8-14)
packages/tanstack-query/src/procedure-utils.test.ts (3)
packages/tanstack-query/tests/shared.tsx (1)
  • queryClient (8-14)
packages/tanstack-query/src/types.ts (1)
  • OPERATION_CONTEXT_SYMBOL (30-30)
packages/tanstack-query/src/index.ts (1)
  • OPERATION_CONTEXT_SYMBOL (8-8)
packages/tanstack-query/src/procedure-utils.angular.test-d.ts (1)
packages/tanstack-query/tests/shared.tsx (1)
  • queryClient (8-14)
packages/tanstack-query/src/live-query.ts (1)
packages/shared/src/index.ts (1)
  • Promisable (16-16)
packages/tanstack-query/src/procedure-utils.vue.test-d.ts (1)
packages/tanstack-query/tests/shared.tsx (1)
  • queryClient (8-14)
packages/tanstack-query/src/procedure-utils.test-d.ts (1)
packages/tanstack-query/tests/shared.tsx (1)
  • queryClient (8-14)
packages/tanstack-query/src/procedure-utils.ts (5)
packages/shared/src/args.ts (1)
  • MaybeOptionalOptions (1-3)
packages/tanstack-query/src/types.ts (6)
  • QueryKeyOptions (39-41)
  • experimental_LiveQueryOutput (16-16)
  • QueryOptionsIn (43-46)
  • QueryOptionsBase (48-54)
  • OPERATION_CONTEXT_SYMBOL (30-30)
  • OperationContext (32-37)
packages/tanstack-query/src/key.ts (1)
  • generateOperationKey (3-12)
packages/tanstack-query/src/live-query.ts (1)
  • experimental_liveQuery (4-25)
packages/shared/src/iterator.ts (1)
  • isAsyncIteratorObject (4-10)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint
  • GitHub Check: publish-commit
🔇 Additional comments (21)
packages/tanstack-query/src/types.ts (2)

16-16: LGTM! Clean type extraction for live queries.

The experimental_LiveQueryOutput type correctly extracts the yielded item type from an AsyncIterable, which is exactly what's needed for live queries that emit individual chunks rather than accumulated arrays.


20-20: Approve the OperationType extension.

Adding 'live' to the union type is consistent with the existing operation types and follows the established pattern.

packages/tanstack-query/tests/live-query.test.tsx (1)

7-40: Comprehensive test coverage for live query React integration.

This test effectively verifies the core live query behavior:

  • Sequential data updates replacing previous values (not accumulating)
  • Proper async state handling with act() and vi.waitFor()
  • Refetch functionality resetting to the first value

The test structure is solid and covers the key differences between live and streamed queries.

packages/tanstack-query/src/live-query.test.ts (1)

8-70: Excellent test coverage for live query core functionality.

These tests comprehensively verify:

  1. Sequential cache updates as chunks are yielded
  2. Proper resolution with the final value
  3. Abort signal handling with early termination
  4. Cleanup execution in generator finally blocks

The test structure effectively validates the live query contract and error handling.

packages/tanstack-query/src/procedure-utils.angular.test-d.ts (1)

161-225: Comprehensive type safety validation for Angular live queries.

This test suite effectively validates:

  • Correct data type inference (UtilsOutput[number] vs UtilsOutput)
  • Error type propagation across all Angular Query hooks
  • Integration with select, initialData, and error handling options
  • Consistency with the existing test patterns

The @ts-expect-error annotations appropriately document known TypeScript inference limitations with injectQueries.

packages/tanstack-query/src/procedure-utils.solid.test-d.ts (1)

152-213: LGTM! Comprehensive type testing for live queries.

The .liveOptions test suite correctly implements type validation for the new live query feature. The key insight that data should be typed as UtilsOutput[number] (individual items) rather than UtilsOutput (arrays) properly reflects the live query semantics where each chunk replaces the entire result.

packages/tanstack-query/src/procedure-utils.svelte.test-d.ts (1)

153-214: LGTM! Proper Svelte adaptation of live query tests.

The test suite correctly adapts the live query functionality for Svelte's reactive store patterns, using createQuery, createQueries, and get() appropriately. Type expectations are consistent with other framework implementations.

apps/content/docs/integrations/tanstack-query.md (2)

118-133: Excellent documentation for the live query feature.

The documentation clearly explains the key difference between .liveOptions and .streamedOptions - that live queries replace the entire result with each chunk rather than accumulating them. The example usage and recommendation to combine with Client Retry plugin provide practical guidance for users.


292-305: Good update to include live queries in operation context.

The addition of 'live' to the GET_OPERATION_TYPE set properly extends the HTTP method selection logic to handle the new live query operation type, maintaining consistency with existing query types.

packages/tanstack-query/src/procedure-utils.test-d.ts (2)

301-351: Comprehensive testing for live query keys.

The .liveKey test suite thoroughly validates all aspects of live query key generation, including optional/required input handling, type inference, skipToken support, and query key overrides. The tests ensure type safety and proper integration with the broader query system.


353-429: Thorough validation of live query options.

The .liveOptions tests comprehensively cover the live query functionality, correctly validating that data types are UtilsOutput[number] (individual items) rather than UtilsOutput (arrays). The inclusion of error cases for non-async-iterable outputs provides important type safety guarantees.

packages/tanstack-query/src/procedure-utils.vue.test-d.ts (1)

161-226: Proper Vue integration for live query tests.

The test suite correctly adapts live query functionality for Vue's reactive system using computed() and .value accessors. The TODO comments appropriately acknowledge Vue Query's type handling limitations while ensuring the core live query functionality is properly tested.

packages/tanstack-query/src/procedure-utils.react.test-d.ts (1)

256-368: Excellent type inference for live queries!

The .liveOptions test suite correctly verifies that live queries return UtilsOutput[number] (individual items from the async iterable) rather than UtilsOutput (the full array). This properly reflects the live query behavior where each chunk replaces the entire result. The test coverage is comprehensive across all React Query hooks.

packages/tanstack-query/src/procedure-utils.test.ts (4)

3-3: Good integration of live query dependency.

The import and spy setup for experimental_liveQuery properly integrates the live query functionality for testing.


16-16: Proper test spy setup.

The spy on experimental_liveQuery enables verification of the integration between the utility functions and the core live query implementation.


169-176: Correct key generation for live queries.

The .liveKey test verifies that query keys are generated with the correct 'live' operation type, following the established pattern from other query utilities.


178-249: Comprehensive live query options testing.

The test suite excellently covers all aspects of live query behavior:

  • Normal operation: Verifies that the last yielded value ('__2__') is returned and cached, demonstrating the data replacement behavior that distinguishes live queries from streamed queries
  • SkipToken handling: Properly tests disabled state and error throwing
  • Error handling: Validates appropriate error message for unsupported output types
  • Integration: Confirms proper integration with experimental_liveQuery function

The test structure mirrors existing patterns while correctly testing the unique live query semantics.

packages/tanstack-query/src/procedure-utils.ts (4)

5-5: Good type import for live query support.

The import of experimental_LiveQueryOutput properly enables type inference for live queries that extract individual items from async iterables.


22-22: Proper import of live query implementation.

The import of experimental_liveQuery integrates the core live query functionality from the dedicated module.


81-103: Excellent API design and documentation.

The experimental_liveKey and experimental_liveOptions methods follow the established patterns from existing query utilities while providing clear documentation that distinguishes live queries from streamed queries. The key insight that "live queries replace the entire result with each new chunk received" is well-explained.


234-270: Solid implementation following established patterns.

The live query utilities implementation is excellent:

  • Consistent API: Mirrors the structure of existing experimental_streamedOptions
  • Proper integration: Uses experimental_liveQuery wrapper correctly
  • Error handling: Validates async iterator with appropriate error message
  • Type safety: Works with experimental_LiveQueryOutput for correct type inference
  • Operation context: Properly sets operation type to 'live' for consistent tracking

The implementation maintains consistency with existing utilities while properly integrating the live query functionality.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds experimental "live" query support to the Tanstack Query integration, enabling full-result replacement on each emitted chunk.

  • Introduces experimental_liveOptions and experimental_liveKey utilities alongside type updates and key generation.
  • Implements experimental_liveQuery runtime to drive live updates via an AsyncIterable.
  • Updates test suites across frameworks and documentation to cover live-query features.

Reviewed Changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/live-query.test.tsx Adds React hook test for streamed vs. live query behavior
src/types.ts Introduces experimental_LiveQueryOutput and adds 'live' to OperationType
src/procedure-utils.ts Implements experimental_liveKey & .experimental_liveOptions methods
src/procedure-utils.*.test-d.ts (all flavors) Expands type-level tests for live options/key in Vue, Svelte, Solid, React, Angular
src/live-query.ts & src/live-query.test.ts Implements and tests the runtime for live queries
apps/content/docs/integrations/tanstack-query.md Adds documentation for live query options
Comments suppressed due to low confidence (4)

apps/content/docs/integrations/tanstack-query.md:61

  • Several stray comment lines (//) were added here without context. These should be removed to clean up the markdown and avoid confusion.
//

packages/tanstack-query/src/procedure-utils.ts:88

  • The QueryKeyOptions generic expects both a type and input parameter. For clarity and type safety, specify the operation type explicitly (e.g. QueryKeyOptions<'live', TInput>).
      QueryKeyOptions<TInput>

packages/tanstack-query/tests/live-query.test.tsx:2

  • renderHook is not exported from '@testing-library/react'; it should be imported from '@testing-library/react-hooks' (or the appropriate testing library package) to ensure the hook renders correctly.
import { renderHook } from '@testing-library/react'

packages/tanstack-query/src/live-query.test.ts:1

  • Relative import path appears incorrect; the shared test helper is under tests/shared, so from src this should likely be ../../tests/shared.
import { queryClient } from '../tests/shared'

Comment thread packages/tanstack-query/src/live-query.test.ts
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

♻️ Duplicate comments (1)
packages/tanstack-query/src/live-query.test.ts (1)

8-8: Remove the async modifier from the describe callback.

The describe callback should be synchronous to avoid unexpected test runner behavior.

🧹 Nitpick comments (3)
packages/tanstack-query/src/live-query.test.ts (3)

20-24: Improve type safety by avoiding as any assertion.

The as any type assertion bypasses type checking and could mask potential type issues. Consider defining a proper type interface or using more specific typing.

-    const resultPromise = expect(queryFn({
-      queryKey: ['live-query'],
-      signal: controller.signal,
-      client: queryClient,
-    } as any)).resolves.toEqual(3)
+    const resultPromise = expect(queryFn({
+      queryKey: ['live-query'],
+      signal: controller.signal,
+      client: queryClient,
+    })).resolves.toEqual(3)

55-59: Improve type safety by avoiding as any assertion.

Similar to the previous test, consider removing the as any assertion for better type safety.

-    const resultPromise = expect(queryFn({
-      queryKey: ['live-query'],
-      signal: controller.signal,
-      client: queryClient,
-    } as any)).resolves.toEqual(1)
+    const resultPromise = expect(queryFn({
+      queryKey: ['live-query'],
+      signal: controller.signal,
+      client: queryClient,
+    })).resolves.toEqual(1)

76-82: Improve type safety by avoiding as any assertion.

Consider removing the as any assertion here as well for consistency and better type safety.

-    await expect(queryFn({
-      queryKey: ['live-query'],
-      signal: new AbortController().signal,
-      client: queryClient,
-    } as any)).rejects.toThrowError(
+    await expect(queryFn({
+      queryKey: ['live-query'],
+      signal: new AbortController().signal,
+      client: queryClient,
+    })).rejects.toThrowError(
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69c8401 and 25048b4.

📒 Files selected for processing (3)
  • packages/tanstack-query/src/live-query.test.ts (1 hunks)
  • packages/tanstack-query/src/live-query.ts (1 hunks)
  • packages/tanstack-query/src/procedure-utils.test-d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/tanstack-query/src/live-query.ts
  • packages/tanstack-query/src/procedure-utils.test-d.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint
  • GitHub Check: publish-commit
🔇 Additional comments (3)
packages/tanstack-query/src/live-query.test.ts (3)

26-32: Well-structured async testing pattern.

Good use of vi.waitFor to handle async assertions and verify that the query client cache updates correctly with each yielded value.


37-69: Excellent test coverage for abort signal behavior.

This test comprehensively validates the cleanup logic when an abort signal is triggered, ensuring the finally block executes and the query resolves with the last yielded value.


71-84: Comprehensive error handling test with descriptive error message.

The test properly validates the error case when no data is yielded, and the error message is informative and includes the query key for debugging.

@dinwwwh dinwwwh merged commit 251560d into main Jul 3, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants