Skip to main content

Upgrade to 1.44

GraphQL-Markdown 1.44 removes two deprecated settings, mdxParser (deprecated in 1.35.0) and customDirective (deprecated in 1.37.0), and stops ignoring settings it does not support. A configuration that ran on 1.43 can fail on 1.44, so check it before you upgrade.

Check your configuration​

Generation now stops with an error when your configuration contains a setting that GraphQL-Markdown does not support. The error names every unsupported setting at once and suggests the closest supported setting for a likely typo:

Error: Unsupported settings "mdxParser", "fromatter" (did you mean "formatter"?). See https://graphql-markdown.dev/docs/reference/settings for the list of supported settings.

Earlier releases silently ignored these settings, so a misspelled option had no effect. Fix or remove each setting the error lists. The settings reference lists every supported setting.

The schema, documents, include and exclude keys that graphql-config adds to a project are still accepted.

Replace mdxParser with formatter​

mdxParser was renamed to formatter in 1.35.0, which kept mdxParser as a deprecated alias until 1.44. The value is the same: a package name or a path to a formatter module.

.graphqlrc.js
module.exports = {
schema: "./schema.graphql",
extensions: {
"graphql-markdown": {
- mdxParser: "@graphql-markdown/formatters/hugo",
+ formatter: "@graphql-markdown/formatters/hugo",
},
},
};

On the command line, replace the --mdxParser flag with --formatter:

- npx docusaurus graphql-to-doc --mdxParser ./custom-formatter.js
+ npx docusaurus graphql-to-doc --formatter ./custom-formatter.js

Replace customDirective with decorators​

decorators replaced customDirective in 1.37.0, which kept customDirective working as a deprecated setting until 1.44. Each customDirective entry becomes one decorator for its descriptor and one for its tag, both selected with hasDirectiveNamed:

- customDirective: {
- auth: {
- descriptor: (directive, node) =>
- directiveDescriptor(directive, node, "Requires the `${requires}` role."),
- },
- },
+ decorators: {
+ authDescription: {
+ predicate: hasDirectiveNamed("auth"),
+ position: { into: "description" },
+ render: withDirective("auth", (directive, options, { type }) =>
+ escapeMDX(directiveDescriptor(directive, type, "Requires the `${requires}` role.")),
+ ),
+ },
+ },

hasDirectiveNamed comes from @graphql-markdown/graphql, withDirective and directiveDescriptor from @graphql-markdown/helpers, and escapeMDX from @graphql-markdown/utils. Migrating from customDirective has the complete example, including tags, and explains what changes.

Removed TypeScript exports​

If you import the customDirective API in your own code, such as a custom formatter or a script, these exports were removed:

PackageRemoved exportsUse instead
@graphql-markdown/typesCustomDirective, CustomDirectiveMap, CustomDirectiveMapItem, CustomDirectiveOptions, CustomDirectiveFunction, CustomDirectiveResolver, PageSections.customDirectivesDecorators, DecoratorDefinition
@graphql-markdown/typesmdxParser in ConfigOptions and CliOptionsformatter
@graphql-markdown/graphqlisCustomDirective, getCustomDirectiveOptions, getCustomDirectives, getConstDirectiveMap, WILDCARD_DIRECTIVEhasDirectiveNamed, getDirectiveFromSchema
@graphql-markdown/printer-legacybuildCustomDirectiveDecoratorsdecorators

The section names customDirectives, customDirective:description and customDirective:tags are no longer reserved, so a decorator can use them as its id.