gqlutils

package module
v0.0.0-...-d4074e7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2018 License: MIT Imports: 4 Imported by: 0

README

gqlutils

My utilities to work with Graphql

Go Report Card Build Status Coverage Status GoDoc License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StructToFields

func StructToFields(strct interface{}) graphql.Fields

StructToFields takes a json tag and generate fields.

The following function supports the json tag rules, and adding additional tags:

  • type - The datatype to use (Golang's basic data types). If non provided, the default data type of the field will be used.
  • desc - description for the field
  • deprecation - A deprecation message for the field

Example for struct:

 type test struct {
	  ID       int       `json:"id,omitempty" desc:"foo bar" type:"int64"`
	  Name     string    `json:"-"`
	  DateTime time.Time `json:"date_time" type:"time" desc:"DateTime"`
	  KeyName  int64     `json:"-," deprecation:""`
	  Nothing  string
 }

func TypeToGQLType

func TypeToGQLType(typ string) *graphql.Scalar

TypeToGQLType takes a string with a type and converts it into graphql Scalar. If unknown type is found, it returns graphql.String.

Supported data types:

  • integer (byte, uintptr, int, int8, int16, int32, int64, uint..uint64)
  • floating point (float32, float64, complex64, complex128)
  • string (string, rune)
  • date/time
  • boolean

Types

This section is empty.

Jump to

Keyboard shortcuts

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