@graphql-markdown/printer-legacy 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code.js +2 -2
- package/dist/common.d.ts +3 -4
- package/dist/common.js +14 -32
- package/dist/const/options.d.ts +1 -1
- package/dist/example.d.ts +1 -1
- package/dist/example.js +41 -23
- package/dist/frontmatter.js +2 -1
- package/dist/graphql/enum.js +2 -2
- package/dist/link.d.ts +2 -1
- package/dist/link.js +22 -4
- package/dist/printer.d.ts +4 -3
- package/dist/printer.js +4 -2
- package/dist/section.js +1 -1
- package/package.json +5 -6
package/dist/code.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printCodeField = exports.printCodeArguments = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const strings_1 = require("./const/strings");
|
|
6
|
-
const
|
|
6
|
+
const link_1 = require("./link");
|
|
7
7
|
const printCodeArguments = (type, indentationLevel = 1) => {
|
|
8
8
|
if (typeof type !== "object" ||
|
|
9
9
|
type === null ||
|
|
@@ -33,7 +33,7 @@ const printCodeField = (type, options, indentationLevel = 0) => {
|
|
|
33
33
|
if (typeof type !== "object" || type === null || !("type" in type)) {
|
|
34
34
|
return "";
|
|
35
35
|
}
|
|
36
|
-
if (!(0,
|
|
36
|
+
if (!(0, link_1.hasPrintableDirective)(type, options)) {
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
39
|
let code = `${(0, graphql_1.getTypeName)(type)}`;
|
package/dist/common.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Maybe, MDXString, PrintTypeOptions } from "@graphql-markdown/types";
|
|
2
2
|
export declare const printCustomDirectives: (type: unknown, options?: PrintTypeOptions) => string;
|
|
3
3
|
export declare const formatDescription: (type: unknown, replacement?: Maybe<string>) => MDXString | string;
|
|
4
|
-
export declare const printWarning: (text?: string, title?: string) => string;
|
|
5
|
-
export declare const printDeprecation: (type: unknown) => string;
|
|
4
|
+
export declare const printWarning: (text?: string, title?: string, options?: PrintTypeOptions) => string;
|
|
5
|
+
export declare const printDeprecation: (type: unknown, options?: PrintTypeOptions) => string;
|
|
6
6
|
export declare const printDescription: (type: unknown, options?: PrintTypeOptions, noText?: string) => MDXString | string;
|
|
7
|
-
export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
|
package/dist/common.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const utils_1 = require("@
|
|
5
|
-
const utils_2 = require("@graphql-markdown/utils");
|
|
3
|
+
exports.printDescription = exports.printDeprecation = exports.printWarning = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
4
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
6
5
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
7
6
|
const directive_1 = require("./directive");
|
|
8
7
|
const strings_1 = require("./const/strings");
|
|
9
8
|
const printCustomDirectives = (type, options) => {
|
|
10
9
|
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
|
|
11
|
-
if ((0,
|
|
10
|
+
if ((0, utils_1.isEmpty)(constDirectiveMap)) {
|
|
12
11
|
return "";
|
|
13
12
|
}
|
|
14
13
|
const content = Object.values(constDirectiveMap)
|
|
@@ -19,7 +18,7 @@ const printCustomDirectives = (type, options) => {
|
|
|
19
18
|
return typeof text === "string" && text.length > 0;
|
|
20
19
|
})
|
|
21
20
|
.map((text) => {
|
|
22
|
-
return (0,
|
|
21
|
+
return (0, utils_1.escapeMDX)(text);
|
|
23
22
|
})
|
|
24
23
|
.join(strings_1.MARKDOWN_EOP);
|
|
25
24
|
return `${strings_1.MARKDOWN_EOP}${content}`;
|
|
@@ -27,57 +26,40 @@ const printCustomDirectives = (type, options) => {
|
|
|
27
26
|
exports.printCustomDirectives = printCustomDirectives;
|
|
28
27
|
const formatDescription = (type, replacement = strings_1.NO_DESCRIPTION_TEXT) => {
|
|
29
28
|
if (typeof type !== "object" || type === null) {
|
|
30
|
-
return `${strings_1.MARKDOWN_EOP}${(0,
|
|
29
|
+
return `${strings_1.MARKDOWN_EOP}${(0, utils_1.escapeMDX)(replacement)}`;
|
|
31
30
|
}
|
|
32
31
|
const description = "description" in type && typeof type.description === "string"
|
|
33
32
|
? type.description
|
|
34
33
|
: replacement;
|
|
35
|
-
return `${strings_1.MARKDOWN_EOP}${(0,
|
|
34
|
+
return `${strings_1.MARKDOWN_EOP}${(0, utils_1.escapeMDX)(description)}`;
|
|
36
35
|
};
|
|
37
36
|
exports.formatDescription = formatDescription;
|
|
38
|
-
const printWarning = (text, title) => {
|
|
37
|
+
const printWarning = (text, title, options) => {
|
|
39
38
|
const formattedText = typeof text !== "string" || text.trim() === ""
|
|
40
39
|
? strings_1.MARKDOWN_EOP
|
|
41
40
|
: `${strings_1.MARKDOWN_EOP}${text}${strings_1.MARKDOWN_EOP}`;
|
|
42
|
-
|
|
41
|
+
const isDocusaurus = options?.meta?.generatorFrameworkName === "docusaurus";
|
|
42
|
+
if (isDocusaurus &&
|
|
43
|
+
options.meta?.generatorFrameworkVersion?.startsWith("2")) {
|
|
43
44
|
return `${strings_1.MARKDOWN_EOP}:::caution ${title}${formattedText}:::`;
|
|
44
45
|
}
|
|
45
46
|
return `${strings_1.MARKDOWN_EOP}:::warning[${title}]${formattedText}:::`;
|
|
46
47
|
};
|
|
47
48
|
exports.printWarning = printWarning;
|
|
48
|
-
const printDeprecation = (type) => {
|
|
49
|
+
const printDeprecation = (type, options) => {
|
|
49
50
|
if (typeof type !== "object" || type === null || !(0, graphql_1.isDeprecated)(type)) {
|
|
50
51
|
return "";
|
|
51
52
|
}
|
|
52
53
|
const reason = "deprecationReason" in type && typeof type.deprecationReason === "string"
|
|
53
|
-
? (0,
|
|
54
|
+
? (0, utils_1.escapeMDX)(type.deprecationReason)
|
|
54
55
|
: "";
|
|
55
|
-
return (0, exports.printWarning)(reason, strings_1.DEPRECATED.toUpperCase());
|
|
56
|
+
return (0, exports.printWarning)(reason, strings_1.DEPRECATED.toUpperCase(), options);
|
|
56
57
|
};
|
|
57
58
|
exports.printDeprecation = printDeprecation;
|
|
58
59
|
const printDescription = (type, options, noText) => {
|
|
59
60
|
const description = (0, exports.formatDescription)(type, noText);
|
|
60
61
|
const customDirectives = (0, exports.printCustomDirectives)(type, options);
|
|
61
|
-
const deprecation = (0, exports.printDeprecation)(type);
|
|
62
|
+
const deprecation = (0, exports.printDeprecation)(type, options);
|
|
62
63
|
return `${deprecation}${description}${customDirectives}`;
|
|
63
64
|
};
|
|
64
65
|
exports.printDescription = printDescription;
|
|
65
|
-
const hasPrintableDirective = (type, options) => {
|
|
66
|
-
if (!type) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
if (!options) {
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
const skipDirective = "skipDocDirectives" in options && options.skipDocDirectives
|
|
73
|
-
? (0, graphql_1.hasDirective)(type, options.skipDocDirectives)
|
|
74
|
-
: false;
|
|
75
|
-
const skipDeprecated = "deprecated" in options &&
|
|
76
|
-
options.deprecated === "skip" &&
|
|
77
|
-
(0, graphql_1.isDeprecated)(type);
|
|
78
|
-
const onlyDirective = "onlyDocDirectives" in options && options.onlyDocDirectives
|
|
79
|
-
? (0, graphql_1.hasDirective)(type, options.onlyDocDirectives, true)
|
|
80
|
-
: true;
|
|
81
|
-
return !(skipDirective || skipDeprecated) && onlyDirective;
|
|
82
|
-
};
|
|
83
|
-
exports.hasPrintableDirective = hasPrintableDirective;
|
package/dist/const/options.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare enum SectionLevels {
|
|
|
11
11
|
LEVEL_5 = "#####"
|
|
12
12
|
}
|
|
13
13
|
export declare const PRINT_TYPE_DEFAULT_OPTIONS: Required<PrinterConfigPrintTypeOptions>;
|
|
14
|
-
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
14
|
+
export declare const DEFAULT_OPTIONS: Required<Omit<PrintTypeOptions, "collapsible" | "groups" | "level" | "meta" | "onlyDocDirectives" | "parentType" | "schema" | "skipDocDirectives">> & {
|
|
15
15
|
collapsible: Maybe<CollapsibleOption>;
|
|
16
16
|
groups: Maybe<SchemaEntitiesGroupMap>;
|
|
17
17
|
level: Maybe<SectionLevelValue>;
|
package/dist/example.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Maybe, PrintTypeOptions, TypeDirectiveExample } from "@graphql-markdown/types";
|
|
2
|
-
export declare const getDirectiveExampleOption: (
|
|
2
|
+
export declare const getDirectiveExampleOption: ({ exampleSection, schema, }: PrintTypeOptions) => Maybe<TypeDirectiveExample>;
|
|
3
3
|
export declare const printExample: (type: unknown, options: PrintTypeOptions) => Maybe<string>;
|
package/dist/example.js
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printExample = exports.getDirectiveExampleOption = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
6
|
+
const link_1 = require("./link");
|
|
7
|
+
const getDirectiveExampleOption = ({ exampleSection, schema, }) => {
|
|
7
8
|
let directiveName = "example", argName = "value", parserFunc = undefined;
|
|
8
|
-
if (
|
|
9
|
-
if ("directive" in
|
|
10
|
-
|
|
11
|
-
directiveName = options.exampleSection.directive;
|
|
9
|
+
if (exampleSection && typeof exampleSection === "object") {
|
|
10
|
+
if ("directive" in exampleSection && exampleSection.directive) {
|
|
11
|
+
directiveName = exampleSection.directive;
|
|
12
12
|
}
|
|
13
|
-
if ("field" in
|
|
14
|
-
argName =
|
|
13
|
+
if ("field" in exampleSection && exampleSection.field) {
|
|
14
|
+
argName = exampleSection.field;
|
|
15
15
|
}
|
|
16
|
-
if ("parser" in
|
|
17
|
-
parserFunc =
|
|
16
|
+
if ("parser" in exampleSection && exampleSection.parser) {
|
|
17
|
+
parserFunc = exampleSection.parser;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
const directive =
|
|
21
|
-
?
|
|
20
|
+
const directive = schema && (0, graphql_1.instanceOf)(schema, graphql_1.GraphQLSchema)
|
|
21
|
+
? schema.getDirective(directiveName)
|
|
22
22
|
: undefined;
|
|
23
23
|
if (!directive) {
|
|
24
24
|
return undefined;
|
|
@@ -30,7 +30,7 @@ const getDirectiveExampleOption = (options) => {
|
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
32
|
exports.getDirectiveExampleOption = getDirectiveExampleOption;
|
|
33
|
-
const parseTypeFields = (type, options) => {
|
|
33
|
+
const parseTypeFields = (type, options, mappedTypes = []) => {
|
|
34
34
|
const directiveExample = (0, exports.getDirectiveExampleOption)(options);
|
|
35
35
|
if (!directiveExample) {
|
|
36
36
|
return undefined;
|
|
@@ -42,19 +42,26 @@ const parseTypeFields = (type, options) => {
|
|
|
42
42
|
let example = {};
|
|
43
43
|
fields
|
|
44
44
|
.filter((field) => {
|
|
45
|
-
return (0,
|
|
45
|
+
return (0, link_1.hasPrintableDirective)(field, options);
|
|
46
46
|
})
|
|
47
47
|
.forEach((field) => {
|
|
48
48
|
const fieldType = (0, graphql_1.hasDirective)(field, [directiveExample.directive])
|
|
49
49
|
? field
|
|
50
50
|
: field.type;
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
52
|
-
const value = parseExampleDirective(fieldType, options);
|
|
52
|
+
const value = parseExampleDirective(fieldType, options, mappedTypes);
|
|
53
|
+
let structuredValue = value;
|
|
54
|
+
if ((0, graphql_1.isListType)((0, graphql_1.getNullableType)(fieldType))) {
|
|
55
|
+
if (!value && (0, graphql_1.isNonNullType)(fieldType)) {
|
|
56
|
+
structuredValue = [];
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
structuredValue = value ? [value] : undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
53
62
|
example = {
|
|
54
63
|
...example,
|
|
55
|
-
[field.name]:
|
|
56
|
-
? [value]
|
|
57
|
-
: value,
|
|
64
|
+
[field.name]: structuredValue,
|
|
58
65
|
};
|
|
59
66
|
});
|
|
60
67
|
return example;
|
|
@@ -78,27 +85,38 @@ const parseExampleValue = (value, type) => {
|
|
|
78
85
|
}
|
|
79
86
|
return value;
|
|
80
87
|
};
|
|
81
|
-
const parseExampleDirective = (type, options) => {
|
|
88
|
+
const parseExampleDirective = (type, options, mappedTypes = []) => {
|
|
82
89
|
const directiveExample = (0, exports.getDirectiveExampleOption)(options);
|
|
83
|
-
if (!directiveExample || !(0,
|
|
90
|
+
if (!directiveExample || !(0, link_1.hasPrintableDirective)(type, options)) {
|
|
84
91
|
return undefined;
|
|
85
92
|
}
|
|
86
93
|
const parser = typeof directiveExample.parser === "function"
|
|
87
94
|
? directiveExample.parser
|
|
88
95
|
: parseExampleValue;
|
|
96
|
+
// get parent type
|
|
89
97
|
const namedType = (0, graphql_1.isType)(type) ? (0, graphql_1.getNamedType)(type) : type;
|
|
90
98
|
if (!namedType) {
|
|
91
99
|
return undefined;
|
|
92
100
|
}
|
|
101
|
+
// get type name
|
|
102
|
+
const typename = (0, graphql_1.isType)(namedType)
|
|
103
|
+
? (0, utils_1.toString)(namedType)
|
|
104
|
+
: (0, utils_1.toString)(namedType.name);
|
|
105
|
+
// recursion check
|
|
106
|
+
if (mappedTypes.includes(typename)) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
mappedTypes.push(typename);
|
|
93
110
|
try {
|
|
94
111
|
const arg = (0, graphql_1.getTypeDirectiveArgValue)(directiveExample.directive, namedType, directiveExample.field);
|
|
95
112
|
return parser(arg, namedType);
|
|
96
113
|
}
|
|
97
114
|
catch (err) {
|
|
98
115
|
if (err instanceof graphql_1.IntrospectionError) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
if (!(0, graphql_1.isType)(namedType)) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return parseTypeFields(namedType, options, mappedTypes);
|
|
102
120
|
}
|
|
103
121
|
throw err;
|
|
104
122
|
}
|
package/dist/frontmatter.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.printFrontMatter = exports.formatFrontMatterProp = void 0;
|
|
4
|
+
const utils_1 = require("@graphql-markdown/utils");
|
|
4
5
|
const strings_1 = require("./const/strings");
|
|
5
6
|
const tabs = (indentation = 0) => {
|
|
6
7
|
return strings_1.MARKDOWN_CODE_INDENTATION.repeat(indentation);
|
|
@@ -30,7 +31,7 @@ const formatFrontMatterList = (prop, indentation = 0, prefix = "- ") => {
|
|
|
30
31
|
}));
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
frontMatter.push(`${tabs(indentation)}- ${entry}`);
|
|
34
|
+
frontMatter.push(`${tabs(indentation)}- ${(0, utils_1.toString)(entry)}`);
|
|
34
35
|
}
|
|
35
36
|
});
|
|
36
37
|
return frontMatter;
|
package/dist/graphql/enum.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.printCodeEnum = exports.printEnumMetadata = void 0;
|
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const strings_1 = require("../const/strings");
|
|
6
6
|
const section_1 = require("../section");
|
|
7
|
-
const
|
|
7
|
+
const link_1 = require("../link");
|
|
8
8
|
const printEnumMetadata = (type, options) => {
|
|
9
9
|
if (!(0, graphql_1.isEnumType)(type)) {
|
|
10
10
|
return "";
|
|
@@ -20,7 +20,7 @@ const printCodeEnum = (type, options) => {
|
|
|
20
20
|
code += type
|
|
21
21
|
.getValues()
|
|
22
22
|
.map((value) => {
|
|
23
|
-
if (!(0,
|
|
23
|
+
if (!(0, link_1.hasPrintableDirective)(value, options)) {
|
|
24
24
|
return "";
|
|
25
25
|
}
|
|
26
26
|
const v = (0, graphql_1.getTypeName)(value);
|
package/dist/link.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
|
|
1
|
+
import type { ApiGroupOverrideType, MDXString, Maybe, PrintLinkOptions, PrintTypeOptions, TypeDeprecatedOption, TypeLink, TypeLocale } from "@graphql-markdown/types";
|
|
2
2
|
export declare const API_GROUPS: Required<ApiGroupOverrideType>;
|
|
3
|
+
export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
|
|
3
4
|
export declare const getCategoryLocale: (type: unknown) => Maybe<TypeLocale>;
|
|
4
5
|
export declare const getLinkCategoryFolder: (type: unknown, operationLocale?: Maybe<TypeLocale>) => Maybe<string>;
|
|
5
6
|
export declare const hasOptionWithAttributes: (options: PrintLinkOptions) => boolean;
|
package/dist/link.js
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.getLinkDeprecatedFolder = exports.getLinkApiGroupFolder = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategoryFolder = exports.getCategoryLocale = exports.API_GROUPS = void 0;
|
|
3
|
+
exports.printParentLink = exports.printLink = exports.printLinkAttributes = exports.getRelationLink = exports.toLink = exports.getLinkDeprecatedFolder = exports.getLinkApiGroupFolder = exports.hasOptionParentType = exports.hasOptionWithAttributes = exports.getLinkCategoryFolder = exports.getCategoryLocale = exports.hasPrintableDirective = exports.API_GROUPS = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const utils_1 = require("@graphql-markdown/utils");
|
|
6
6
|
const group_1 = require("./group");
|
|
7
7
|
const strings_1 = require("./const/strings");
|
|
8
|
-
const common_1 = require("./common");
|
|
9
8
|
const options_1 = require("./const/options");
|
|
10
9
|
exports.API_GROUPS = {
|
|
11
10
|
operations: "operations",
|
|
12
11
|
types: "types",
|
|
13
12
|
};
|
|
13
|
+
const hasPrintableDirective = (type, options) => {
|
|
14
|
+
if (!type) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (!options) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
const skipDirective = "skipDocDirectives" in options && options.skipDocDirectives
|
|
21
|
+
? (0, graphql_1.hasDirective)(type, options.skipDocDirectives)
|
|
22
|
+
: false;
|
|
23
|
+
const skipDeprecated = "deprecated" in options &&
|
|
24
|
+
options.deprecated === "skip" &&
|
|
25
|
+
(0, graphql_1.isDeprecated)(type);
|
|
26
|
+
const onlyDirective = "onlyDocDirectives" in options && options.onlyDocDirectives
|
|
27
|
+
? (0, graphql_1.hasDirective)(type, options.onlyDocDirectives, true)
|
|
28
|
+
: true;
|
|
29
|
+
return !(skipDirective || skipDeprecated) && onlyDirective;
|
|
30
|
+
};
|
|
31
|
+
exports.hasPrintableDirective = hasPrintableDirective;
|
|
14
32
|
const getCategoryLocale = (type) => {
|
|
15
33
|
switch (true) {
|
|
16
34
|
case (0, graphql_1.isDirectiveType)(type):
|
|
@@ -84,7 +102,7 @@ const toLink = (type, name, operation, options) => {
|
|
|
84
102
|
url: "#",
|
|
85
103
|
};
|
|
86
104
|
if (typeof type !== "object" ||
|
|
87
|
-
(typeof options !== "undefined" && !(0,
|
|
105
|
+
(typeof options !== "undefined" && !(0, exports.hasPrintableDirective)(type, options))) {
|
|
88
106
|
return fallback;
|
|
89
107
|
}
|
|
90
108
|
const graphQLNamedType = (0, graphql_1.getNamedType)(type);
|
|
@@ -150,7 +168,7 @@ const printLink = (type, options) => {
|
|
|
150
168
|
if (typeof type !== "object" || type === null) {
|
|
151
169
|
return "";
|
|
152
170
|
}
|
|
153
|
-
const link = (0, exports.toLink)(type, (0, graphql_1.getTypeName)(type,
|
|
171
|
+
const link = (0, exports.toLink)(type, (0, graphql_1.getTypeName)(type, (0, utils_1.toString)(type)), undefined, options);
|
|
154
172
|
if (typeof options !== "undefined" && !(0, exports.hasOptionWithAttributes)(options)) {
|
|
155
173
|
const textWithAttribute = (0, exports.hasOptionParentType)(options)
|
|
156
174
|
? `<code style={{ fontWeight: 'normal' }}>${options.parentType}.<b>${link.text}</b></code>`
|
package/dist/printer.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, Maybe, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
|
|
1
|
+
import type { CustomDirectiveMap, GraphQLDirective, GraphQLSchema, IPrinter, MDXString, Maybe, MetaOptions, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, TypeDeprecatedOption } from "@graphql-markdown/types";
|
|
2
2
|
export declare class Printer implements IPrinter {
|
|
3
3
|
static options: Readonly<Maybe<PrintTypeOptions>>;
|
|
4
4
|
static readonly printDescription: (type: unknown, options?: PrintTypeOptions, noText?: string) => MDXString | string;
|
|
5
5
|
static readonly printCustomDirectives: (type: unknown, options: PrintTypeOptions) => string;
|
|
6
6
|
static readonly printCustomTags: (type: unknown, options: PrintTypeOptions) => MDXString | string;
|
|
7
|
-
static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, onlyDocDirectives, printTypeOptions, skipDocDirectives,
|
|
7
|
+
static init(schema: Maybe<GraphQLSchema>, baseURL?: Maybe<string>, linkRoot?: Maybe<string>, { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, }?: {
|
|
8
8
|
customDirectives?: CustomDirectiveMap;
|
|
9
9
|
deprecated?: TypeDeprecatedOption;
|
|
10
10
|
groups?: SchemaEntitiesGroupMap;
|
|
11
|
+
meta?: Maybe<MetaOptions>;
|
|
12
|
+
metatags?: Record<string, string>[];
|
|
11
13
|
onlyDocDirectives?: GraphQLDirective[];
|
|
12
14
|
printTypeOptions?: PrinterConfigPrintTypeOptions;
|
|
13
15
|
skipDocDirectives?: GraphQLDirective[];
|
|
14
|
-
metatags?: Record<string, string>[];
|
|
15
16
|
}): void;
|
|
16
17
|
static readonly printHeader: (id: string, title: string, options: PrintTypeOptions) => string;
|
|
17
18
|
static readonly printCode: (type: unknown, options: PrintTypeOptions) => string;
|
package/dist/printer.js
CHANGED
|
@@ -8,6 +8,7 @@ const common_1 = require("./common");
|
|
|
8
8
|
const directive_1 = require("./directive");
|
|
9
9
|
const frontmatter_1 = require("./frontmatter");
|
|
10
10
|
const graphql_2 = require("./graphql");
|
|
11
|
+
const link_1 = require("./link");
|
|
11
12
|
const strings_1 = require("./const/strings");
|
|
12
13
|
const mdx_1 = require("./const/mdx");
|
|
13
14
|
const options_1 = require("./const/options");
|
|
@@ -17,7 +18,7 @@ class Printer {
|
|
|
17
18
|
static printDescription = common_1.printDescription;
|
|
18
19
|
static printCustomDirectives = directive_1.printCustomDirectives;
|
|
19
20
|
static printCustomTags = directive_1.printCustomTags;
|
|
20
|
-
static init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, groups, onlyDocDirectives, printTypeOptions, skipDocDirectives,
|
|
21
|
+
static init(schema, baseURL = "schema", linkRoot = "/", { customDirectives, groups, meta, metatags, onlyDocDirectives, printTypeOptions, skipDocDirectives, } = {
|
|
21
22
|
customDirectives: undefined,
|
|
22
23
|
groups: undefined,
|
|
23
24
|
}) {
|
|
@@ -43,6 +44,7 @@ class Printer {
|
|
|
43
44
|
typeBadges: printTypeOptions?.typeBadges ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.typeBadges,
|
|
44
45
|
metatags: metatags ?? [],
|
|
45
46
|
hierarchy: printTypeOptions?.hierarchy ?? options_1.PRINT_TYPE_DEFAULT_OPTIONS.hierarchy,
|
|
47
|
+
meta: meta,
|
|
46
48
|
};
|
|
47
49
|
}
|
|
48
50
|
static printHeader = (id, title, options) => {
|
|
@@ -143,7 +145,7 @@ class Printer {
|
|
|
143
145
|
...Printer.options,
|
|
144
146
|
...options,
|
|
145
147
|
};
|
|
146
|
-
if (!name || !(0,
|
|
148
|
+
if (!name || !(0, link_1.hasPrintableDirective)(type, printTypeOptions)) {
|
|
147
149
|
return undefined;
|
|
148
150
|
}
|
|
149
151
|
const header = Printer.printHeader(name, (0, graphql_1.getTypeName)(type), printTypeOptions);
|
package/dist/section.js
CHANGED
|
@@ -17,7 +17,7 @@ const printSectionItem = (type, options) => {
|
|
|
17
17
|
const level = "level" in options && typeof options.level === "string"
|
|
18
18
|
? options.level
|
|
19
19
|
: options_1.SectionLevels.LEVEL_4;
|
|
20
|
-
if (!(0,
|
|
20
|
+
if (!(0, link_1.hasPrintableDirective)(type, options)) {
|
|
21
21
|
return "";
|
|
22
22
|
}
|
|
23
23
|
const typeNameLink = (0, link_1.printLink)(type, {
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/graphql-markdown/graphql-markdown/issues"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.
|
|
8
|
+
"version": "1.10.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -56,15 +56,14 @@
|
|
|
56
56
|
"docs": "typedoc"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@graphql-markdown/
|
|
61
|
-
"@graphql-markdown/utils": "^1.7.0"
|
|
59
|
+
"@graphql-markdown/graphql": "^1.1.5",
|
|
60
|
+
"@graphql-markdown/utils": "^1.7.1"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
|
-
"@graphql-markdown/types": "^1.
|
|
63
|
+
"@graphql-markdown/types": "^1.5.0"
|
|
65
64
|
},
|
|
66
65
|
"resolutions": {
|
|
67
|
-
"micromatch": "4.0.
|
|
66
|
+
"micromatch": "4.0.8"
|
|
68
67
|
},
|
|
69
68
|
"directories": {
|
|
70
69
|
"test": "tests"
|