Open
Conversation
added 2 commits
March 14, 2026 12:41
🦋 Changeset detectedLatest commit: 002ea39 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Author
|
Hey TanStack team, my first contribution here. I didn't include the generated docs as they generate a lot of changes. What's the general rule: include generated docs in the PR or create a follow-up PR for docs only? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
Summary
.meta()method to pass dynamic runtime context (tenant IDs, scopes, feature flags) to query functionsDiscussion and issues related with passing meta in queries:
Problem
Applications need to pass runtime context to their query functions — such as tenant IDs for multi-tenancy, authorisation scopes, or feature flags — without embedding these values in query predicates. Previously, there was no way to attach this metadata to queries, forcing developers to either hardcode context or use workarounds.
Additionally, when different runtime contexts share the same predicates, caching and deduplication logic must account for meta differences, otherwise, queries from different tenants or users with identical predicates would incorrectly share cache entries, causing data isolation bugs.
Approach
The
.meta()method accepts arbitrary context data and integrates seamlessly with the query builder, following the same chainable pattern as existing methods like.limit(). Query-level metadata is merged with collection-level metadata (with query-level taking precedence).Meta is included in the cache key serialisation, ensuring that queries with identical predicates but different runtime contexts receive separate cache entries. The
isPredicateSubset()deduplication logic also checks meta equality, preventing data corruption in multi-tenant scenarios where two requests with the same predicates but different tenant scopes would otherwise reuse cached data from the wrong tenant.The implementation includes tests that validate meta preservation throughout the query lifecycle, correct merging semantics, proper cache key differentiation, and deduplication behaviour.
Documentation covers usage in live queries and extends the existing
metadocumentation for collections.✅ Checklist
pnpm test.🚀 Release Impact