@graphql-markdown/printer-legacy 1.8.5 → 1.9.1
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 +0 -1
- package/dist/common.js +2 -21
- package/dist/const/options.d.ts +5 -0
- package/dist/const/options.js +8 -2
- package/dist/example.d.ts +1 -1
- package/dist/example.js +43 -28
- package/dist/frontmatter.js +2 -1
- package/dist/graphql/enum.js +2 -2
- package/dist/link.d.ts +4 -2
- package/dist/link.js +56 -15
- package/dist/printer.js +3 -2
- package/dist/section.js +1 -1
- package/package.json +5 -5
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
|
@@ -4,4 +4,3 @@ export declare const formatDescription: (type: unknown, replacement?: Maybe<stri
|
|
|
4
4
|
export declare const printWarning: (text?: string, title?: string) => string;
|
|
5
5
|
export declare const printDeprecation: (type: unknown) => 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,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.printDescription = exports.printDeprecation = exports.printWarning = exports.formatDescription = exports.printCustomDirectives = void 0;
|
|
4
4
|
const utils_1 = require("@docusaurus/utils");
|
|
5
5
|
const utils_2 = require("@graphql-markdown/utils");
|
|
6
6
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
@@ -8,7 +8,7 @@ const directive_1 = require("./directive");
|
|
|
8
8
|
const strings_1 = require("./const/strings");
|
|
9
9
|
const printCustomDirectives = (type, options) => {
|
|
10
10
|
const constDirectiveMap = (0, graphql_1.getConstDirectiveMap)(type, options?.customDirectives);
|
|
11
|
-
if (
|
|
11
|
+
if ((0, utils_2.isEmpty)(constDirectiveMap)) {
|
|
12
12
|
return "";
|
|
13
13
|
}
|
|
14
14
|
const content = Object.values(constDirectiveMap)
|
|
@@ -62,22 +62,3 @@ const printDescription = (type, options, noText) => {
|
|
|
62
62
|
return `${deprecation}${description}${customDirectives}`;
|
|
63
63
|
};
|
|
64
64
|
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
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { CollapsibleOption, GraphQLDirective, GraphQLSchema, Maybe, PrintTypeOptions, PrinterConfigPrintTypeOptions, SchemaEntitiesGroupMap, SectionLevelValue } from "@graphql-markdown/types";
|
|
2
|
+
export declare enum TypeHierarchy {
|
|
3
|
+
API = "api",
|
|
4
|
+
ENTITY = "entity",
|
|
5
|
+
FLAT = "flat"
|
|
6
|
+
}
|
|
2
7
|
export declare enum SectionLevels {
|
|
3
8
|
NONE = "",
|
|
4
9
|
LEVEL_3 = "###",
|
package/dist/const/options.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_OPTIONS = exports.PRINT_TYPE_DEFAULT_OPTIONS = exports.SectionLevels = void 0;
|
|
3
|
+
exports.DEFAULT_OPTIONS = exports.PRINT_TYPE_DEFAULT_OPTIONS = exports.SectionLevels = exports.TypeHierarchy = void 0;
|
|
4
|
+
var TypeHierarchy;
|
|
5
|
+
(function (TypeHierarchy) {
|
|
6
|
+
TypeHierarchy["API"] = "api";
|
|
7
|
+
TypeHierarchy["ENTITY"] = "entity";
|
|
8
|
+
TypeHierarchy["FLAT"] = "flat";
|
|
9
|
+
})(TypeHierarchy || (exports.TypeHierarchy = TypeHierarchy = {}));
|
|
4
10
|
var SectionLevels;
|
|
5
11
|
(function (SectionLevels) {
|
|
6
12
|
SectionLevels["NONE"] = "";
|
|
@@ -16,7 +22,7 @@ exports.PRINT_TYPE_DEFAULT_OPTIONS = {
|
|
|
16
22
|
parentTypePrefix: true,
|
|
17
23
|
relatedTypeSection: true,
|
|
18
24
|
typeBadges: true,
|
|
19
|
-
|
|
25
|
+
hierarchy: { [TypeHierarchy.API]: {} },
|
|
20
26
|
};
|
|
21
27
|
exports.DEFAULT_OPTIONS = {
|
|
22
28
|
...exports.PRINT_TYPE_DEFAULT_OPTIONS,
|
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
|
@@ -3,23 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printExample = exports.getDirectiveExampleOption = void 0;
|
|
4
4
|
const graphql_1 = require("@graphql-markdown/graphql");
|
|
5
5
|
const utils_1 = require("@graphql-markdown/utils");
|
|
6
|
-
const
|
|
7
|
-
const getDirectiveExampleOption = (
|
|
6
|
+
const link_1 = require("./link");
|
|
7
|
+
const getDirectiveExampleOption = ({ exampleSection, schema, }) => {
|
|
8
8
|
let directiveName = "example", argName = "value", parserFunc = undefined;
|
|
9
|
-
if (
|
|
10
|
-
if ("directive" in
|
|
11
|
-
|
|
12
|
-
directiveName = options.exampleSection.directive;
|
|
9
|
+
if (exampleSection && typeof exampleSection === "object") {
|
|
10
|
+
if ("directive" in exampleSection && exampleSection.directive) {
|
|
11
|
+
directiveName = exampleSection.directive;
|
|
13
12
|
}
|
|
14
|
-
if ("field" in
|
|
15
|
-
argName =
|
|
13
|
+
if ("field" in exampleSection && exampleSection.field) {
|
|
14
|
+
argName = exampleSection.field;
|
|
16
15
|
}
|
|
17
|
-
if ("parser" in
|
|
18
|
-
parserFunc =
|
|
16
|
+
if ("parser" in exampleSection && exampleSection.parser) {
|
|
17
|
+
parserFunc = exampleSection.parser;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
|
-
const directive =
|
|
22
|
-
?
|
|
20
|
+
const directive = schema && (0, graphql_1.instanceOf)(schema, graphql_1.GraphQLSchema)
|
|
21
|
+
? schema.getDirective(directiveName)
|
|
23
22
|
: undefined;
|
|
24
23
|
if (!directive) {
|
|
25
24
|
return undefined;
|
|
@@ -31,7 +30,7 @@ const getDirectiveExampleOption = (options) => {
|
|
|
31
30
|
};
|
|
32
31
|
};
|
|
33
32
|
exports.getDirectiveExampleOption = getDirectiveExampleOption;
|
|
34
|
-
const parseTypeFields = (type, options) => {
|
|
33
|
+
const parseTypeFields = (type, options, mappedTypes = []) => {
|
|
35
34
|
const directiveExample = (0, exports.getDirectiveExampleOption)(options);
|
|
36
35
|
if (!directiveExample) {
|
|
37
36
|
return undefined;
|
|
@@ -43,65 +42,81 @@ const parseTypeFields = (type, options) => {
|
|
|
43
42
|
let example = {};
|
|
44
43
|
fields
|
|
45
44
|
.filter((field) => {
|
|
46
|
-
return (0,
|
|
45
|
+
return (0, link_1.hasPrintableDirective)(field, options);
|
|
47
46
|
})
|
|
48
47
|
.forEach((field) => {
|
|
49
48
|
const fieldType = (0, graphql_1.hasDirective)(field, [directiveExample.directive])
|
|
50
49
|
? field
|
|
51
50
|
: field.type;
|
|
52
51
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
53
|
-
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
|
+
}
|
|
54
62
|
example = {
|
|
55
63
|
...example,
|
|
56
|
-
[field.name]:
|
|
57
|
-
? [value]
|
|
58
|
-
: value,
|
|
64
|
+
[field.name]: structuredValue,
|
|
59
65
|
};
|
|
60
66
|
});
|
|
61
67
|
return example;
|
|
62
68
|
};
|
|
63
|
-
const parseExampleValue = (value,
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
65
|
-
type) => {
|
|
69
|
+
const parseExampleValue = (value, type) => {
|
|
66
70
|
if (!value || typeof value !== "string") {
|
|
67
71
|
return undefined;
|
|
68
72
|
}
|
|
69
73
|
try {
|
|
70
74
|
return JSON.parse(value);
|
|
71
75
|
}
|
|
72
|
-
catch
|
|
76
|
+
catch {
|
|
73
77
|
if ((0, graphql_1.isOperation)(type)) {
|
|
74
78
|
try {
|
|
75
79
|
return (0, graphql_1.parse)(value, { noLocation: true });
|
|
76
80
|
}
|
|
77
|
-
catch
|
|
81
|
+
catch {
|
|
78
82
|
/* empty */
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
return value;
|
|
83
87
|
};
|
|
84
|
-
const parseExampleDirective = (type, options) => {
|
|
88
|
+
const parseExampleDirective = (type, options, mappedTypes = []) => {
|
|
85
89
|
const directiveExample = (0, exports.getDirectiveExampleOption)(options);
|
|
86
|
-
if (!directiveExample || !(0,
|
|
90
|
+
if (!directiveExample || !(0, link_1.hasPrintableDirective)(type, options)) {
|
|
87
91
|
return undefined;
|
|
88
92
|
}
|
|
89
93
|
const parser = typeof directiveExample.parser === "function"
|
|
90
94
|
? directiveExample.parser
|
|
91
95
|
: parseExampleValue;
|
|
96
|
+
// get parent type
|
|
92
97
|
const namedType = (0, graphql_1.isType)(type) ? (0, graphql_1.getNamedType)(type) : type;
|
|
93
98
|
if (!namedType) {
|
|
94
99
|
return undefined;
|
|
95
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);
|
|
96
110
|
try {
|
|
97
111
|
const arg = (0, graphql_1.getTypeDirectiveArgValue)(directiveExample.directive, namedType, directiveExample.field);
|
|
98
112
|
return parser(arg, namedType);
|
|
99
113
|
}
|
|
100
114
|
catch (err) {
|
|
101
115
|
if (err instanceof graphql_1.IntrospectionError) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
116
|
+
if (!(0, graphql_1.isType)(namedType)) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return parseTypeFields(namedType, options, mappedTypes);
|
|
105
120
|
}
|
|
106
121
|
throw err;
|
|
107
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,9 +1,11 @@
|
|
|
1
|
-
import type { 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
|
+
export declare const API_GROUPS: Required<ApiGroupOverrideType>;
|
|
3
|
+
export declare const hasPrintableDirective: (type: unknown, options?: Pick<PrintTypeOptions, "deprecated" | "onlyDocDirectives" | "skipDocDirectives">) => boolean;
|
|
2
4
|
export declare const getCategoryLocale: (type: unknown) => Maybe<TypeLocale>;
|
|
3
5
|
export declare const getLinkCategoryFolder: (type: unknown, operationLocale?: Maybe<TypeLocale>) => Maybe<string>;
|
|
4
6
|
export declare const hasOptionWithAttributes: (options: PrintLinkOptions) => boolean;
|
|
5
7
|
export declare const hasOptionParentType: (options: PrintLinkOptions) => boolean;
|
|
6
|
-
export declare const getLinkApiGroupFolder: (type: unknown) => string;
|
|
8
|
+
export declare const getLinkApiGroupFolder: (type: unknown, groups?: Maybe<ApiGroupOverrideType | boolean>) => string;
|
|
7
9
|
export declare const getLinkDeprecatedFolder: (type: unknown, option: Maybe<TypeDeprecatedOption>) => string;
|
|
8
10
|
export declare const toLink: (type: unknown, name: string, operation: Maybe<TypeLocale>, options: PrintLinkOptions) => TypeLink;
|
|
9
11
|
export declare const getRelationLink: (category: Maybe<TypeLocale>, type: unknown, options: PrintLinkOptions) => Maybe<TypeLink>;
|
package/dist/link.js
CHANGED
|
@@ -1,11 +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 = 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
|
|
8
|
+
const options_1 = require("./const/options");
|
|
9
|
+
exports.API_GROUPS = {
|
|
10
|
+
operations: "operations",
|
|
11
|
+
types: "types",
|
|
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;
|
|
9
32
|
const getCategoryLocale = (type) => {
|
|
10
33
|
switch (true) {
|
|
11
34
|
case (0, graphql_1.isDirectiveType)(type):
|
|
@@ -58,36 +81,54 @@ const hasOptionParentType = (options) => {
|
|
|
58
81
|
typeof options.parentType !== "undefined");
|
|
59
82
|
};
|
|
60
83
|
exports.hasOptionParentType = hasOptionParentType;
|
|
61
|
-
const getLinkApiGroupFolder = (type) => {
|
|
62
|
-
|
|
84
|
+
const getLinkApiGroupFolder = (type, groups) => {
|
|
85
|
+
let folderNames = exports.API_GROUPS;
|
|
86
|
+
if (groups && typeof groups === "object") {
|
|
87
|
+
folderNames = { ...exports.API_GROUPS, ...groups };
|
|
88
|
+
}
|
|
89
|
+
return (0, graphql_1.isApiType)(type) ? folderNames.operations : folderNames.types;
|
|
63
90
|
};
|
|
64
91
|
exports.getLinkApiGroupFolder = getLinkApiGroupFolder;
|
|
65
92
|
const getLinkDeprecatedFolder = (type, option) => {
|
|
66
93
|
return option === "group" && (0, graphql_1.isDeprecated)(type) ? strings_1.DEPRECATED : "";
|
|
67
94
|
};
|
|
68
95
|
exports.getLinkDeprecatedFolder = getLinkDeprecatedFolder;
|
|
96
|
+
const isHierarchy = (options, hierarchy) => {
|
|
97
|
+
return (options?.hierarchy?.[hierarchy] && true);
|
|
98
|
+
};
|
|
69
99
|
const toLink = (type, name, operation, options) => {
|
|
70
100
|
const fallback = {
|
|
71
101
|
text: name,
|
|
72
102
|
url: "#",
|
|
73
103
|
};
|
|
74
104
|
if (typeof type !== "object" ||
|
|
75
|
-
(typeof options !== "undefined" && !(0,
|
|
105
|
+
(typeof options !== "undefined" && !(0, exports.hasPrintableDirective)(type, options))) {
|
|
76
106
|
return fallback;
|
|
77
107
|
}
|
|
78
108
|
const graphQLNamedType = (0, graphql_1.getNamedType)(type);
|
|
79
|
-
|
|
80
|
-
if (!category || !graphQLNamedType) {
|
|
109
|
+
if (!graphQLNamedType) {
|
|
81
110
|
return fallback;
|
|
82
111
|
}
|
|
112
|
+
let category = "";
|
|
113
|
+
let deprecatedFolder = "";
|
|
114
|
+
let groupFolder = "";
|
|
115
|
+
let apiGroupFolder = "";
|
|
116
|
+
if (!isHierarchy(options, options_1.TypeHierarchy.FLAT)) {
|
|
117
|
+
category = (0, exports.getLinkCategoryFolder)(graphQLNamedType, operation);
|
|
118
|
+
if (!category) {
|
|
119
|
+
return fallback;
|
|
120
|
+
}
|
|
121
|
+
deprecatedFolder = options.deprecated
|
|
122
|
+
? (0, exports.getLinkDeprecatedFolder)(type, options.deprecated)
|
|
123
|
+
: "";
|
|
124
|
+
groupFolder = options.groups
|
|
125
|
+
? (0, group_1.getGroup)(type, options.groups, category)
|
|
126
|
+
: "";
|
|
127
|
+
apiGroupFolder = isHierarchy(options, options_1.TypeHierarchy.API)
|
|
128
|
+
? (0, exports.getLinkApiGroupFolder)(type)
|
|
129
|
+
: "";
|
|
130
|
+
}
|
|
83
131
|
const text = graphQLNamedType.name || graphQLNamedType.toString();
|
|
84
|
-
const deprecatedFolder = options.deprecated
|
|
85
|
-
? (0, exports.getLinkDeprecatedFolder)(type, options.deprecated)
|
|
86
|
-
: "";
|
|
87
|
-
const groupFolder = options.groups
|
|
88
|
-
? (0, group_1.getGroup)(type, options.groups, category)
|
|
89
|
-
: "";
|
|
90
|
-
const apiGroupFolder = options.useApiGroup ? (0, exports.getLinkApiGroupFolder)(type) : "";
|
|
91
132
|
const url = utils_1.pathUrl.join(options.basePath, deprecatedFolder, apiGroupFolder, groupFolder, category, `${(0, utils_1.slugify)(text)}${strings_1.LINK_MDX_EXTENSION}`);
|
|
92
133
|
return {
|
|
93
134
|
text,
|
|
@@ -127,7 +168,7 @@ const printLink = (type, options) => {
|
|
|
127
168
|
if (typeof type !== "object" || type === null) {
|
|
128
169
|
return "";
|
|
129
170
|
}
|
|
130
|
-
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);
|
|
131
172
|
if (typeof options !== "undefined" && !(0, exports.hasOptionWithAttributes)(options)) {
|
|
132
173
|
const textWithAttribute = (0, exports.hasOptionParentType)(options)
|
|
133
174
|
? `<code style={{ fontWeight: 'normal' }}>${options.parentType}.<b>${link.text}</b></code>`
|
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");
|
|
@@ -42,7 +43,7 @@ class Printer {
|
|
|
42
43
|
skipDocDirectives: skipDocDirectives ?? [],
|
|
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,
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
static printHeader = (id, title, options) => {
|
|
@@ -143,7 +144,7 @@ class Printer {
|
|
|
143
144
|
...Printer.options,
|
|
144
145
|
...options,
|
|
145
146
|
};
|
|
146
|
-
if (!name || !(0,
|
|
147
|
+
if (!name || !(0, link_1.hasPrintableDirective)(type, printTypeOptions)) {
|
|
147
148
|
return undefined;
|
|
148
149
|
}
|
|
149
150
|
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.9.1",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"@docusaurus/utils": ">=3.2.0",
|
|
60
|
-
"@graphql-markdown/graphql": "^1.1.
|
|
61
|
-
"@graphql-markdown/utils": "^1.
|
|
60
|
+
"@graphql-markdown/graphql": "^1.1.5",
|
|
61
|
+
"@graphql-markdown/utils": "^1.7.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@graphql-markdown/types": "^1.
|
|
64
|
+
"@graphql-markdown/types": "^1.4.2"
|
|
65
65
|
},
|
|
66
66
|
"resolutions": {
|
|
67
|
-
"micromatch": "4.0.
|
|
67
|
+
"micromatch": "4.0.8"
|
|
68
68
|
},
|
|
69
69
|
"directories": {
|
|
70
70
|
"test": "tests"
|