structql

package module
v0.0.0-...-8b63e41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2020 License: BSD-3-Clause Imports: 5 Imported by: 2

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateType

func GenerateType(y interface{}) *graphql.Object

GenerateType does all the magic. generates graphql objects from any struct interface

func SetDefaultTag

func SetDefaultTag(tag string)

SetDefaultTag SetDefaultTag set the struct tag we should look for name matching. defaults to json

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL