# README
go-gen-graphql
Generate a graphql query/mutation body from a struct
package main
import (
"fmt"
gengraphql "github.com/Eun/go-gen-graphql"
)
func main() {
type Data struct {
ID string
Name string `json:"name"`
CreationTime string `graphql:"createdOn"`
ActiveProjects struct {
ID string `json:"id"`
} `json:"projects" graphql:"projects(filter: %q)"`
}
s, err := gengraphql.Generatef(Data{}, nil, "active")
if err != nil {
panic(err)
}
fmt.Println(s)
// Output:
// ID
// name
// createdOn
// projects(filter: "active"){
// id
// }
}
Build History
# Functions
Generate generates a graphql body from a struct.
Generatef generates a graphql body from a struct.
GenerateFromReflectValue generates a graphql body from reflect Type.
# Structs
InvalidTypeError indicates that the type is invalid or not supported.
Options can be used to modify the behavior of Generate, Generatef and GenerateFromReflectValue.