Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

根据GraphQL Schema生成Dgraph Schema #10

Closed
wangyuheng opened this issue Sep 1, 2020 · 0 comments · Fixed by #11
Closed

根据GraphQL Schema生成Dgraph Schema #10

wangyuheng opened this issue Sep 1, 2020 · 0 comments · Fixed by #11
Assignees
Labels
Doing enhancement New feature or request
Milestone

Comments

@wangyuheng
Copy link
Owner

wangyuheng commented Sep 1, 2020

概念:

  1. Dgraph Schema: Dgraph数据库结构化语句,类似mysql中的DDL
  2. predicate: Dgraph的数据库字段,一个predicate可以被多个type使用
  3. domainClass: Arc框架中定义javaBean类型,用于反序列化

背景

为了提升开发效率,加快schema领域模型验证。
希望在根据GraphQL Schema自动生成Java代码(#5) 的同时,可以自动生成数据库结构语句,并可根据需要自动执行数据库初始化(#7)

方案

解析GraphQL Schema后,根据转换逻辑生成Dgraph Schema

注意Arc框架限制

  1. DB结构中拥有框架依赖通用predicate,如 domainClass
  2. 为了解决predicate跨type定义问题,dgraph中的predicate命名增加type为前缀

验收

  1. 根据 https://github.com/YituHealthcare/Arc/blob/master/sample/full-sample/src/main/resources/graphql/schema.graphqls 自动生成Dgraph Schema
<domainClass>: string .
<dgraph.graphql.schema>: string .
<PROJECT.name>: string .
<PROJECT.description>: string .
<PROJECT.category>: [string] .
<PROJECT.createTime>: dateTime .
<PROJECT.milestones>: [uid] .
<MILESTONE.name>: string .
<MILESTONE.status>: string .
<USER.name>: string .
type Project {
domainClass
dgraph.graphql.schema
PROJECT.name
PROJECT.description
PROJECT.category
PROJECT.createTime
PROJECT.milestones
}
type Milestone {
domainClass
dgraph.graphql.schema
MILESTONE.name
MILESTONE.status
}
type User {
domainClass
dgraph.graphql.schema
USER.name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Doing enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant