Categorygithub.com/Eun/go-gen-graphql
modulepackage
0.0.3
Repository: https://github.com/eun/go-gen-graphql.git
Documentation: pkg.go.dev

# README

go-gen-graphql

Actions Status Coverage Status PkgGoDev go-report

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

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.