Skip to main content

Settings

Every setting is a plugin option in your config file, and most have a CLI flag that overrides it. Run the CLI with npx docusaurus graphql-to-doc (Docusaurus plugin) or npx gqlmd graphql-to-doc (standalone), and see configuration for where the config lives.

At a glance​

OptionTypeDefaultPurpose
schemastring./schema.graphqlPath, URL or introspection result of the schema
loadersobject{ }GraphQL schema loaders
rootPathstring./docsRoot folder for the generated documentation
baseURLstringschemaBase URL and output folder name under rootPath
linkRootstring/Root path used for type cross-links
docOptionsobject-Index pages, front matter, category sort, header IDs
printTypeOptionsobject-Hierarchy, deprecated handling, badges, parent prefix
groupByDirectivestringundefinedGroup types by a directive: @directive(field|=fallback)
homepagestring | falsegenerated.mdLanding page file, false to disable
idstringdefaultIdentifier of the configuration instance
onlyDocDirectivestring[][]Include only types with these directives
skipDocDirectivestring[][]Exclude types with these directives
customDirectiveobjectundefinedDeprecated, use decorators
decoratorsobjectundefinedRender custom content for schema nodes
formatterstringundefinedPackage name or path to a formatter module
outputAdapterobjectlocal filesystemWrite pages somewhere other than the filesystem
metatagsobject[][]Page <head> metadata
prettybooleanfalseFormat generated files with Prettier
forcebooleanfalseForce regeneration of all files
diffMethodstringNONEChange detection: NONE, FORCE, SCHEMA-DIFF, SCHEMA-HASH
tmpDirstringOS temp folderFolder for the schema copy and signature
telemetrybooleanonAnonymous usage telemetry
--configflagnullPrint the resolved configuration

CLI flags​

Every flag below works with npx docusaurus graphql-to-doc (Docusaurus plugin) and npx gqlmd graphql-to-doc (standalone CLI), and overrides the matching setting.

FlagSettingDescription
-s, --schema <path>schemaSchema file, URL, or introspection JSON
-b, --base <baseURL>baseURLBase URL and output folder name
-r, --root <rootPath>rootPathRoot output folder
-l, --link <linkRoot>linkRootRoot path for cross-links
-h, --homepage <file>homepageCustom homepage file
-f, --forceforceSkip diff, always regenerate
-d, --diff <method>diffMethodDiff method (NONE, SCHEMA-DIFF, etc.)
-t, --tmp <dir>tmpDirTemp dir for schema diffing
--indexdocOptions.indexGenerate category index pages
--hierarchy <type>printTypeOptions.hierarchyFolder structure: api, entity, flat
--deprecated <option>printTypeOptions.deprecateddefault, group, or skip
--noParentTypeprintTypeOptions.parentTypePrefixHide parent type prefix on fields
--noTypeBadgesprintTypeOptions.typeBadgesHide type attribute badges
--noSectionIddocOptions.sectionHeaderIdDisable section header IDs for permalinks
--only <@directive...>onlyDocDirectiveInclude only types with these directives
--skip <@directive...>skipDocDirectiveExclude types with these directives
--groupByDirective <expr>groupByDirectiveGroup by directive: @dir(field|=fallback)
--prettyprettyFormat output with Prettier
--formatter <pkg>formatterFormatter package name or path
--mdxParser <pkg>mdxParser (deprecated)Deprecated alias for formatter
--config--configPrint resolved config (debug)
--no-telemetrytelemetryDisable anonymous usage telemetry

--formatter and --mdxParser are only registered when the CLI has a default formatter package, as @graphql-markdown/docusaurus does. The standalone gqlmd command doesn't expose them, so set formatter in your configuration file instead.

Input​

Where the schema comes from and how its pages are addressed.

schema​

The GraphQL schema location.

SettingCLI flagDefault
schema-s, --schema <schema>./schema.graphql

loaders​

GraphQL schema loaders to use (see schema loading).

SettingCLI flagDefault
loadersnot supported{ }

rootPath​

The output root path for the generated documentation, relative to the current workspace. It works with baseURL, and the final path will be rootPath/baseURL.

SettingCLI flagDefault
rootPath-r, --root <rootPath>./docs

baseURL​

The base URL used by Docusaurus. It will also be used as the folder name under rootPath for the generated documentation.

SettingCLI flagDefault
baseURL-b, --base <baseURL>schema

linkRoot​

The root for links in documentation. It depends on the entry for the schema main page in the Docusaurus sidebar.

SettingCLI flagDefault
linkRoot-l, --link <linkRoot>/

Output structure​

How generated pages are organized, named and linked.

docOptions​

