UNPKG

docusaurus-graphql-plugin

Version:

Docusaurus plugin generating Markdown documentation from a GraphQL schema.

25 lines (19 loc) 681 B
import { GraphQLObjectType } from "graphql"; import { MarkdownConverterOptions } from "../types"; import { pushFields } from "./pushFields"; import { pushInterfaces } from "./pushInterfaces"; export function convertObjectToMarkdown( object: GraphQLObjectType, options: MarkdownConverterOptions ): string { const lines: string[] = []; lines.push(`## ${object.name}`, `\n\n`); lines.push(object.description || "", `\n\n`); const interfaces = object.getInterfaces(); if (interfaces.length > 0) { pushInterfaces(lines, interfaces, options); } const fields = Object.values(object.getFields()); pushFields(lines, fields, options); return lines.join(""); }