Skip to main content

Schema loading

GraphQL-Markdown use external loaders for loading GraphQL schemas (see full list).

You can declare as many loaders as you need using a LoaderOption map:

type LoaderOption = {
[name: ClassName]: PackageName | PackageConfig;
};

type PackageName = string & { _opaque: typeof PackageName };

type ClassName = string & { _opaque: typeof ClassName };

type PackageConfig = {
module: PackageName;
options?: PackageOptionsConfig;
};

type RootTypes = { query?: string; mutation?: string; subscription?: string };

type PackageOptionsConfig = BaseLoaderOptions & RootTypes;

Local schema (file)​

Use @graphql-tools/graphql-file-loader if you want to load a local schema:

shell
npm install @graphql-tools/graphql-file-loader

Once done, you can declare the loader in @graphql-markdown/docusaurus configuration:

docusaurus.config.js
plugins: [
[
"@graphql-markdown/docusaurus",
/** @type {import('@graphql-markdown/types').ConfigOptions} */
{
// ... other options
loaders: {
GraphQLFileLoader: "@graphql-tools/graphql-file-loader"
}
},
],
],

Remote schema (url)​

Use @graphql-tools/url-loader, if you want to load a schema from a URL:

shell
npm install @graphql-tools/url-loader

Once done, you can declare the loader in @graphql-markdown/docusaurus configuration:

docusaurus.config.js
plugins: [
[
"@graphql-markdown/docusaurus",
/** @type {import('@graphql-markdown/types').ConfigOptions} */
{
// ... other options
loaders: {
UrlLoader: {
module: "@graphql-tools/url-loader",
options: {
headers: {
Authorization: "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
}
}
}
}
},
],
],