Repository Details
Shared by
HelloGitHub Rating
0 ratings
Facebook GraphQL 协议的 Go 语言版本
Past 7 days Received 0 stars ✨
Use arrow keys to explore dates, Home and End for the first and last date, Escape to dismiss.| Date | Star | Daily change |
|---|---|---|
| 周二 | 1,570 | — |
| 周三 | 1,570 | 0 |
| 周四 | 1,570 | 0 |
| 周五 | 1,570 | 0 |
| 周六 | 1,570 | 0 |
| 周日 | 1,570 | 0 |
| 周一 | 1,570 | 0 |
1.6k
Stars
No
Chinese
JavaScript
Language
No
Active
55
Contributors
131
Issues
Yes
Organization
None
Latest
111
Forks
MIT
License
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)
}
```
Included in:
Vol.31
Comments
Rating:
No comments yet