Skip to content

cescoferraro/structql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

structql

GoDoc

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
	},
},

image

About

Transform structs into Graphql types. For super fast Graphql development using Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages