-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(enhance): Prisma Pulse support #1658
Conversation
WalkthroughWalkthroughThe code changes involve significant modifications to several classes and methods related to data handling and processing logic in a Prisma-based application. Key updates include the introduction of a new streaming capability, enhancements to the existing subscription methods, and refinements to authorization logic. Additionally, new tests have been implemented to validate policy enforcement and data integrity across various scenarios. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PrismaProxyHandler
participant OmitHandler
participant PolicyProxyHandler
participant DbOperations
User->>PrismaProxyHandler: Call stream(args)
PrismaProxyHandler->>PolicyProxyHandler: handleSubscribeStream('stream', args)
PolicyProxyHandler->>OmitHandler: processResultEntity(method, data)
OmitHandler-->>PolicyProxyHandler: Return processed data
PolicyProxyHandler-->>PrismaProxyHandler: Return subscription data
PrismaProxyHandler-->>User: Return results
Assessment against linked issues
Possibly related issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- packages/runtime/src/enhancements/omit.ts (1 hunks)
- packages/runtime/src/enhancements/policy/handler.ts (1 hunks)
- packages/runtime/src/enhancements/policy/policy-utils.ts (1 hunks)
- packages/runtime/src/enhancements/proxy.ts (4 hunks)
- packages/runtime/src/types.ts (1 hunks)
- packages/testtools/src/schema.ts (3 hunks)
- tests/integration/tests/enhancements/with-policy/prisma-pulse.test.ts (1 hunks)
Additional comments not posted (15)
packages/runtime/src/types.ts (1)
26-26
: Addition ofstream
method is appropriate.The introduction of the
stream
method in theDbOperations
interface is consistent with the existing method signatures and aligns with the PR objectives.packages/runtime/src/enhancements/omit.ts (1)
29-60
: Enhanced handling ofsubscribe
andstream
methods is effective.The changes to the
processResultEntity
method improve its ability to handle different data processing scenarios based on themethod
parameter. This enhances the functionality and control flow.packages/runtime/src/enhancements/proxy.ts (2)
58-58
: Addition ofstream
method toPrismaProxyHandler
is appropriate.The introduction of the
stream
method enhances the interface's functionality and aligns with the PR objectives.
169-190
: Implementation ofdoSubscribeStream
method is well-structured.The
doSubscribeStream
method effectively handles both subscription and streaming, ensuring proper processing of iteration results.packages/testtools/src/schema.ts (2)
240-240
: Caution: Potential data loss with--accept-data-loss
.The addition of
--accept-data-loss
in theprisma db push
command allows for data loss during the operation. Ensure that this is intentional and properly documented to avoid unintended consequences.
392-395
: LGTM: Dynamic module loading withloadModule
.The
loadModule
function enhances modularity by dynamically resolving module paths. This approach improves error handling and path resolution.tests/integration/tests/enhancements/with-policy/prisma-pulse.test.ts (6)
20-77
: LGTM: Comprehensive authorization check test.The test case effectively verifies authorization checks for the
stream
API, covering both anonymous and authenticated user scenarios.
79-132
: LGTM: Thorough model-level policy test.The test case effectively validates model-level policies using the
stream
API, ensuring policy enforcement based on model attributes.
134-187
: LGTM: Effective partial subscription test.The test case successfully validates the partial subscription functionality of the
stream
API.
189-257
: LGTM: Comprehensive policy and filter combination test.The test case thoroughly evaluates the interaction between policies and user-provided filters using the
stream
API.
259-309
: LGTM: Field-level policy enforcement test.The test case effectively validates field-level policy enforcement using the
stream
API.
311-364
: LGTM:@omit
directive test.The test case successfully verifies the functionality of the
@omit
directive using thestream
API.packages/runtime/src/enhancements/policy/policy-utils.ts (1)
598-598
: LGTM! Explicitly settingargs.where
to false enhances clarity.The change ensures that no records are returned when authorization fails, improving the robustness of the authorization logic.
packages/runtime/src/enhancements/policy/handler.ts (2)
1542-1543
: Refactoredsubscribe
method looks good.The refactoring to use
handleSubscribeStream
improves maintainability by centralizing logic.
1546-1547
: Refactoredstream
method looks good.The refactoring to use
handleSubscribeStream
improves maintainability by centralizing logic.
Fixes #1473