robingo.trulyao.dev/robin/generator Index | Files | Directories

package generator

import "go.trulyao.dev/robin/generator"

Index

Functions

func New

func New(procedures []types.Procedure) *generator

func NormalizeProcedureName

func NormalizeProcedureName(name string) string

NormalizeProcedureName normalizes the procedure name to a valid typescript function name For example, todo.create -> todoCreate, sign-in -> signIn etc This is done to ensure that the generated method names are valid

Types

type GenerateBindingsOpts

type GenerateBindingsOpts struct {
	// Whether to include the schema in the generated bindings file or not
	IncludeSchema bool

	// The generated schema type
	Schema string

	// Whether to use the union result type or not - when enabled, the result type will be a uniion of the Ok and Error types which would disallow access to any of the fields without checking the `ok` field first
	UseUnionResult bool

	// Whether to throw a ProcedureCallError when a procedure call fails for any reason (e.g. invalid payload, user-defined error, etc.) instead of returning an error result
	ThrowOnError bool
}

type GenerateMethodsOpts

type GenerateMethodsOpts struct {
	ThrowOnError bool
}

type GeneratedMethods

type GeneratedMethods struct {
	Mutations []string
	Queries   []string
}

type MethodTemplateOpts

type MethodTemplateOpts struct {
	OriginalName string
	Name         string
	Type         string
	HasPayload   bool
	ThrowOnError bool
}

type TemplateOpts

type TemplateOpts struct {
	// Whether to include the schema in the generated bindings file or not
	IncludeSchema bool

	// The generated schema type
	Schema string

	// The generated query methods
	QueryMethods string

	// The generated mutation methods
	MutationMethods string

	// Whether to use the union result type or not - when enabled, the result type will be a uniion of the Ok and Error types which would disallow access to any of the fields without checking the `ok` field first
	UseUnionResult bool

	// Whether to throw a ProcedureCallError when a procedure call fails for any reason (e.g. invalid payload, user-defined error, etc.) instead of returning an error result
	ThrowOnError bool
}

Source Files

generator.go

Directories

PathSynopsis
generator/templates
Version
v0.7.0 (latest)
Published
Mar 7, 2025
Platform
linux/amd64
Imports
14 packages
Last checked
1 hour ago

Tools for package owners.