fix: issue with multiple on query plugins with args override#169
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
Claude finished @ymc9's task —— View job PR Review: Fix for Multiple OnQuery Plugins with Args OverrideReview Checklist:
SummaryThis PR fixes a critical issue with the plugin system where arguments overridden by one Code Quality & Best Practices ✅Strengths:
Minor Suggestions:
Bug Fixes & Correctness ✅Problem Solved: // Before (buggy)
proceed = () => onQuery({ client, model, operation, args, proceed: _proceed })
// After (fixed)
proceed = (_args: unknown) => onQuery({
client, model, operation,
args: _args, // Now properly reflects overrides
proceed: (nextArgs: unknown) => _proceed(nextArgs)
})Key Improvements:
Performance Considerations ✅
Security Concerns ✅
Test Coverage ✅Excellent Test Addition: it('propagates overridden args across multiple onQuery plugins', async () => {
// Plugin A should see overrides from Plugin B
const clientA = _client.$use({
id: 'plugin-a',
onQuery: (ctx) => {
// Validates it sees the overridden args
earlierSawOverridden = (ctx.args as any)?.where?.id === 'non-exist';
return ctx.proceed(ctx.args);
},
});
// Plugin B overrides args
const client = clientA.$use({
id: 'plugin-b',
onQuery: (ctx) => {
return ctx.proceed({ where: { id: 'non-exist' } });
},
});
// ... validation logic
});This test perfectly captures the bug scenario and validates the fix. Overall Assessment ⭐⭐⭐⭐⭐Excellent PR:
Recommendation: APPROVE - This is a well-crafted fix that resolves a critical plugin system bug while maintaining code quality standards. |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where multiple onQuery plugins with argument overrides weren't properly propagating changes between plugins in the correct order.
- Modified the plugin chain execution to ensure argument overrides from later plugins are visible to earlier plugins
- Added comprehensive test coverage to verify the fix works correctly for multiple chained onQuery plugins
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/runtime/src/client/client-impl.ts | Updates plugin execution logic to properly propagate argument overrides between chained onQuery plugins |
| packages/runtime/test/plugin/on-query-hooks.test.ts | Adds test case to verify multiple onQuery plugins correctly share overridden arguments |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
No description provided.