https://github.com/cescoferraro/structql
Transform structs into Graphql types. For super fast Graphql development using Go
https://github.com/cescoferraro/structql
Last synced: 13 days ago
JSON representation
Transform structs into Graphql types. For super fast Graphql development using Go
- Host: GitHub
- URL: https://github.com/cescoferraro/structql
- Owner: cescoferraro
- License: bsd-3-clause
- Created: 2020-04-22T11:13:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-26T13:58:29.000Z (over 5 years ago)
- Last Synced: 2024-11-14T13:36:59.416Z (about 1 year ago)
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 6
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - structql
README
# structql
[](https://godoc.org/github.com/cescoferraro/structql)
Easily generate graphl type from any struct in any library. Turns any go package type into a graphql ready object for super fast go/graphql development.
type Token struct {
Code string `json:"code"`
Max int `json:"max"`
Valid bool `json:"valid"`
Expiry time.Time `json:"expiry"`
Data Data `json:"data"`
}
type Data struct {
Name string `json:"name"`
Trys int `json:"trys"`
Valid bool `json:"valid"`
Expiry time.Time `json:"expiry"`
}
#### Usings struct as graphql type:
"token": &graphql.Field{
Type: structql.GenerateType(Token{}),
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
return Token{
Code: "super-secret",
Max: 2,
Valid: false,
Expiry: time.Now(),
Data: Data{
Name: "yay",
Trys: 40,
Valid: true,
Expiry: time.Now(),
},
}, nil
},
},
