zenstack
zenstack copied to clipboard
[Feature Request] Access policy allow field to be created only with default value
For example, the Payment could be created by customer, but the isPaid field should not be changed by customer, it could only be updated by the backend service after receive the webhook callback.
model Payment {
...
isPaid @default(false) @deny('create', true)
@@allow('create, read', auth() == owner)
}
However, the current field level access policy doesn't allow control for 'create' policy.
Is there a workaround for this limitation at the moment?
I think there are two workarounds you can use:
-
Use field access policy to deny update.
isPaid @default(false) @deny('update', true)But you need to make sure that isPaid is never provided when calling
createfunction. -
Use
ignoreisPaid @default(false) @ignoreThe trade-off is that you have to use raw SQL to update it since it is excluded from prisma client.