Paul
Paul•4mo ago

How to have multiple schemas

I've seen this, but I don't think it's what I want: https://docs.convex.dev/production/multiple-repos I saw somewhere and now I can't find it. The ability to have multiple ConvexProviders in react because they were going to different code generated endpoints. I want this ability myself. As I have a very large and complex project and I don't want 1 repo for the many tables that I have. I want the tables restricted to where the code actually lives. If that makes sense. I have dam and auth with convex directories but only auth is live (see image). How to fix that? Thanks
No description
7 Replies
Paul
PaulOP•4mo ago
I just remembered that I needed to have a watcher running. Now I get it. 2 days in Rust kills your typescript knowledge. 😩 So I don't think this is what I want. As the watcher is complaining and tables are present in the dashboard but saying they aren't in the schema. How do I effectively organise my monorepo. So in future I don't want to die? I have 10+ apps and all of them will convex tables, queries and functions. Do I need a centralised location which imports them?
And then watch that centralised location? šŸ¤”
Gi
Gi•4mo ago
Yup. All Convex functions in one package, and export the api/types to use in the other packages
Paul
PaulOP•4mo ago
I achieved what I was ultimately wanting. https://i.imgur.com/3aRDYJn.png I create a stub for the schema to import. But links to the "invoker".
export { schema as authTokens, getTokenById, insertToken } from "../../../packages/auth/convex/authTokens";
export { schema as authTokens, getTokenById, insertToken } from "../../../packages/auth/convex/authTokens";
In the convex/schema.ts, import that stub
import { authTokens } from "./heimdall/auth/authTokens";

export default defineSchema({
authTokens,
});
import { authTokens } from "./heimdall/auth/authTokens";

export default defineSchema({
authTokens,
});
So all schema, queries/mutations all are centralised to the adjacent "invoker".
Imgur
Paul
PaulOP•4mo ago
Current schema, which will grow. But this includes 3 different locations.
No description
Paul
PaulOP•4mo ago
The functions.
No description
Paul
PaulOP•4mo ago
Also validated as working. As the rust application which runs the auth for the app.
let result = client.mutation("heimdall/auth/users:insertUserbyEmail", maplit::btreemap!{
...
}).await;
let result = client.mutation("heimdall/auth/users:insertUserbyEmail", maplit::btreemap!{
...
}).await;
and the user is created (in the above image) I really hope this works in prod. šŸ™ šŸ˜… Now to determine whether I can create queries/mutations in my ts backend and then have the watcher import them as functions. šŸ¤” Can confirm it works from my encore backend. Didn't need to follow the link above. Team. Are there any pitfalls to doing this approach? Thanks
atalay
atalay•3mo ago
Hey Paul I'm trying to do exactly what you do, did you find any solutions for this? I don't want merge my repos, and that document didn't help me too, I already changed api import from other repos but still facing issue

Did you find this page helpful?