Optimize file structure of Bliz.js #2631
Replies: 3 comments
-
I don't think this proposal is an improvement. To begin, there is a mistake in the proposed folder structure, -/data/projects/pages/[projectId].tsx
+/data/projects/pages/projects/[projectId].tsx You need to have the resource folder after
I don't see value in inserting a folder called |
Beta Was this translation helpful? Give feedback.
-
It is less about if the folder is called 'data' or not even if there is no folder at all still fine, the main point is to have the pages inside the same folder where also the queries and mutations are generated. |
Beta Was this translation helpful? Give feedback.
-
We actually started out with this approach, but then changed. See #1694 for the context behind the change. That said, I think we can add a config option that allows users to opt into this behavior. I converted this issue into a discussion, but if you are good with adding a config option, then please open a new issue specifically for that. :) |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm new to Blitz but one thing that I saw where I think this can be done cleaner is how the generated files are structured.
When I run in my Blitz app
blitz generate all projects
I get a file structure like this.📦app
┣ 📂api
┃ ┗ 📜.keep
┣ 📂auth
┃ ┣ 📂components
┃ ┃ ┣ 📜LoginForm.tsx
┃ ┃ ┗ 📜SignupForm.tsx
┃ ┣ 📂mutations
┃ ┃ ┣ 📜changePassword.ts
┃ ┃ ┣ 📜forgotPassword.test.ts
┃ ┃ ┣ 📜forgotPassword.ts
┃ ┃ ┣ 📜login.ts
┃ ┃ ┣ 📜logout.ts
┃ ┃ ┣ 📜resetPassword.test.ts
┃ ┃ ┣ 📜resetPassword.ts
┃ ┃ ┗ 📜signup.ts
┃ ┣ 📂pages
┃ ┃ ┣ 📜forgot-password.tsx
┃ ┃ ┣ 📜login.tsx
┃ ┃ ┣ 📜reset-password.tsx
┃ ┃ ┗ 📜signup.tsx
┃ ┗ 📜validations.ts
┣ 📂core
┃ ┣ 📂components
┃ ┃ ┣ 📜Form.tsx
┃ ┃ ┗ 📜LabeledTextField.tsx
┃ ┣ 📂hooks
┃ ┃ ┗ 📜useCurrentUser.ts
┃ ┣ 📂layouts
┃ ┃ ┗ 📜Layout.tsx
┃ ┗ 📂styles
┃ ┃ ┗ 📜index.css
┣ 📂pages
┃ ┣ 📂projects
┃ ┃ ┣ 📂[projectId]
┃ ┃ ┃ ┗ 📜edit.tsx
┃ ┃ ┣ 📜[projectId].tsx
┃ ┃ ┣ 📜index.tsx
┃ ┃ ┗ 📜new.tsx
┃ ┣ 📜404.tsx
┃ ┣ 📜_app.tsx
┃ ┣ 📜_document.tsx
┃ ┣ 📜index.test.tsx
┃ ┗ 📜index.tsx
┣ 📂projects
┃ ┣ 📂components
┃ ┃ ┗ 📜ProjectForm.tsx
┃ ┣ 📂mutations
┃ ┃ ┣ 📜createProject.ts
┃ ┃ ┣ 📜deleteProject.ts
┃ ┃ ┗ 📜updateProject.ts
┃ ┗ 📂queries
┃ ┃ ┣ 📜getProject.ts
┃ ┃ ┗ 📜getProjects.ts
┗ 📂users
┃ ┗ 📂queries
┃ ┃ ┗ 📜getCurrentUser.ts
We generate inside the app a folder
projects
and underapp/pages
also, why not have a folder called 'data' under 'app' where the 'projects' folder, for example, is generated and this folder holds not onlycomponents, mutations, queries
but also theroutes/pages
this way every data model created has a central place which holds everything from mutations & queries to the pages/routes it is up to the framework later to merge them correctly. This is I think it could look.📦app
┣ 📂api
┃ ┗ 📜.keep
┣ 📂auth
┃ ┣ 📂components
┃ ┃ ┣ 📜LoginForm.tsx
┃ ┃ ┗ 📜SignupForm.tsx
┃ ┣ 📂mutations
┃ ┃ ┣ 📜changePassword.ts
┃ ┃ ┣ 📜forgotPassword.test.ts
┃ ┃ ┣ 📜forgotPassword.ts
┃ ┃ ┣ 📜login.ts
┃ ┃ ┣ 📜logout.ts
┃ ┃ ┣ 📜resetPassword.test.ts
┃ ┃ ┣ 📜resetPassword.ts
┃ ┃ ┗ 📜signup.ts
┃ ┣ 📂pages
┃ ┃ ┣ 📜forgot-password.tsx
┃ ┃ ┣ 📜login.tsx
┃ ┃ ┣ 📜reset-password.tsx
┃ ┃ ┗ 📜signup.tsx
┃ ┗ 📜validations.ts
┣ 📂core
┃ ┣ 📂components
┃ ┃ ┣ 📜Form.tsx
┃ ┃ ┗ 📜LabeledTextField.tsx
┃ ┣ 📂hooks
┃ ┃ ┗ 📜useCurrentUser.ts
┃ ┣ 📂layouts
┃ ┃ ┗ 📜Layout.tsx
┃ ┗ 📂styles
┃ ┃ ┗ 📜index.css
┣ 📂data
┃ ┗ 📂projects
┃ ┃ ┣ 📂components
┃ ┃ ┃ ┗ 📜ProjectForm.tsx
┃ ┃ ┣ 📂mutations
┃ ┃ ┃ ┣ 📜createProject.ts
┃ ┃ ┃ ┣ 📜deleteProject.ts
┃ ┃ ┃ ┗ 📜updateProject.ts
┃ ┃ ┣ 📂pages
┃ ┃ ┃ ┣ 📂[projectId]
┃ ┃ ┃ ┃ ┗ 📜edit.tsx
┃ ┃ ┃ ┣ 📜[projectId].tsx
┃ ┃ ┃ ┣ 📜index.tsx
┃ ┃ ┃ ┗ 📜new.tsx
┃ ┃ ┗ 📂queries
┃ ┃ ┃ ┣ 📜getProject.ts
┃ ┃ ┃ ┗ 📜getProjects.ts
┣ 📂pages
┃ ┣ 📜_app.tsx
┃ ┣ 📜_document.tsx
┃ ┣ 📜404.tsx
┃ ┣ 📜index.test.tsx
┃ ┗ 📜index.tsx
┗ 📂users
┃ ┗ 📂queries
┃ ┃ ┗ 📜getCurrentUser.ts
It is similar to the way the already existing
auth
folder is structured and like I said I'm new to blitz and the current generate cli command always puts pages inside the default pages directory and it does not structure it like the auth folder which is the perfect way because it makes everything cleaner, maybe there is an cli option I'm not aware of so correct me if I'm wrong. ThanksBeta Was this translation helpful? Give feedback.
All reactions