# README
hgraph
golang 结构体添加自定义标签的方式开发Graphql服务。
// Query结构体示例
type Query struct {
Member Member `graphql:"!member" description:"会员服务"`
Version string
}
// 顶级结构体只有Query与Mutation
// 通过往结构体加属性,可层层嵌套,与Graphql Schema结构一致。
// 结构体对应graphql.NewOject, 结构体字段对应graphql.Field
// Http服务 使用Handel
http.ListenAndServe(":9990", hgraph.GraphqlHttpHandler(Query{}, Mutation{}))
Features
- 结构体自定义标签方式实现Graphql schema。
- 基于Host DNS的方式实现微服务调用(使用docker集群或者改为注册中心等方式实现),Query 与 Mutation 对象的一级字段作为为服务名,子集为业务字段。
- 微服务,客户端可一次请求多个业务服务,合并结果数据返回,多服务对前端无感知。
Change Log
v0.1.0
- 使用Go结构体的方式构建Graphql schema
# Packages
No description provided by the author
# Functions
批量请求Graphql服务响应报文,合并响应结果返回.
调用业务服务 解析请求字符串第一级字段作为服务名调用Graphql服务.
网关调用服务.
Http Handler h := hgraph.GraphqlHttpHandler(&Query{}, &Mutation{}).
i = Query{} i = Mutation{}.
object := Query{} objectType := reflect.TypeOf(object).
No description provided by the author
No description provided by the author
解析Graphql 字符串,第一级Key作为服务名,value拼接为查询字符串.
No description provided by the author
根据服务名调用服务 bytes 为http请求响应body message 为错误消息.
# Variables
Graphql Schema.
# Structs
Graphql 请求JSON Model.
Graphql 响应JSON Model.
No description provided by the author