tag
Custom directive tag
helper.
Seeβ
Option customDirective.[directive].tag
directiveTag()β
function directiveTag(
directive,
type?,
classname?): Badge
Helper for rendering custom description from schema directive on type.
This is an example on how to build a custom tag
callback.
Parametersβ
β’ directive: GraphQLDirective
the schema directive to parse.
β’ type?: unknown
the type being processed.
β’ classname?: string
= "badge--secondary"
optional CSS classname, "badge--secondary"
by default.
Returnsβ
Badge
a custom description based on directive value.
Exampleβ
import { GraphQLDirective, GraphQLScalarType } from "graphql";
import { directiveTag } from "@graphql-markdown/helpers/directives/tag";
const directive = new GraphQLDirective({
name: "auth",
description: "Authentication required",
locations: [],
});
const type = new GraphQLScalarType<string>({
name: "FooBar",
astNode: {
kind: Kind.SCALAR_TYPE_DEFINITION,
name: { kind: Kind.NAME, value: "FooBar" },
directives: [
{
kind: Kind.DIRECTIVE,
name: { kind: Kind.NAME, value: "auth" },
},
],
},
});
directiveTag(directive, type);
// Expected result: { text: "@auth", classname: "badge--secondary" }
Defined inβ
directives/tag.ts:51