Honey
Honey4w ago

Feature request: For Better file management

It would be nice if Convex could ignore folders in brackets—just like Next.js does. Example: If I have a file like: queries/(internal)/analytics/getSales.ts I want to still use it like: api.queries.analytics.getSales() This would help keep my Convex folder more organized without messing up the function paths. let me know your thoughts
18 Replies
Convex Bot
Convex Bot4w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
Clever Tagline
Interesting idea. Not sure how tough it would be to implement that. While it might be great from the dev's perspective, it could complicate things from the code gen angle. Side note: I recommend changing the post title to something relevant to your question
Honey
HoneyOP4w ago
I think they would need to update the compiler so it skips folders with brackets when generating function paths.
ballingt
ballingt4w ago
@Honey could you say more about this, does (internal) automatically make all queries, mutations and actions under that directory internalMutations etc., or is internal just an example?
Honey
HoneyOP4w ago
Here is my current Convex folder structure (in the image). I want to organize my Convex functions into folders like this: (connections)/ ├── shopify/ ├── meta/ └── google/ But when I use useQuery, I want to be able to call it like: api.shopify.getStore api.meta.getUserAdAccount Basically, I want the (connections) folder to act as a grouping folder that gets ignored during compilation — similar to how folders in parentheses work in Next.js (for organizing without affecting the API path). Make it possible in convex
No description
Honey
HoneyOP4w ago
--------------------------- I don't have any issue using a lot of nested folders, but it starts throwing TypeScript errors.
Honey
HoneyOP4w ago
"Type instantiation is excessively deep and possibly infinite. " i was gettting this erorr so i had claude to rewrite whole damm codebase and it was brutal
No description
Honey
HoneyOP4w ago
bassically what nextjs does to routes , if its possible want same for convex,
No description
adam
adam4w ago
@ballingt I also like this idea of grouping folders that are ignored by the Convex codegen step. This would help with managing LLM context in a large code base. For example, I might have a feature such as (loyalty). I would plan to have a (loyalty) folder within Convex folder, but also a matching (loyalty) folder on my frontend grouping all the loyalty pages and components. I've also self authored Convex components in an attempt to isolate/group features that are mostly stand alone - though I found it was a bit too much overhead for the benifit of a feature only used within this project. I would prefer to group the related Convex files within a folder. Side note: I am using Convex static code gen, so I loose the benifit of cmd+click to jump to source files. This has changed how I organise my Convex files. I no longer want to have deeply nested API routes like api.loyalty.orders.list because I have a few orders.ts files now in the code base (and difficult to find quickly). I prefer to use something like api.loyaltyOrders.list which allows me to quickly search for loyaltyOrders.ts (as it's unique). Ideally, this would be the folder structure /convex/(loyalty)/loyaltyOrders.ts - Allowing for grouping for LLM context, and ease of navigating the codebase (when using static code gen). Oh, and one final note: this allows the IDE to autocomplete when I type api. (I can quickly select loyaltyOrders) and don't need to think about which subfolder it's located in.
Parker
Parker4w ago
i thought i was the only one haha. that error was my nightmare.
Honey
HoneyOP4w ago
@ballingt can you ask the team or give confirmation if we can get something like this or not
ballingt
ballingt4w ago
no I can't confirm anything, we're just chatting here One way to tackle this is being more flexible for static API generation, once you're using that you should be able to use any style you want The dynamic codegen approach is more limiting, but once this is generated it can be structured however. The current design constraint is that whatever you type after api, like api.foo.bar.baz, is going to be used as the identifier, "foo.bar.js:baz" today. That maps to a module called foo/bar.js in the backend hm lots of possibilities here No immediate plans here, the ignoring directories in smooth brackets idea is possible
adam
adam4w ago
I have re read the docs here https://docs.convex.dev/production/project-configuration#using-static-code-generation-beta but I don’t quite understand how it is more flexible and can be customised?
ballingt
ballingt4w ago
Ah sorry, it's not; I just mean we can do that
Gorka Cesium
Gorka Cesium3w ago
how did you fix it?
Honey
HoneyOP3w ago
just make sure you are not using alot of nested folders
Gorka Cesium
Gorka Cesium3w ago
i'll take a look, good tip, thanks!
Honey
HoneyOP3w ago
you can check this if you want to maintain large codebase
No description

Did you find this page helpful?