-
BackgroundIn Blitz.js, a folder named Problem: Deeply nested file paths because url base path is always
|
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 12 replies
-
@flybayer first, let me commend you for the robust and mature method of suggesting changes with this RFC process. Bravo! This appears to be an improvement on the current system; and one that I think makes a lot of sense if you're married to this approach. That said; if you're considering other approaches… Blitz' magic "pages" directory is interesting for smaller apps; as you can get up and running quickly…but IMHO this will become messy and difficult to maintain for larger applications when mixed with API Routes. The way Rails actually handles this is with the In a Rails route file, typing something like Not everything has to follow this model, but in the Blitz approach it's less clear to me what HTTP methods are available from the paged routes. Perhaps that's not a concern of Blitz, or is solved some other way I'm unaware of by reading through the docs? |
Beta Was this translation helpful? Give feedback.
-
I'm not convinced that this change should occur. Deeply nested routes are inherently going to be more complex, but it isn't just the routes themselves, the ways the user views and interacts with these concepts is also connected. I'm afraid that adding a new syntax could muddy a developer's ability to perceive the existence of those relationships when viewing the source code. If the user is expected to navigate through "projects" in order to reach "tasks," and cannot jump to "tasks" directly from "home," then the organizational structure should reveal that relationship. The "magic folders" are fine for hierarchies that are wide, shallow, and loosely connected, but you shouldn't try to shoehorn nested relationships into them because it obfuscates the connection. This may just be my opinion, but I'm turned off by the ^path and ^^path proposals, and even if they existed I think I'd prefer to organize the deeply nested routes in the most plain way possible, a single root "pages" folder.
|
Beta Was this translation helpful? Give feedback.
-
Thanks so much for putting this up for the proposal. I'm really impressed with the way you interact with the community, whatever it ultimately decides to approve! I think, a little like @MrLeebo above, I don't have a problem with pages living directly inside the pages folder eg : I appreciate however that some people would prefer to keep their module-specific pages alongside the queries/resolvers. For me, simple is king but I appreciate that other developers will have different reasonings. |
Beta Was this translation helpful? Give feedback.
-
Like the others who've commented, I think introducing a little language within the pathnames is a step in the wrong (complexity-increasing) direction. My dream framework would make the routes even more obvious than next or blitz does: I guess I'd have a flat directory where even nested routes are not nested files.
(Or perhaps a unicode slash-like character instead of '%'. Maybe '╱'.) The way next does it reminds me of the way .java files' package names are tied to their directory location, and the proposal makes this more extreme. |
Beta Was this translation helpful? Give feedback.
-
A lot of great thought and comments from everybody already 👏🏻. Some additional thoughts:
As another approach, I'd like to suggest adding the url into the page with a new api. Let's call it const SomePage: BlitzPage = () => {
return (...)
}
SomePage.route = "/some/route/:id"
SomePage.getLayout = (page) => <Layout title="SomePage">{page}</Layout> This has the added benefit of keeping the url as close to the page as possible, while allowing you to organize in any way possible. While the |
Beta Was this translation helpful? Give feedback.
-
To my mind, it'd be a move in the wrong direction. "mature" != "similar to other frameworks". Similarly to @MrLeebo, I'd like to advocate for keeping it as is, specifically because it to decouple your domain dissection and path logic. Imagine I build something like a Instagram, where there are a lot of distinct features that all center around users: When I originally saw our current routing logic, I didn't get it. It's not obvious. But when one of you explained to me the Why, I started to like it, and I imagine it's the same for other people. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your input everyone! I just added an alternative follow up proposal at the end of the original post. Please review and comment :) |
Beta Was this translation helpful? Give feedback.
-
Firstly a shout out to Norfolk Developers group. It was via your online talk that I got in to Blitz @flybayer 👍 I'm not convined that this would be an improvement as it adds a considerable amount of cognitive complexity to understand the resulting URL for any given directory. This topic is something that I have been actively thinking about over the past couple of weeks born out of frustration from the current limitations of how the pages directory works in both Next and Blitz. Ideally we would be able to locate assets, components, containers, helpers, hook, mutations, queries, etc contextually (with root-level global equivalents where necessary) to prevent duplication of directory structure for different content types. Something like this, with nested
How achievable this is I honestly don't know but this would be the utopia of directory structure in Next/Blitz apps from my experience. |
Beta Was this translation helpful? Give feedback.
-
I am strongly in favor of the alternate proposal. It sets the right defaults for beginners and allows us to introduce "splitting by domain" to anyone who might need it. It also brings the default structure more in line with how Next.js works, which is good for adoption. |
Beta Was this translation helpful? Give feedback.
-
I've implemented the alternate proposal here: #1719 |
Beta Was this translation helpful? Give feedback.
I am strongly in favor of the alternate proposal. It sets the right defaults for beginners and allows us to introduce "splitting by domain" to anyone who might need it. It also brings the default structure more in line with how Next.js works, which is good for adoption.