generator

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: Apache-2.0 Imports: 8 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",
	"ProjectID":        "Project",
	"ProjectCommandID": "ProjectCommand",
}

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) (*introspection.Schema, error)

Introspect get the Dagger Schema

func IntrospectAndGenerate

func IntrospectAndGenerate(ctx context.Context, generator Generator) ([]byte, error)

IntrospectAndGenerate generate the Dagger API

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) ConvertID added in v0.5.3

func (c *CommonFunctions) ConvertID(f introspection.Field) bool

ConvertID returns true if the field returns an ID that should be converted into an object.

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`

func (*CommonFunctions) FormatReturnType added in v0.5.3

func (c *CommonFunctions) FormatReturnType(f introspection.Field) string

FormatReturnType formats a GraphQL type into the SDK language output, unless it's an ID that will be converted which needs to be formatted as an input (for chaining).

func (*CommonFunctions) GetArrayField added in v0.8.0

func (c *CommonFunctions) GetArrayField(f *introspection.Field) []*introspection.Field

func (*CommonFunctions) IsListOfObject added in v0.8.0

func (c *CommonFunctions) IsListOfObject(t *introspection.TypeRef) bool

func (*CommonFunctions) IsSelfChainable added in v0.6.4

func (c *CommonFunctions) IsSelfChainable(t introspection.Type) bool

IsSelfChainable returns true if an object type has any fields that return that same type.

func (*CommonFunctions) ToLowerCase added in v0.8.0

func (c *CommonFunctions) ToLowerCase(s string) string

func (*CommonFunctions) ToUpperCase added in v0.8.0

func (c *CommonFunctions) ToUpperCase(s 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 🇻🇳