Use these options to tweak some of the static documentation generator features:

  • categorySort: control how categories are sorted in the sidebar. Can be "natural" for alphabetical sorting or a custom compare function. When enabled, folder names are automatically prefixed with zero-padded order numbers (e.g., 01-objects, 02-queries). When not set, the order depends on document generator folders sorting and no prefixes are added.
  • frontMatter: set custom front matter entries as key/value. If set to false, then it will disable the frontmatter and print a level 1 title as the page title.
  • index: enable/disable the index page for categories/groups, see Docusaurus documentation — ONLY FOR DOCUSAURUS
  • sectionHeaderId: enable/disable the generation of custom header IDs for permalinks. When disabled, field and argument names are printed without a link, since their headings have no known anchor. The syntax depends on the formatter:
    • Docusaurus 3.10 and later: ### Section {/* #ID */} (see Strict Heading IDs and heading IDs).
    • Fumadocs: ### Section [#ID].
    • Other formatters: the classic ### Section {#ID}.
    • Starlight and Vocs have no custom header ID syntax, so the classic one is escaped as ### Section \{#ID\} to keep the page valid MDX. It is only resolved if a remark plugin such as remark-custom-heading-id is configured.
    • DocFX does not support {#ID} by default, so its formatter appends an HTML anchor <a id="ID"></a> to the heading instead.
    • Override formatMDXPermalink in a custom formatter to change it.
SettingCLI flagDefault
docOptions.categorySortnot supported-
docOptions.frontMatternot supported{}
docOptions.index--indexfalse
docOptions.sectionHeaderId--noSectionIdtrue
docusaurus.config.js
plugins: [
[
"@graphql-markdown/docusaurus",
/** @type {import('@graphql-markdown/types').ConfigOptions} */
{
schema: "./schema/swapi.graphql",
rootPath: "./docs",
baseURL: "swapi",
homepage: "./docs/swapi.md",
docOptions: {
frontMatter: {
pagination_next: null, // disable page navigation next
pagination_prev: null, // disable page navigation previous
hide_table_of_contents: true, // disable page table of content
},
index: true, // enable generated index pages, same as CLI flag --index
categorySort: "natural", // sort categories alphabetically and prefix with order numbers (01-objects, 02-queries, etc.)
sectionHeaderId: false, // disable custom section header IDs (restores previous behavior)
},
loaders: {
GraphQLFileLoader: "@graphql-tools/graphql-file-loader" // local file schema
},
},
],
],

Compatibility between options​

The categorySort option works seamlessly with:

  • hierarchy option: Works with all hierarchy types (api, entity, flat)
  • groupByDirective option: When using custom groups, categories are sorted based on group names and prefixed accordingly
  • deprecated option: Deprecated categories are sorted along with other categories

Example with groupByDirective:

docOptions: {
categorySort: "natural", // Sort groups alphabetically and prefix with order numbers
},
groupByDirective: {
directive: "doc",
field: "category",
fallback: "Common",
}

This generates folder names like: 01-common, 02-internal, 03-public

printTypeOptions​

Use these options to toggle the type of information rendered on pages:

  • deprecated: option for displaying deprecated entities (fields, values, operations).
    • default: deprecated entities are displayed with other entities.
    • group: deprecated entities are grouped.
    • skip: deprecated entities are not displayed (same as skipDocDirective).
  • exampleSection: configure example rendering based on directive data (see Examples).
  • hierarchy: option for type folder structure:
    • api: folder structure by operations (Operations group) and types Types group based on GraphQL entity types.
    • entity: folder structure by GraphQL entity types (eg. queries, mutations, scalars, objects...).
    • flat: no folder structure (override groupByDirective). Filenames are prefixed with the entity kind to keep them unique, e.g. objects-user.mdx and queries-user.mdx (since 1.38.0).
    • Namespaced operations are supported by default and generated as nested operation paths (See Namespaced Operations).
  • parentTypePrefix: prefix field names with the parent type name.
  • typeBadges: add field type attributes badges.
SettingCLI flagDefault
printTypeOptions.deprecated--deprecated <option>default
printTypeOptions.exampleSectionn/a—
printTypeOptions.hierarchy--hierarchyapi
printTypeOptions.parentTypePrefix--noParentTypetrue
printTypeOptions.typeBadges--noTypeBadgestrue

Use beforeComposePageTypeHook to control section visibility and order. To customize the rendering of printTypeOptions.deprecated: "group", see customize deprecated sections.

danger

Declaring a different option type in the CLI flag hierarchy and the config file hierarchy will generate an error.

docusaurus.config.js
plugins: [
[
"@graphql-markdown/docusaurus",
/** @type {import('@graphql-markdown/types').ConfigOptions} */
{
schema: "./schema/swapi.graphql",
rootPath: "./docs",
baseURL: "swapi",
homepage: "./docs/swapi.md",
printTypeOptions: {
deprecated: "group", // group deprecated entities, same as CLI flag --deprecated group
exampleSection: {
field: "example", // use directive field for example rendering
},
hierarchy: "entity", // disable type API grouping, same as CLI flag --hierarchy entity
parentTypePrefix: false, // disable parent prefix, same as CLI flag --noParentType
typeBadges: false, // disable type attribute badges, same as CLI flag --noTypeBadges
},
formatter: require.resolve("./custom-mdx.cjs"), // use hook-based section composition
loaders: {
GraphQLFileLoader: "@graphql-tools/graphql-file-loader" // local file schema
}
},
],
],
custom-mdx.cjs
const DocusaurusMDX = require("@graphql-markdown/docusaurus/mdx");

const beforeComposePageTypeHook = async (event) => {
// Hide code and relations sections
event.output = event.output.filter(
(key) => key !== "code" && key !== "relations",
);
};

module.exports = {
...DocusaurusMDX,
beforeComposePageTypeHook,
};

Custom group names​

The api option for hierarchy can use customized group names (defaults are operations and types). Pass an object instead of api, using the group name as key for the new name:

docusaurus.config.js
plugins: [
[
"@graphql-markdown/docusaurus",
/** @type {import('@graphql-markdown/types').ConfigOptions} */
{
printTypeOptions: {
hierarchy: { // no customization 'hierarchy: "api"' (default)
api: { // enable useApiGroup with custom groups name
operations: "api", // rename the group 'operations' to 'api'
//group 'types' left unchanged
}
}
},
},
],
],

groupByDirective​

Use a GraphQL directive for creating documentation categories (see documentation categories).

SettingCLI flagDefault
groupByDirective--groupByDirective <@directive(field|=fallback)>undefined

homepage​

The location of the landing page to be used for the documentation, relative to the current workspace (see custom homepage). The file will be copied to the root folder of the generated documentation.

The plugin provides a default page in assets/generated.

SettingCLI flagDefault
homepage-h, --homepage <homepage>generated.md

Set homepage: false to disable the homepage generation. The GraphQL-Markdown template for Docusaurus provides a customized homepage located at static/index.md.

id​

The identifier of the configuration instance. It is used for supporting additional schemas: each instance gets its own command graphql-to-doc:<id>, and it maps to the GraphQL Config project of the same name.

SettingCLI flagDefault
idnot supporteddefault

Content filtering​

Which types and directives end up in the documentation.

onlyDocDirective​

The schema directive/s is used for selecting types to be rendered in the documentation.

The CLI flag supports multiple values separated by a space character, eg --only @stable @beta.

SettingCLI flagDefault
onlyDocDirective--only <@directive...>[]

It only applies to types with a location compatible with the directive, i.e. if the onlyDocDirective cannot be applied to a type (e.g. ENUM), then the type will be displayed. See also skipDocDirective.

skipDocDirective​

The schema directive/s is used for skipping types from documentation.

The CLI flag supports multiple values separated by a space character, eg --skip @noDoc @deprecated.

SettingCLI flagDefault
skipDocDirective--skip <@directive...>[]

Types with @deprecated directive can also be skipped using the setting printTypeOptions.deprecated: "skip" or the flag --deprecated skip. See also onlyDocDirective.

danger

Declaring the same type in both onlyDocDirective and skipDocDirective will generate an error.

customDirective​

caution

Deprecated in favor of decorators, which supersedes it. See migrating from customDirective.

Use this option to render directive information for types (see custom directive).

SettingCLI flagDefault
customDirectivenot supportedundefined

decorators​

Select any node in the schema with a predicate and render a custom section, badge, or description text for it (see decorators). Supersedes customDirective.

SettingCLI flagDefault
decoratorsnot supportedundefined

Rendering​

How pages are formatted, written and decorated.

formatter​

Provide a custom module for formatting output content. You can also use built-in formatter presets from @graphql-markdown/formatters. @graphql-markdown/docusaurus comes with @graphql-markdown/formatters/docusaurus by default.

SettingCLI flagDefault
formatter--formatterundefined

The mdxParser setting and --mdxParser CLI flag are deprecated aliases for formatter / --formatter. They still work but emit a deprecation warning, so migrate to formatter.

caution

The --formatter and --mdxParser CLI flags are only registered when the CLI is set up with a default formatter package, which is what @graphql-markdown/docusaurus does. The standalone gqlmd command does not expose them, so set formatter in your configuration file instead.

The custom module can export individual formatter functions:

ExportTypeDescription
formatMDXBadge(badge: { text, classname? }) => stringFormat type badges
formatMDXAdmonition(admonition, meta?) => stringFormat callout/warning blocks
formatMDXBullet(text?: string) => stringFormat bullet point separators
formatMDXDetails(option) => stringFormat collapsible sections
formatMDXFrontmatter(props?, formatted?, context?) => stringFormat page frontmatter
formatMDXLink(link) => { text, url }Transform type links
formatMDXNameEntity(name, parentType?) => stringFormat named entity references
formatMDXPermalink(id) => stringFormat section header permalinks
formatMDXSpecifiedByLink(url) => stringFormat scalar specification links. Receives an absolute http(s) URL; encode it for where you write it (for example as an HTML attribute)
formatMDXTitle(title) => stringOptional visible page title, printed after the frontmatter

For detailed examples on formatter functions, see Other frameworks.

Additionally, the module can export:

ExportTypeDescription
mdxDeclarationstringImport statements prepended to generated files
mdxExtensionstringCustom file extension (defaults to .mdx)

The custom module can also export lifecycle hooks for customizing the generation process, see Hooks Recipes.

docusaurus.config.js
plugins: [
[
"@graphql-markdown/docusaurus",
/** @type {import('@graphql-markdown/types').ConfigOptions} */
{
schema: "./schema/swapi.graphql",
rootPath: "./docs",
baseURL: "swapi",
homepage: "./docs/swapi.md",
formatter: "./lib/custom-mdx.cjs",
loaders: {
GraphQLFileLoader: "@graphql-tools/graphql-file-loader" // local file schema
}
},
],
],

outputAdapter​

The destination for generated documentation. By default pages are written to the local filesystem under rootPath/baseURL. Set an adapter to send them somewhere else instead — a CMS storage API, an object store, an in-memory map — without forking the renderer.

SettingCLI flagDefault
outputAdapternonelocal filesystem

An adapter must provide writeFile and readFile, and may provide ensureDir:

interface OutputAdapter {
writeFile: (filePath: string, content: string) => Promise<void>;
readFile: (filePath: string) => Promise<string | undefined>;
ensureDir?: (
dirPath: string,
options?: { forceEmpty?: boolean },
) => Promise<void>;
}

See Output adapter for the full contract and worked examples:

metatags​

Set page metadata in <html>, <head> using Docusaurus head metadata.

Meta tags are provided as a list of metadata objects, eg [{ name: "robots", content: "noindex" }] for <meta name="robots" content="noindex" />.

SettingCLI flagDefault
metatagsnot supported[]
docusaurus.config.js
plugins: [
[
"@graphql-markdown/docusaurus",
/** @type {import('@graphql-markdown/types').ConfigOptions} */
{
schema: "./schema/swapi.graphql",
rootPath: "./docs",
baseURL: "swapi",
homepage: "./docs/swapi.md",
metatags: [
{ name: "robots", content: "noindex" }, // <meta name="robots" content="noindex" />
{ charset: "utf-8" }, // <meta charset="utf-8" />
],
loaders: {
GraphQLFileLoader: "@graphql-tools/graphql-file-loader" // local file schema
}
},
],
],

pretty​

Use prettier to format generated files. The prettier package has to be installed separately. If the package is not present locally, then the formatting will always be skipped.

SettingCLI flagDefault
pretty--prettyfalse

Run behavior​

How and when generation runs.

force​

Force generating documentation in an empty folder and set diffMethod to FORCE. If the folder located at rootPath/baseURL is not empty, then the plugin will delete the folder recursively and recreate it.

SettingCLI flagDefault
force-f, --forcefalse

diffMethod​

The method to be used for identifying changes in the schema for triggering the documentation generation.

The possible values are:

  • FORCE: skip diff, always generate documentation, also triggered by force setting.
  • NONE: skip diff (same as FORCE).
  • SCHEMA-DIFF: use GraphQL Inspector to identify changes in the schema (including description).
  • SCHEMA-HASH: use the schema SHA-256 hash for identifying changes in the schema (this method is sensitive to white spaces and invisible characters).
SettingCLI flagDefault
diffMethod-d, --diff <diffMethod>NONE

The package @graphql-markdown/diff is required for using diffMethod. If the package is missing, then the change detection is always skipped.

npm install @graphql-markdown/diff

tmpDir​

The folder used for storing schema copy and signature is used by diffMethod setting.

SettingCLI flagDefault
tmpDir-t, --tmp <tmpDir>OS temp folder

telemetry​

Enables or disables anonymous usage telemetry. Set it to false to opt out; true only enables telemetry for programmatic use of @graphql-markdown/core, and never overrides DO_NOT_TRACK, GRAPHQL_MARKDOWN_TELEMETRY_DISABLED or gqlmd telemetry disable.

SettingCLI flagDefault
telemetry--no-telemetryon

--config​

Print the resolved configuration used for generating documentation. This CLI flag is used for debugging purposes.

SettingCLI flagDefault
--confignull

Example:

npx docusaurus graphql-to-doc --config