generator

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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