enum

package
v0.0.0-...-7c7107e Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(dir string, generators ...Generator) error

*

  GenEnum generates MarshalGraphQL and UnmarshalGraphQL for enum types

  ````
  type MyEnum string
  const (
	  MyEnumValueA = MyEnum("value_a")
	  MyEnumValueB = MyEnum("value_b")
  )
  ````

  This generates GraphQL enum MyEnum { ValueA ValueB } by go-gen-graphql-schema and
  and MyEnum is supposed to implement `MarshalGraphQL` and `UnmarshalGraphQL` to convert
  ValueA/ValueB to go constants MyEnumValueA/MyEnumValueB and vice versa.

  gqlgen-enum can be used to generate these methods so you don't have to write marshaler/unmarshaler by yourselve.

Types

type EnumKey

type EnumKey struct {
	GoName string
	Name   string
	Value  string
}

type EnumType

type EnumType struct {
	Name string
	Keys []EnumKey
}

func GetEnum

func GetEnum(t *types.Named) *EnumType

GetEnum returns Enum for the named type

type Generator

type Generator interface {
	Filename() string
	Generate(io.Writer, []EnumType) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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