printer
getPrinter()β
function getPrinter(
printerModule?,
config?,
options?,
mdxModule?): Promise<typeof IPrinter>
Defined in: printer.ts:60
Loads and initializes a printer module for GraphQL schema documentation.
This function dynamically imports the specified printer module and initializes it with the provided configuration and options. The printer is responsible for rendering GraphQL schema documentation in the desired format.
Parametersβ
printerModule?β
Maybe
<PackageName
>
The name/path of the printer module to load
config?β
Maybe
<PrinterConfig
>
Configuration for the printer including schema, baseURL, and linkRoot
options?β
Maybe
<PrinterOptions
>
Additional options for customizing the printer's behavior
mdxModule?β
unknown
Optional MDX module for MDX-specific functionality
Returnsβ
Promise
<typeof IPrinter
>
A promise that resolves to the initialized Printer instance
Throwsβ
Will throw an error if printerModule is not a string
Throwsβ
Will throw an error if config is not provided
Throwsβ
Will throw an error if the module specified by printerModule cannot be found
Exampleβ
import { getPrinter } from '@graphql-markdown/core';
import { buildSchema } from 'graphql';
const schema = buildSchema(`
type Query {
hello: String
}
`);
const printer = await getPrinter(
'@graphql-markdown/printer-legacy',
{
schema,
baseURL: '/docs',
linkRoot: 'graphql'
},
{
printTypeOptions: { includeDeprecationReasons: true }
}
);
const output = printer.printSchema();