zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.05k stars 87 forks source link

[Question] Does the @zenstackhq/trpc plugin support optimistic updates? #1614

Open kirankunigiri opened 2 months ago

kirankunigiri commented 2 months ago

The @zenstackhq/tanstack-query mentions that it has optimistic updates implemented. I didn't see this mentioned in the docs for the @zenstackhq/trpc plugin. I would like to know if it also supports it, since trpc also uses tanstack-query.

ymc9 commented 2 months ago

The problem is that trpc manages the tanstack-query hooks it uses. For ZenStack-generated tq hooks it has the flexibility to register custom code to be executed post-mutation - that's how optimistic update is implemented. I haven't thought about a good way to do it for trpc yet .. I'm definitely open to suggestions on how to do that.