Integrating gqlgen into a Feature-Based Project Structure
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
I'm working on a Go project that utilizes a Feature-Based (also known as Domain-Driven Design or Vertical Slices) project structure. Our goal is for each feature (e.g., users, products, orders) to encapsulate all its related components, including GraphQL schema definitions, resolvers, models, and business logic.
A typical project structure for us looks like this:
```
.
├── go.mod
├── go.sum
├── main.go
└── internal/
├── app/ (main application setup)
├── config/
└── features/
├── users/
│ ├── graph/
│ │ ├── users.graphqls
│ │ ├── users.resolvers.go
│ │ └── users.models.go
│ ├── service/
│ │ └── users.go
│ └── repository/
│ └── users.go
├── products/
│ ├── graph/
│ │ ├── products.graphqls
│ │ ├── products.resolvers.go
│ │ └── products.models.go
│ ├── service/
│ └── repository/
└── orders/
├── graph/
│ ├── orders.graphqls
│ ├── orders.resolvers.go
│ └── orders.models.go
├── service/
└── repository/
```
How can gqlgen be instructed to generate resolvers and models directly into their respective feature-specific directories instead of a single top-level graph folder? For instance, I'd like users.resolvers.go and users.models.go to be generated within features/users/graph/
贡献指南
调研方向
这个 issue 涉及配置 gqlgen 的代码生成,使其将文件输出到特性专属的目录中。首先阅读 gqlgen 的配置文档和源代码,尤其关注 `gqlgen.yml` 文件以及 `exec` 和 `model` 指令相关的部分。查找多 schema 设置或自定义输出路径的现有示例。目标是修改生成流程,使 feature 的 `graph/` 目录中的每个 `.graphqls` schema 都在同一位置生成对应的 resolver 和 model 文件。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go, graphql
- 领域
- api, backend, build-system
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100