-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Doesn't work with the Prisma fluent API #80
Comments
Thanks for the reproduction repo, I'll have a look. In the mean time, what do the debug logs say when you hit the fluent endpoint?
|
Thank you for your reply. debug logs 2023-08-30T17:24:19.777Z prisma-field-encryption:encryption Clear-text input: { |
Thanks, I think I have an idea of what is going on. The query coming into the extension asks for a user, with included posts: {
args: { select: { posts: true } },
model: 'User',
action: 'findFirst',
dataPath: [],
runInTransaction: false
} However, the data coming back from the database (or rather from the client engine doing its thing) is a list of Posts: [
{
id: 5,
title: 'Post1',
content: 'v1.aesgcm256.2fc1baee.BYsfYrU7k6ppBv0t.n_MIe9lb-jpIveEs3jfRVH2LJGxU4pvvvqECrFg=',
published: false,
authorId: 5
},
{
id: 6,
title: 'Post2',
content: 'v1.aesgcm256.2fc1baee.srH0TPxsXRm2DDz2.2U9FRykgqty9jiIlGQTLFlnA_EWRysmhUW41oSs=',
published: false,
authorId: 5
}
] This throws the decryption engine off which was expecting a User model, with some connections to a list of Posts, not the posts themselves. Since Prisma does this downstream and doesn't give us any info of this change (neither from the input arguments nor from the returned data), I don't see how we can handle this and differenciate it from a regular (non-Fluent) call. |
FYI, I have opened a discussion about this behaviour on the Prisma repo: prisma/prisma#20901 |
Test checks that it isn't actually supported. See #80.
Thank you very much. I don't have any idea about solving this problem because there is no information on the Internet. |
Describe the Bug
I have trouble in using prisma-field-encryption middleware when using prisma fluent API. Not decrypted data are returned when I request data through prisma fluent API. To avoid N+1 problem, I want to use fluent API which can use prisma data loader.
To Reproduce
Add prisma-field-encryption middleware. Make schema which has parent-children relation model and @Encrypted field in children model. (see my code below)
Expected Behavior
I expect data which are requested through prisma fluent API to be decrypted.
Environment:
OS: ubuntu 22.04.1
Node 20.2.0
Prisma version 5.2.0
prisma-field-encryption 1.5.0
TypeScript version 5.2.2
Express 4.18.2
Additional Context
This is my github repository
Prisma schema
Express Server
The text was updated successfully, but these errors were encountered: