generator

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryStructName       = "Query"
	QueryStructClientName = "Client"
)

Variables

View Source
var CustomScalar = map[string]string{
	"ContainerID": "Container",
	"FileID":      "File",
	"DirectoryID": "Directory",
	"SecretID":    "Secret",
	"SocketID":    "Socket",
	"CacheID":     "CacheVolume",
}

CustomScalar registers custom Dagger type. TODO: This may done it dynamically later instead of a static map.

View Source
var ErrUnknownSDKLang = errors.New("unknown sdk language")

Functions

func GetSchema added in v0.4.2

func GetSchema() *introspection.Schema

func Introspect added in v0.3.5

func Introspect(ctx context.Context, r *router.Router) (*introspection.Schema, error)

Introspect get the Dagger Schema with the router r.

func IntrospectAndGenerate

func IntrospectAndGenerate(ctx context.Context, r *router.Router, generator Generator) ([]byte, error)

IntrospectAndGenerate generate the Dagger API with the router r.

func SetSchema added in v0.4.2

func SetSchema(schema *introspection.Schema)

func SetSchemaParents added in v0.3.5

func SetSchemaParents(schema *introspection.Schema)

SetSchemaParents sets all the parents for the fields.

Types

type CommonFunctions added in v0.3.12

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

CommonFunctions formatting function with global shared template functions.

func NewCommonFunctions added in v0.3.12

func NewCommonFunctions(formatTypeFuncs FormatTypeFuncs) *CommonFunctions

func (*CommonFunctions) FormatInputType added in v0.3.12

func (c *CommonFunctions) FormatInputType(r *introspection.TypeRef) string

FormatInputType formats a GraphQL type into the SDK language input

Example: `String` -> `string`

func (*CommonFunctions) FormatOutputType added in v0.3.12

func (c *CommonFunctions) FormatOutputType(r *introspection.TypeRef) string

FormatOutputType formats a GraphQL type into the SDK language output

Example: `String` -> `string`

type Config

type Config struct {
	Lang SDKLang
	// Package is the target package that is generated.
	// Not used for the SDKLangNodeJS.
	Package string
}

type FormatTypeFuncs added in v0.3.12

type FormatTypeFuncs interface {
	FormatKindList(representation string) string
	FormatKindScalarString(representation string) string
	FormatKindScalarInt(representation string) string
	FormatKindScalarFloat(representation string) string
	FormatKindScalarBoolean(representation string) string
	FormatKindScalarDefault(representation string, refName string, input bool) string
	FormatKindObject(representation string, refName string) string
	FormatKindInputObject(representation string, refName string) string
	FormatKindEnum(representation string, refName string) string
}

FormatTypeFuncs is an interface to format any GraphQL type. Each generator has to implement this interface.

type Generator added in v0.3.5

type Generator interface {
	Generate(ctx context.Context, schema *introspection.Schema) ([]byte, error)
}

type SDKLang added in v0.3.5

type SDKLang string
const (
	SDKLangGo     SDKLang = "go"
	SDKLangNodeJS SDKLang = "nodejs"
	SDKLangPython SDKLang = "python"
)

Directories

Path Synopsis
go
templates
Go name linting.
Go name linting.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