cli
This module provides the CLI functionality for generating documentation from GraphQL schemas. It exports utilities to run the documentation generator both programmatically and via CLI.
See
GraphQL Markdown Documentation
GraphQLMarkdownCliType
type GraphQLMarkdownCliType = Command;
Defined in: cli/src/index.ts:33
Type representing the GraphQL Markdown CLI.
See
GraphQL Markdown Documentation
RunContext
type RunContext = BuildConfigContext;
Defined in: cli/src/index.ts:38
Internal context set by GraphQL-Markdown entry points.
getGraphQLMarkdownCli()
function getGraphQLMarkdownCli(
options,
loggerModule?,
customFormatter?,
context?,
): Command;
Defined in: cli/src/index.ts:102
Configures and returns the GraphQL Markdown CLI.
Parameters
options
ConfigOptions
Options for configuring the GraphQL Markdown CLI.
loggerModule?
string
Optional logger module to use.
customFormatter?
string
Optional formatter package name used as the fallback when no CLI
flag or configuration sets a formatter. When provided, registers the --formatter flag.
context?
Optional internal context (telemetry trigger).
Returns
Command
The configured CLI instance.
Example
const cli = getGraphQLMarkdownCli(
{ id: "custom" },
"custom-logger",
"@graphql-markdown/formatters/docusaurus",
);
await cli.parseAsync(process.argv);
runGraphQLMarkdown()
function runGraphQLMarkdown(
options,
cliOptions?,
loggerModule?,
context?,
): Promise<
Omit<ConfigOptions, "homepage" | "linkRoot" | "pretty" | "rootPath"> &
Required<
Pick<
ConfigOptions,
| "diffMethod"
| "docOptions"
| "metatags"
| "onlyDocDirective"
| "printTypeOptions"
| "skipDocDirective"
> &
object
> &
object
>;
Defined in: cli/src/index.ts:59
Runs the GraphQL Markdown CLI to generate documentation from a GraphQL schema.
Parameters
options
ConfigOptions
Options for configuring the GraphQL Markdown CLI.
cliOptions?
CliOptions
Optional command-line options passed to the CLI.
loggerModule?
string
Optional logger module to use.
context?
Optional internal context (telemetry trigger, entry-point defaults).
Returns
Promise<Omit<ConfigOptions, "homepage" | "linkRoot" | "pretty" | "rootPath"> & Required<Pick<ConfigOptions,
| "diffMethod"
| "docOptions"
| "metatags"
| "onlyDocDirective"
| "printTypeOptions"
| "skipDocDirective"> & object> & object>
The resolved configuration the documentation was generated with.
Example
await runGraphQLMarkdown(
{ id: "custom" },
{ schema: "./schema.graphql", root: "./docs" },
"custom-logger",
);