Documentation ¶
Index ¶
- Constants
- Variables
- func GetSchema() *introspection.Schema
- func Introspect(ctx context.Context, dag *dagger.Client) (*introspection.Schema, error)
- func Overlay(ctx context.Context, logsW io.Writer, overlay fs.FS, outputDir string) (rerr error)
- func SetSchema(schema *introspection.Schema)
- func SetSchemaParents(schema *introspection.Schema)
- type CommonFunctions
- func (c *CommonFunctions) ConvertID(f introspection.Field) bool
- func (c *CommonFunctions) FormatInputType(r *introspection.TypeRef, scopes ...string) (string, error)
- func (c *CommonFunctions) FormatOutputType(r *introspection.TypeRef, scopes ...string) (string, error)
- func (c *CommonFunctions) FormatReturnType(f introspection.Field, scopes ...string) (string, error)
- func (c *CommonFunctions) GetArrayField(f *introspection.Field) ([]*introspection.Field, error)
- func (c *CommonFunctions) InnerType(t *introspection.TypeRef) *introspection.TypeRef
- func (c *CommonFunctions) IsIDableObject(t *introspection.TypeRef) (bool, error)
- func (c *CommonFunctions) IsListOfObject(t *introspection.TypeRef) bool
- func (c *CommonFunctions) IsSelfChainable(t introspection.Type) bool
- func (c *CommonFunctions) ObjectName(t *introspection.TypeRef) (string, error)
- func (c *CommonFunctions) ToLowerCase(s string) string
- func (c *CommonFunctions) ToUpperCase(s string) string
- type Config
- type FormatTypeFuncs
- type GeneratedState
- type Generator
- type SDKLang
Constants ¶
const ( QueryStructName = "Query" QueryStructClientName = "Client" )
Variables ¶
var ErrUnknownSDKLang = errors.New("unknown sdk language")
Functions ¶
func GetSchema ¶
func GetSchema() *introspection.Schema
func Introspect ¶
Introspect gets the Dagger Schema
func SetSchema ¶
func SetSchema(schema *introspection.Schema)
func SetSchemaParents ¶
func SetSchemaParents(schema *introspection.Schema)
SetSchemaParents sets all the parents for the fields.
Types ¶
type CommonFunctions ¶
type CommonFunctions struct {
// contains filtered or unexported fields
}
CommonFunctions formatting function with global shared template functions.
func NewCommonFunctions ¶
func NewCommonFunctions(formatTypeFuncs FormatTypeFuncs) *CommonFunctions
func (*CommonFunctions) ConvertID ¶
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 ¶
func (c *CommonFunctions) FormatInputType(r *introspection.TypeRef, scopes ...string) (string, error)
FormatInputType formats a GraphQL type into the SDK language input
Example: `String` -> `string`
func (*CommonFunctions) FormatOutputType ¶
func (c *CommonFunctions) FormatOutputType(r *introspection.TypeRef, scopes ...string) (string, error)
FormatOutputType formats a GraphQL type into the SDK language output
Example: `String` -> `string`
func (*CommonFunctions) FormatReturnType ¶
func (c *CommonFunctions) FormatReturnType(f introspection.Field, scopes ...string) (string, error)
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 ¶
func (c *CommonFunctions) GetArrayField(f *introspection.Field) ([]*introspection.Field, error)
func (*CommonFunctions) InnerType ¶
func (c *CommonFunctions) InnerType(t *introspection.TypeRef) *introspection.TypeRef
func (*CommonFunctions) IsIDableObject ¶
func (c *CommonFunctions) IsIDableObject(t *introspection.TypeRef) (bool, error)
func (*CommonFunctions) IsListOfObject ¶
func (c *CommonFunctions) IsListOfObject(t *introspection.TypeRef) bool
func (*CommonFunctions) IsSelfChainable ¶
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) ObjectName ¶
func (c *CommonFunctions) ObjectName(t *introspection.TypeRef) (string, error)
func (*CommonFunctions) ToLowerCase ¶
func (c *CommonFunctions) ToLowerCase(s string) string
func (*CommonFunctions) ToUpperCase ¶
func (c *CommonFunctions) ToUpperCase(s string) string
type Config ¶
type Config struct { // Language supported by this codegen infra. Lang SDKLang // Destination directory for generated code. OutputDir string // Name of the module to generate code for ModuleName string ModuleContextPath string // Optional pre-computed introspection json string IntrospectionJSON string }
type FormatTypeFuncs ¶
type FormatTypeFuncs interface { WithScope(scope string) FormatTypeFuncs 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, input bool) string FormatKindInputObject(representation string, refName string, input bool) string FormatKindEnum(representation string, refName string) string }
FormatTypeFuncs is an interface to format any GraphQL type. Each generator has to implement this interface.
type GeneratedState ¶
type GeneratedState struct { // Overlay is the overlay filesystem that contains generated code to write // over the output directory. Overlay fs.FS // PostCommands are commands that need to be run after the codegen has // finished. This is used for example to run `go mod tidy` after generating // Go code. PostCommands []*exec.Cmd // NeedSync indicates that the code needs to be generated again. This can // happen if the codegen spat out templates that depend on generated types. // In that case the codegen needs to be run again with both the templates and // the initially generated types available. NeedRegenerate bool }
type Generator ¶
type Generator interface { // Generate runs codegen and returns a map of default filename to content for that file. Generate(ctx context.Context, schema *introspection.Schema) (*GeneratedState, error) }