print-type
Print type event classes.
Event classes for print operations that allow handlers to modify the generated output.
Events
PrintCodeEvent
Defined in: events/print-type.ts:45
Event emitted before/after generating the code block for a GraphQL type.
The output property is mutable, allowing event handlers to modify
the generated code before it's included in the documentation.
Example
events.on(PrintTypeEvents.AFTER_PRINT_CODE, (event: PrintCodeEvent) => {
// Add a comment to all generated code
event.output = `# Auto-generated\n${event.output}`;
});
Extends
Constructors
Constructor
new PrintCodeEvent(
data,
initialOutput,
options?): PrintCodeEvent;
Defined in: events/print-type.ts:55
Parameters
data
initialOutput
string
options?
Returns
Overrides
Properties
data
readonly data: PrintCodeEventData;
Defined in: events/print-type.ts:47
Read-only event data
output
output: string;
Defined in: events/print-type.ts:53
The generated code output. Handlers can modify this property to change the final output.
Accessors
defaultAction
Get Signature
get defaultAction(): DefaultAction | undefined;
Defined in: events/base.ts:109
Gets the default action function if one was provided.
Returns
DefaultAction | undefined
Inherited from
CancellableEvent.defaultAction
defaultPrevented
Get Signature
get defaultPrevented(): boolean;
Defined in: events/base.ts:95
Gets whether the default action has been prevented.
Returns
boolean
Inherited from
CancellableEvent.defaultPrevented
propagationStopped
Get Signature
get propagationStopped(): boolean;
Defined in: events/base.ts:102
Gets whether propagation has been stopped.
Returns
boolean
Inherited from
CancellableEvent.propagationStopped
Methods
preventDefault()
preventDefault(): void;
Defined in: events/base.ts:127
Prevents the default action from executing. Only works if the event is cancellable.
Returns
void
Example
events.on("beforeLoadSchema", (event) => {
if (shouldUseCustomLoader) {
event.preventDefault(); // Stops default schema loading
// Custom logic here
}
});
Inherited from
CancellableEvent.preventDefault
runDefaultAction()
runDefaultAction(): Promise<void>;
Defined in: events/base.ts:160
Executes the default action for an event if it hasn't been prevented.
Returns
Promise<void>
A promise that resolves when the default action completes, or void if the action was prevented or no default action is defined
Remarks
This method will only execute the _defaultAction if:
- The event's default has not been prevented (
_defaultPreventedis false) - A default action function has been defined (
_defaultActionis a function)
Inherited from
CancellableEvent.runDefaultAction
stopPropagation()
stopPropagation(): void;
Defined in: events/base.ts:146
Stops propagation to remaining event handlers. Handlers registered after the current one will not execute.
Returns
void
Example
events.on("beforeLoadSchema", (event) => {
if (criticalError) {
event.stopPropagation(); // No more handlers run
}
});
Inherited from
CancellableEvent.stopPropagation
PrintTypeEvent
Defined in: events/print-type.ts:94
Event emitted before/after generating the full documentation for a GraphQL type.
The output property is mutable, allowing event handlers to modify
the complete generated documentation.
Example
events.on(PrintTypeEvents.AFTER_PRINT_TYPE, (event: PrintTypeEvent) => {
// Add a footer to all type documentation
event.output = `${event.output}\n\n---\nGenerated by GraphQL-Markdown`;
});
Extends
Constructors
Constructor
new PrintTypeEvent(
data,
initialOutput,
options?): PrintTypeEvent;
Defined in: events/print-type.ts:104
Parameters
data
initialOutput
Maybe<MDXString>
options?
Returns
Overrides
Properties
data
readonly data: PrintTypeEventData;
Defined in: events/print-type.ts:96
Read-only event data
output
output: Maybe<MDXString>;
Defined in: events/print-type.ts:102
The generated documentation output. Handlers can modify this property to change the final output.
Accessors
defaultAction
Get Signature
get defaultAction(): DefaultAction | undefined;
Defined in: events/base.ts:109
Gets the default action function if one was provided.
Returns
DefaultAction | undefined
Inherited from
CancellableEvent.defaultAction
defaultPrevented
Get Signature
get defaultPrevented(): boolean;
Defined in: events/base.ts:95
Gets whether the default action has been prevented.
Returns
boolean
Inherited from
CancellableEvent.defaultPrevented
propagationStopped
Get Signature
get propagationStopped(): boolean;
Defined in: events/base.ts:102
Gets whether propagation has been stopped.
Returns
boolean
Inherited from
CancellableEvent.propagationStopped
Methods
preventDefault()
preventDefault(): void;
Defined in: events/base.ts:127
Prevents the default action from executing. Only works if the event is cancellable.
Returns
void
Example
events.on("beforeLoadSchema", (event) => {
if (shouldUseCustomLoader) {
event.preventDefault(); // Stops default schema loading
// Custom logic here
}
});
Inherited from
CancellableEvent.preventDefault
runDefaultAction()
runDefaultAction(): Promise<void>;
Defined in: events/base.ts:160
Executes the default action for an event if it hasn't been prevented.
Returns
Promise<void>
A promise that resolves when the default action completes, or void if the action was prevented or no default action is defined
Remarks
This method will only execute the _defaultAction if:
- The event's default has not been prevented (
_defaultPreventedis false) - A default action function has been defined (
_defaultActionis a function)
Inherited from
CancellableEvent.runDefaultAction
stopPropagation()
stopPropagation(): void;
Defined in: events/base.ts:146
Stops propagation to remaining event handlers. Handlers registered after the current one will not execute.
Returns
void
Example
events.on("beforeLoadSchema", (event) => {
if (criticalError) {
event.stopPropagation(); // No more handlers run
}
});
Inherited from
CancellableEvent.stopPropagation
Other
PrintCodeEventData
Defined in: events/print-type.ts:20
Data payload for print code events.
Properties
options
readonly options: PrintTypeOptions;
Defined in: events/print-type.ts:26
The print options in effect
type
readonly type: unknown;
Defined in: events/print-type.ts:22
The GraphQL type being printed
typeName
readonly typeName: string;
Defined in: events/print-type.ts:24
The name of the type
PrintTypeEventData
Defined in: events/print-type.ts:69
Data payload for print type events.
Properties
name
readonly name: Maybe<string>;
Defined in: events/print-type.ts:73
The name identifier for the type
options
readonly options: PrintTypeOptions;
Defined in: events/print-type.ts:75
The print options in effect
type
readonly type: unknown;
Defined in: events/print-type.ts:71
The GraphQL type being printed