Skip to main content

relation

This module provides functionality to print relationships between GraphQL types, including return types, member fields, and implementations, in a formatted MDX string output.

getRootTypeLocaleFromString()​

function getRootTypeLocaleFromString(text): Maybe<TypeLocale>

Defined in: relation.ts:40

Converts a string representation of a root type to its corresponding TypeLocale

Parameters​

text​

string

The string to convert to a TypeLocale

Returns​

Maybe<TypeLocale>

The matching TypeLocale if found, undefined otherwise

Example​

const locale = getRootTypeLocaleFromString('Query');

printRelationOf()​

function printRelationOf<T>(
type,
section,
getRelation,
options): string | MDXString

Defined in: relation.ts:65

Prints the relation section for a specific type and relation category

Type Parameters​

T​

T

Type of the relation

Parameters​

type​

unknown

The GraphQL type to get relations for

section​

unknown

The section title for the relation

getRelation​

Maybe<IGetRelation<T>>

Function to retrieve relations of type T

options​

PrintTypeOptions

Printing options for type formatting

Returns​

string | MDXString

Formatted MDX string containing the relations or empty string if no relations found

Throws​

If the schema is not provided in options

Example​

const mdx = printRelationOf(type, "Member Of", getRelationOfField, options);

printRelations()​

function printRelations(type, options): string | MDXString

Defined in: relation.ts:134

Prints all relations (return types, member fields, and implementations) for a given type

Parameters​

type​

unknown

The GraphQL type to get all relations for

options​

PrintTypeOptions

Printing options for type formatting

Returns​

string | MDXString

Formatted MDX string containing all relations or empty string if no relations found

Throws​

If the schema is not provided in options

Example​

const relations = printRelations(myType, { schema, formatMDXBullet: () => "* " });