Polly
05/10/2022, 11:12 PMOmar
05/10/2022, 11:13 PMmkspcd
05/11/2022, 4:58 AMMoin Akhter
05/11/2022, 10:51 PMYukito
05/12/2022, 1:39 AMOmar
05/14/2022, 12:32 AMOmar
05/14/2022, 11:39 PMjson-server
.
I'm sure you're going to find this really useful.
Check it out here: https://github.com/omar-dulaimi/prisma-json-server-generatorIshan Manandhar
05/16/2022, 9:14 AMOmar
05/21/2022, 1:18 AMconst permissions = shield({
query: {
fruits: and(isAuthenticated, or(isAdmin, isEditor)),
customers: and(isAuthenticated, isAdmin),
},
mutation: {
addFruitToBasket: isAuthenticated,
},
})
You can define rules as you like, then mix and match then to get exactly what you need with logical operators.
To make things even smoother for tRPC users who also use Prisma, I built a new generator that takes care of emitting the right shield for your Prisma schema:
import { shield, allow } from 'trpc-shield';
export const permissions = shield({
query: {
aggregatePost: allow,
aggregateUser: allow,
findFirstPost: allow,
findFirstUser: allow,
findManyPost: allow,
findManyUser: allow,
findUniquePost: allow,
findUniqueUser: allow,
groupByPost: allow,
groupByUser: allow,
},
mutation: {
createOnePost: allow,
createOneUser: allow,
deleteManyPost: allow,
deleteManyUser: allow,
deleteOnePost: allow,
deleteOneUser: allow,
updateManyPost: allow,
updateManyUser: allow,
updateOnePost: allow,
updateOneUser: allow,
upsertOnePost: allow,
upsertOneUser: allow,
},
});
You can fined them here:
tRPC Shield: https://github.com/omar-dulaimi/trpc-shield
Prisma tRPC Shield Generator: https://github.com/omar-dulaimi/prisma-trpc-shield-generator
😁prisma rainbowJeremy Cohen Hoffing
05/24/2022, 7:09 PMOmar
05/25/2022, 4:51 AMwithShield
option to the generator block in your Prisma schema:
generator trpc {
provider = "prisma-trpc-generator"
withShield = true
}
This is now ready to use starting with v0.1.9
You also don't have to add any //@ts-ignore
anymore 🙂Kushagra Kesav
05/26/2022, 3:22 AMOmar
05/27/2022, 6:40 AMTaras Protchenko
06/03/2022, 10:22 AMSacha Greif
06/17/2022, 12:05 AMVivek Poddar
06/23/2022, 3:01 PMcreatedAt
and updatedAt
which is not present on a new object, I don’t want to make these fields optional at the schema level. Currently Typescript is screaming at me when storing a new object, how to make it happy? 🙂Yashua Pervez
06/29/2022, 6:06 AMGaurav Sharan
06/29/2022, 9:24 AMTaras Protchenko
06/29/2022, 2:45 PMTaras Protchenko
06/29/2022, 2:49 PMMichael Jay
06/30/2022, 7:44 PMGaurav Sharan
07/02/2022, 4:04 PMGG Nam
07/08/2022, 4:47 AMMateusz Stepaniuk
07/08/2022, 1:58 PMMateusz Stepaniuk
07/08/2022, 1:58 PMAndrew Wang
07/11/2022, 3:50 AMOmar
07/13/2022, 7:22 PMMAQ
07/14/2022, 10:00 AMJannik Köster
07/14/2022, 10:22 AMMarcos Iglesias
07/14/2022, 10:31 AM