Skip to main content

graphql-config

GraphQL Markdown configuration utilities

This module provides utilities for loading and processing GraphQL configuration using the graphql-config package.

EXTENSION_NAME​

const EXTENSION_NAME: "graphql-markdown";

Defined in: graphql-config.ts:25

The name of the GraphQL Markdown extension. Used to identify the extension in graphql-config.


graphQLConfigExtension​

const graphQLConfigExtension: GraphQLExtensionDeclaration;

Defined in: graphql-config.ts:40

GraphQL extension declaration for graphql-config.

Returns​

The extension configuration object with name property.

Example​

// In graphql-config setup
const config = await loadConfig({
extensions: [graphQLConfigExtension],
});

loadConfiguration()​

function loadConfiguration(
id,
options?,
throwOptions?): Promise<Maybe<Readonly<ExtensionProjectConfig>>>

Defined in: graphql-config.ts:127

Loads the GraphQL Markdown configuration from graphql-config.

This function attempts to load the GraphQL config and extract the GraphQL Markdown extension configuration for the specified project ID. It also normalizes schema configurations.

Parameters​

id​

Maybe<string>

The project ID to load configuration for.

options?​

Maybe<PackageOptionsConfig>

Optional package options to apply.

throwOptions?​

ThrowOptions = ...

Options for controlling throw behavior.

Returns​

Promise<Maybe<Readonly<ExtensionProjectConfig>>>

The extension project configuration if found, otherwise undefined.

Throws​

Will throw an error if throwOnMissing or throwOnEmpty is true and the corresponding condition is met.

Example​

// Basic usage
const config = await loadConfiguration("my-project");

// With options and throw behavior
const config = await loadConfiguration(
"my-project",
{ baseDir: "./src" },
{ throwOnMissing: true, throwOnEmpty: false }
);

setLoaderOptions()​

function setLoaderOptions(loaders, options): LoaderOption

Defined in: graphql-config.ts:79

Sets loader options for GraphQL Markdown loaders.

This function takes a LoaderOption object and merges the provided options with any existing options for each loader.

Parameters​

loaders​

LoaderOption

The loader configuration object.

options​

PackageOptionsConfig

The package options to apply to loaders.

Returns​

LoaderOption

The updated loader configuration.

Example​

const loaders = {
TypeScriptLoader: {
module: "@graphql-markdown/typescript-loader",
options: { baseDir: "./src" }
}
};
const options = { outputDir: "./docs" };
const updatedLoaders = setLoaderOptions(loaders, options);
// Result: loaders with { baseDir: "./src", outputDir: "./docs" }