perf(convex): deduplicate auth fetches in RLS helpers#414
Conversation
Fetch user and organization data once in mutation/query wrappers and pass to rlsRules via optional prefetchedData parameter, eliminating redundant auth lookups on every RLS-wrapped call.
📝 WalkthroughWalkthroughThe changes refactor RLS (Row-Level Security) rule computation by modifying the call pattern in two helper files to pre-fetch authentication data once before invoking rlsRules. Instead of rlsRules fetching user and organization data internally, both mutation_with_rls.ts and query_with_rls.ts now retrieve this data upfront and pass it as an optional parameter to rlsRules. The rlsRules function signature is updated to accept optional pre-fetched data, with fallback logic to fetch data itself if not provided. This eliminates potential duplicate data fetches within rlsRules. Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
Summary
useranduserOrganizationsonce inmutationWithRLS/queryWithRLSwrappersrlsRules()via optionalprefetchedDataparametergetAuthenticatedUser()andgetUserOrganizations()calls on every RLS-wrapped query/mutationTest plan
Summary by CodeRabbit