feat(query-core): pass a context object to the placeholderData function - #11141
feat(query-core): pass a context object to the placeholderData function#11141RodolfoSilva wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (17)
🚧 Files skipped from review as they are similar to previous changes (17)
📝 WalkthroughWalkthrough
ChangesPlaceholder data context
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant QueryObserver
participant placeholderData
participant QueryClient
QueryObserver->>placeholderData: invoke with previous data, previous query, and context
placeholderData->>QueryClient: read cached query data
QueryClient-->>placeholderData: return cached data
placeholderData-->>QueryObserver: return placeholder data
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
placeholderData functions now receive a third argument holding the client, the queryKey and the meta of the Query, matching the QueryFunctionContext that queryFn already gets. Implements the proposal from TanStack#11140.
7e3ede1 to
eac654d
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
placeholderDatafunctions now receive a third argument holding theclient, thequeryKeyand themetaof the Query, matching theQueryFunctionContextthatqueryFnalready gets.This lets a
queryOptionsfactory seed from the cache without being handed aQueryClient, which previously had to be threaded through components, prefetch calls, route loaders and tests.metaandqueryKeycome from the observer's own options rather than from the Query, so two observers on the same key with differentmetaeach see their own.Existing two argument
placeholderDatafunctions keep working.Implements the proposal from #11140.
Summary by CodeRabbit
New Features
placeholderDatacallbacks now receive context containing the query client, query key, and metadata.Documentation
useQueryanduseQueriesreferences with the new callback context.Tests