Halindra
Halindra3mo ago

hi I just saw this. do you ever have

hi I just saw this. do you ever have problems with circular dependencies? or are you preventing imports from other table directories?
8 Replies
erquhart
erquhart3mo ago
Haven't had any circular dependency issues, what are you seeing?
Halindra
HalindraOP3mo ago
I’m using a 3-layer setup right now (repo-service-workflow), so no circular dependency issues. But I’m open to simplifying my codebase I’m curious with your approach. Do the read(or write) files import from each other?
erquhart
erquhart3mo ago
No they both technically read
Halindra
HalindraOP3mo ago
For example, say inside user/read.ts I want to implement getUserWithLatestPost, which would require pulling data from post/read.ts. In cases like that, do you allow cross-imports between folders, or do you handle it differently to avoid circular dependencies? by circular I mean in post/read.ts, I might want getPostWithAuthor, which would require pulling from user/read.ts
erquhart
erquhart3mo ago
Ah I see - yes, I import from the other files in those cases. post.ts or post/*.ts would be the only files that touch the post table directly. I have found that splitting into read/write/etc is only worthwhile when you have a lot going on, fwiw. Most of my tables are single file, with all reads, writes, etc in one file.
Halindra
HalindraOP3mo ago
got it. what about your queries and mutations (convex functions); do you keep em thin or is the orchestration/business logic going in there?
erquhart
erquhart3mo ago
That’s where all the business logic is, yeah, they can get pretty big
Halindra
HalindraOP3mo ago
Alrighty thanks for the responses I got me some ideas to try 💪

Did you find this page helpful?