Skip to main content

@baeta/generator

Classes

Watcher

Constructors

new Watcher()

new Watcher(cwd, options?): Watcher

Parameters
ParameterType

cwd

string

options?

Options

Returns

Watcher

Methods

close()

close(): Promise<void>

Returns

Promise<void>

createSubscription()

createSubscription(): object

Returns

object

NameType
unsubscribe() => Promise<void>
ignore()

ignore(pattern): void

Parameters
ParameterType

pattern

MatchPattern

Returns

void

off()

off(event, listener): void

Parameters
ParameterType

event

EventType

listener

WatcherListener

Returns

void

on()

on(event, listener): void

Parameters
ParameterType

event

EventType

listener

WatcherListener

Returns

void

onEvents()

onEvents(err, events): void

Parameters
ParameterType

err

null | Error

events

Event[]

Returns

void

unignore()

unignore(pattern): void

Parameters
ParameterType

pattern

MatchPattern

Returns

void

Interfaces

GeneratorHooks

Properties

PropertyType

onEnd?

() => void | Promise<void>

onError?

(error: unknown) => void | Promise<void>

onPluginStepEnd?

(plugin: GeneratorPluginV1<unknown>, step: "end" | "setup" | "generate") => void | Promise<void>

onPluginStepStart?

(plugin: GeneratorPluginV1<unknown>, step: "end" | "setup" | "generate") => void | Promise<void>

onStart?

() => void | Promise<void>


GeneratorOptions

Options for the Baeta Generator.

Properties

PropertyTypeDefault valueDescription

schemas

string[]

["src/∗∗/∗.gql", "src/∗∗/∗.graphql"];

Glob pattern(s) to locate GraphQL schema files.

baseTypesPath?

string

`${modulesDir}/../__generated__/types.ts`;

Output path for the generated base types file.

contextType?

string

undefined;

Path to the context type definition. Supports both named and default exports.

Examples

contextType: "src/types/context.ts#Context"; // for named export
contextType: "src/types/context.ts"; // for default export

cwd?

string

process.cwd();

Current working directory for resolving relative paths.

extensions?

string

undefined;

Path to Baeta Extensions (ex. auth-extension). Only default export is supported.

Example

extensions: "src/extensions.ts";

fileOptions?

FileOptions

undefined

Configuration options for generated files.

importExtension?

false | ".js" | ".ts"

".ts";

File extension to use in generated import statements. Set to false to omit extensions.

loaders?

Loader<any>[]

undefined

Custom schema loaders for processing schema files.

moduleDefinitionName?

string

"typedef.ts";

Filename for the generated module definition file. Contains type definitions and the GraphQL AST.

modulesDir?

string

"src/modules";

Root directory where GraphQL modules are defined.

scalars?

Record<string, string>

undefined;

Custom scalar type mappings. Maps GraphQL scalar types to TypeScript types. Supports global types and imports.

Example

{ DateTime: 'Date', JSON: 'Record<string, unknown>' }	 *

GeneratorPluginV1<Store>

Type Parameters

Type ParameterDefault type

Store

unknown

Properties

PropertyType

actionName

string

end

GeneratorPluginV1Fn<Store>

generate

GeneratorPluginV1Fn<Store>

name

string

setup

GeneratorPluginV1Fn<Store>

type

Generator

version

V1

watch

GeneratorPluginV1WatchOptions


WatcherFile

Properties

PropertyType

path

string

relativePath

string

type

EventType

Type Aliases

WatcherListener()

WatcherListener: (path) => void

Parameters

ParameterType

path

WatcherFile

Returns

void

Functions

generate()

generate(options, plugins, hooks?): Promise<undefined | { didEnd: string[]; didGenerate: string[]; didSetup: string[]; fileManager: FileManager; generatorOptions: NormalizedGeneratorOptions; pluginNames: string[]; watching: boolean; changedFile: WatcherFile; }>

Parameters

ParameterType

options

GeneratorOptions

plugins

GeneratorPluginV1<unknown>[]

hooks?

GeneratorHooks

Returns

Promise<undefined | { didEnd: string[]; didGenerate: string[]; didSetup: string[]; fileManager: FileManager; generatorOptions: NormalizedGeneratorOptions; pluginNames: string[]; watching: boolean; changedFile: WatcherFile; }>


generateAndWatch()

generateAndWatch(options, plugins, hooks?): Watcher

Parameters

ParameterType

options

GeneratorOptions

plugins

GeneratorPluginV1<unknown>[]

hooks?

GeneratorHooks

Returns

Watcher


getGeneratorPlugins()

getGeneratorPlugins(plugins?): GeneratorPluginV1<unknown>[]

Parameters

ParameterType

plugins?

object[]

Returns

GeneratorPluginV1<unknown>[]