import { type GraphQLField } from "graphql"; import type { MarkdownConverterOptions } from "../types"; import { pushArguments } from "./pushArguments"; import { escapeSpecialCharacters, parseMarkdown } from "./parseMarkdown"; export function pushFields( lines: string[], fields: GraphQLField[], options: MarkdownConverterOptions ): void { lines.push( `

Fields

`, `\n\n` ); lines.push(``, `\n`); lines.push(``, `\n`); lines.push(``, `\n`); fields.forEach((field) => { lines.push(``, `\n`); const typeUrl = options.getTypePath(field.type); lines.push( ``, `\n` ); lines.push(``, `\n`); lines.push(``, `\n`); }); lines.push(``, `\n`); lines.push(`
NameDescription
`, `\n`, `${field.name}`, `
\n`, typeUrl ? `${field.type.toJSON()}` : `${field.type.toJSON()}`, `\n`, `
`, `\n`); if (field.deprecationReason) { lines.push( `
Deprecated: ${escapeSpecialCharacters( field.deprecationReason )}
`, `\n\n` ); } lines.push(parseMarkdown(field.description || ""), `\n`); if (field.args.length > 0) { lines.push(`\n`); pushArguments(lines, field.args, options); } lines.push(`
`, `\n\n`); }