CLI: pull schema for dual projects same DB.
My project has a separation of frontend and backend node apps. My
frontend
atm is controlling the schema and functions but I'd like the backend
(lets assume a separate repo) to be able to interact with the same db / schema with the same Developer experience.
when I run npx convex dev
on the backend
the _convex folder gets generated but the api.
does not auto complete.
Is there a way to do something like npx convex pull schema and functions
to update the schema locally and get the right DX on repos that are not the primary controlers of the code?
thanks.
P.3 Replies
My suggestion is not good, because having duplicate copies of the same functions in two repos will lead to them overwriting eachother when not in sync.
Ideally we would be able to fetch only the type definitions of functions and set a flag "consumer" or something that would inhibith overriding the functions that where defined elsewhere somehow.
My general suggestion is to use a monorepo, so that the references can always be up to date. I've worked at a number of companies and eventually all of them converged on the monorepo architecture. If that isn't possible for you, you could use some fancy git features like subtrees or submodules to have both repos depend on the same backend. However, your code may get out of date if you aren't pulling regularly. And the one that gets out of date shouldn't run npx convex dev or they'll overwrite each other. make sense?
In case it's helpful, here's a monorepo template: https://www.convex.dev/templates/monorepo
Templates
The backend application platform with everything you need to build your product.