Skip to content
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

[Feature Request] Zero integration #1933

Open
andrictham opened this issue Jan 1, 2025 · 0 comments
Open

[Feature Request] Zero integration #1933

andrictham opened this issue Jan 1, 2025 · 0 comments

Comments

@andrictham
Copy link

andrictham commented Jan 1, 2025

Is your feature request related to a problem? Please describe.

On the client-side, I want to use Zero instead of swr, tRPC or ZenStack-generated TanStack Query hooks, so that database queries can be updated in realtime for the user, providing a better user experience.

Zero is a sync engine that syncs data from a Postgres database to a client-side database, eliminating the need for manual data fetching, caching, and revalidation.

You put Zero in front of your database or web service, and we distribute your backend all the way to main thread of the UI.

It allows for client-side applications to subscribe to queries on the database that are automatically updated whenever the underlying data updates.

This makes it possible to build apps like Linear with UI that responds to the user instantly, with changes that sync in the background.

It also makes it possible to build collaborative apps like Notion where if another user changes some data, other users with the right permissions should see those changes too.

Zero has their own schema format that also specifies permissions for the client-side database, a query/mutation API for interacting with the client-side database, and data migration workflow.

The problem is that using Zero requires maintaining two schemas, one for Zero's client-side database, and another one for the backend database. Keeping the two in sync (especially with permissions logic) is troublesome.

ZenStack is well-positioned to auto-generate a Zero schema from ZModel so developers don’t have to make two schemas.

Describe the solution you'd like

Support Zero as a first-party ZenStack plugin, similar to @zenstackhq/swr, @zenstackhq/trpc, and @zenstackhq/tanstack-query

The plugin should generate a Zero schema from a ZModel schema, mapping the following: tables, columns, relationships, and permissions.

This plugin should be accompanied with ZModel language features that support specifying only certain tables or columns that the client-side uses, since the client-side shouldn’t be accessing the full database.

Describe alternatives you've considered

Moving away from ZenStack and use Zero with Prisma (not preferable as I like defining my schema and permissions with ZModel)

Additional context

There is already a community-made Prisma generator (https://github.com/Passionfroot/prisma-generator-zero) that generates a Zero schema from a Prisma schema, but it doesn’t support permissions.

ZModel is more suited to generate permissions code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant