Skip to content

Commit 63a8442

Browse files
author
lu.jin
committed
updated README.md
1 parent d468f3c commit 63a8442

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

README.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,35 @@
1-
# graphql-db-api-example
2-
example for Advantech APPs GraphQL APIs
1+
# graphql-db-api-example
2+
3+
本项目提供了 [graphql-db-api](https://github.com/lujin3/graphql-db-api) 的 go demo 示例, 用于适配 superset 的 graphql db 数据源
4+
5+
## 添加新接口
6+
7+
按照以下步骤在您的 GraphQL 服务器中添加新的 API 端点:
8+
9+
1. **定义 schema**
10+
`graph/schema.graphql` 中更新您的新 schema 定义。例如:
11+
12+
```graphql
13+
type User {
14+
id: ID!
15+
name: String!
16+
}
17+
```
18+
19+
2. **生成 gqlgen 配置和模型**
20+
运行以下命令以生成所需的文件:
21+
22+
```bash
23+
go run github.com/99designs/gqlgen generate
24+
```
25+
26+
3. **开发 resolver**
27+
在 `graph/schema.resolvers.go` 中实现您新 API 的逻辑。该文件包含负责获取和返回数据的 resolver。
28+
29+
## Quick start
30+
31+
### Start the graphql server
32+
33+
```bash
34+
go run github.com/99designs/gqlgen generate
35+
```

0 commit comments

Comments
 (0)