项目详情
由
分享
HelloGitHub 评分
0 人评分
Facebook GraphQL 协议的 Go 语言版本
过去 7 天共收获 0 颗 Star ✨
使用方向键查看日期,Home 和 End 跳至首尾,Escape 关闭提示。| 日期 | Star | 较前日 |
|---|---|---|
| 周三 | 1,570 | — |
| 周四 | 1,570 | 0 |
| 周五 | 1,570 | 0 |
| 周六 | 1,570 | 0 |
| 周日 | 1,570 | 0 |
| 周一 | 1,570 | 0 |
| 周二 | 1,570 | 0 |
1.6k
星数
否
中文
JavaScript
主语言
否
活跃
55
贡献者
131
Issues
是
组织
无
最新版本
113
Forks
MIT
协议
Facebook GraphQL 协议的 Go 语言版本。相比之前的其它 GraphQL 库,通过反射结构体的 tag 可以自动生成 schema 给前端,更加便于开发。示例代码:
```go
// Friend is a small struct representing a person.
type Friend struct {
FirstName string
Last string `graphql:"lastName"` // use a custom name
Added time.Date `graphql:"-"` // don't expose over graphql
}
// FullName builds a friend's full name.
func (f *Friend) FullName() string {
return fmt.Sprintf("%s %s", f.FirstName, f.Last)
}
// registerFriend registers custom resolvers on the Friend type.
//
// Note: registerFriend wouldn't be necessary if the type only
// had the default struct field resolvers above.
func registerFriend(schema *schemabuilder.Schema) {
object := schema.Object("Friend", Friend{})
// fullName is a computed field on the Friend{} object.
object.FieldFunc("fullName", Friend.FullName)
}
```
收录于:
第 31 期
评论
评分:
暂无精选评论