swagger2gql

package
v0.0.0-...-7953320 Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluginName            = "swagger2gql"
	PluginConfigKey       = "swagger2gql"
	PluginImportConfigKey = "swagger2gql_files"
)

Variables

View Source
var ErrMultipleSuccessResponses = errors.New("method  contains multiple success responses")

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func GoPackageByPath

func GoPackageByPath(path, vendorPath string) (string, error)

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Config

type Config struct {
	Files      []*SwaggerFileConfig      `mapstructure:"files"`
	OutputPath string                    `mapstructure:"output_path"`
	Messages   []map[string]ObjectConfig `mapstructure:"messages"`
}

func (*Config) GetOutputPath

func (c *Config) GetOutputPath() string

type FieldConfig

type FieldConfig struct {
	ContextKey string `mapstructure:"context_key"`
}

type MethodConfig

type MethodConfig struct {
	Alias              string         `mapstructure:"alias"`
	RequestType        string         `mapstructure:"request_type"` // QUERY | MUTATION
	DataLoaderProvider ProviderConfig `mapstructure:"data_loader_provider"`
}

type ObjectConfig

type ObjectConfig struct {
	Fields      map[string]FieldConfig   `mapstructure:"fields"`
	DataLoaders []dataloader.FieldConfig `mapstructure:"data_loaders"`
}

type ParamConfig

type ParamConfig struct {
	ParamName  string `mapstructure:"param_name"`
	ContextKey string `mapstructure:"context_key"`
}

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func (Plugin) Generate

func (Plugin) Generate() error

func (*Plugin) Infos

func (p *Plugin) Infos() map[string]string

func (*Plugin) Init

func (p *Plugin) Init(config *generator.GenerateConfig, plugins []generator.Plugin) error

func (Plugin) Name

func (Plugin) Name() string

func (*Plugin) Prepare

func (p *Plugin) Prepare() error

func (*Plugin) PrintInfo

func (p *Plugin) PrintInfo(info generator.Infos)

func (*Plugin) TypeInputTypeResolver

func (p *Plugin) TypeInputTypeResolver(typeFile *parsedFile, typ parser.Type) (graphql.TypeResolver, error)

func (*Plugin) TypeOutputTypeResolver

func (p *Plugin) TypeOutputTypeResolver(typeFile *parsedFile, typ parser.Type, required bool) (graphql.TypeResolver, error)

func (*Plugin) TypeValueResolver

func (p *Plugin) TypeValueResolver(
	file *parsedFile,
	typ parser.Type,
	required bool,
	ctxKey string) (_ graphql.ValueResolver, withErr, fromArgs bool, err error)

type ProviderConfig

type ProviderConfig struct {
	Name         string        `mapstructure:"name"`
	WaitDuration time.Duration `mapstructure:"wait_duration"`
	Slice        bool
}

type SwaggerFileConfig

type SwaggerFileConfig struct {
	Name string `mapstructure:"name"`

	Path string `mapstructure:"path"`

	ModelsGoPath string `mapstructure:"models_go_path"`

	OutputPkg  string `mapstructure:"output_package"`
	OutputPath string `mapstructure:"output_path"`

	GQLObjectsPrefix string `mapstructure:"gql_objects_prefix"`

	Tags         map[string]*TagConfig     `mapstructure:"tags"`
	Objects      []map[string]ObjectConfig `mapstructure:"objects"`
	ParamsConfig []ParamConfig             `mapstructure:"params_config"`
}

func (*SwaggerFileConfig) FieldConfig

func (pc *SwaggerFileConfig) FieldConfig(objName string, fieldName string) (FieldConfig, error)

func (*SwaggerFileConfig) GetGQLMessagePrefix

func (pc *SwaggerFileConfig) GetGQLMessagePrefix() string

func (*SwaggerFileConfig) GetName

func (pc *SwaggerFileConfig) GetName() string

func (*SwaggerFileConfig) GetObjects

func (pc *SwaggerFileConfig) GetObjects() []map[string]ObjectConfig

func (*SwaggerFileConfig) GetOutputPath

func (pc *SwaggerFileConfig) GetOutputPath() string

func (*SwaggerFileConfig) GetOutputPkg

func (pc *SwaggerFileConfig) GetOutputPkg() string

func (*SwaggerFileConfig) GetPath

func (pc *SwaggerFileConfig) GetPath() string

func (*SwaggerFileConfig) GetTags

func (pc *SwaggerFileConfig) GetTags() map[string]*TagConfig

func (*SwaggerFileConfig) ObjectConfig

func (pc *SwaggerFileConfig) ObjectConfig(objName string) (ObjectConfig, error)

type TagConfig

type TagConfig struct {
	ClientGoPackage string                             `mapstructure:"client_go_package"`
	ServiceName     string                             `mapstructure:"service_name"`
	Methods         map[string]map[string]MethodConfig `mapstructure:"methods"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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