Skip to content

Commit f00483d

Browse files
author
lu.jin
committed
updated
1 parent a20a83c commit f00483d

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# graphql-db-api-example
22

3-
本项目提供了 [graphql-db-api](https://github.com/lujin3/graphql-db-api) 的 go demo 示例, 用于适配 superset 的 graphql db 数据源
3+
本项目提供了 [graphql-db-api](https://github.com/lujin3/graphql-db-api) 的 go demo 示例, 用于适配 superset 的 graphql db 数据源.
4+
5+
demo 使用 go github.com/99designs/gqlgen 框架, 其他框架和语言只要 GraphQL schema 和 query 定义一致即可.
46

57
## 目录
68

@@ -16,12 +18,22 @@
1618
`graph/schema.graphql` 中更新您的新 schema 定义。例如:
1719

1820
```graphql
19-
type User {
20-
id: ID!
21-
name: String!
21+
type FirefightingData {
22+
ts: Int! # 时间戳,若是时序数据必须定义,并且字段名固定为 `ts`
23+
building: String! # 指标属性(层级),根据业务数据定义,非必须
24+
floor: String! # 指标属性(层级),根据业务数据定义,非必须
25+
indicator: String! # 指标属性(层级),根据业务数据定义,非必须
26+
value: Int! # 指标的值
27+
}
28+
29+
type Query {
30+
firefighting(startTS: Int, endTS: Int, limit: Int): [FirefightingData] # added
2231
}
2332
```
2433

34+
- 指标属性(层级) 非必须, 如需进行在 BI 中下钻数据,则属性(层级)必须明确且符合下钻场景的层级
35+
- 时序数据, ts 字段为必填字段
36+
2537
2. **生成 gqlgen 配置和模型**
2638
运行以下命令以生成所需的文件:
2739

@@ -37,7 +49,7 @@
3749
### Start the graphql server
3850

3951
```bash
40-
go run github.com/99designs/gqlgen generate
52+
go run server.go
4153
```
4254

4355

@@ -747,6 +759,7 @@ go run github.com/99designs/gqlgen generate
747759
```
748760

749761
![docs](./graphql-docs.png)
762+
![query](./query.png)
750763

751764
### 说明
752765

query.png

74 KB
Loading

0 commit comments

Comments
 (0)