@graphql-markdown/printer-legacy 1.4.2 → 1.4.3

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/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.4.2",
8
+ "version": "1.4.3",
9
9
  "license": "MIT",
10
10
  "main": "src/index.js",
11
11
  "repository": {
package/src/badge.js CHANGED
@@ -63,6 +63,7 @@ function printBadge({ text, classname }) {
63
63
  }
64
64
 
65
65
  module.exports = {
66
+ DEFAULT_CSS_CLASSNAME,
66
67
  getTypeBadges,
67
68
  printBadge,
68
69
  printBadges,
package/src/link.js CHANGED
@@ -22,28 +22,28 @@ const {
22
22
  } = require("@graphql-markdown/utils");
23
23
 
24
24
  const { getGroup } = require("./group");
25
- const { ROOT_TYPE_LOCALE, DEPRECATED } = require("./const/strings");
25
+ const { DEPRECATED, ROOT_TYPE_LOCALE } = require("./const/strings");
26
26
  const { OPTION_DEPRECATED } = require("./const/options");
27
27
 
28
28
  class Link {
29
29
  static getLinkCategory = (graphLQLNamedType) => {
30
30
  switch (true) {
31
+ case isDirectiveType(graphLQLNamedType):
32
+ return ROOT_TYPE_LOCALE.DIRECTIVE;
31
33
  case isEnumType(graphLQLNamedType):
32
34
  return ROOT_TYPE_LOCALE.ENUM;
33
- case isUnionType(graphLQLNamedType):
34
- return ROOT_TYPE_LOCALE.UNION;
35
+ case isInputType(graphLQLNamedType):
36
+ return ROOT_TYPE_LOCALE.INPUT;
35
37
  case isInterfaceType(graphLQLNamedType):
36
38
  return ROOT_TYPE_LOCALE.INTERFACE;
37
39
  case isObjectType(graphLQLNamedType):
38
40
  return ROOT_TYPE_LOCALE.TYPE;
39
- case isInputType(graphLQLNamedType):
40
- return ROOT_TYPE_LOCALE.INPUT;
41
- case isScalarType(graphLQLNamedType):
42
- return ROOT_TYPE_LOCALE.SCALAR;
43
- case isDirectiveType(graphLQLNamedType):
44
- return ROOT_TYPE_LOCALE.DIRECTIVE;
45
41
  case isOperation(graphLQLNamedType):
46
42
  return ROOT_TYPE_LOCALE.OPERATION;
43
+ case isScalarType(graphLQLNamedType):
44
+ return ROOT_TYPE_LOCALE.SCALAR;
45
+ case isUnionType(graphLQLNamedType):
46
+ return ROOT_TYPE_LOCALE.UNION;
47
47
  }
48
48
  return undefined;
49
49
  };
@@ -110,10 +110,9 @@ class Link {
110
110
 
111
111
  static getRelationLink = (category, type, options) => {
112
112
  if (typeof category === "undefined") {
113
- return "";
113
+ return undefined;
114
114
  }
115
- const link = Link.toLink(type, type.name, category, options);
116
- return `[\`${link.text}\`](${link.url}) <Badge class="secondary" text="${category.singular}"/>`;
115
+ return Link.toLink(type, type.name, category, options);
117
116
  };
118
117
 
119
118
  static printParentLink = (type, options) => {
package/src/relation.js CHANGED
@@ -1,17 +1,18 @@
1
1
  const {
2
2
  graphql: {
3
- isOperation,
4
- getRelationOfReturn,
5
3
  getRelationOfField,
6
4
  getRelationOfImplementation,
5
+ getRelationOfReturn,
6
+ isOperation,
7
7
  },
8
8
  } = require("@graphql-markdown/utils");
9
9
 
10
10
  const { getRelationLink } = require("./link");
11
+ const { DEFAULT_CSS_CLASSNAME, printBadge } = require("./badge");
11
12
  const {
12
- ROOT_TYPE_LOCALE,
13
13
  HEADER_SECTION_LEVEL,
14
14
  MARKDOWN_EOP,
15
+ ROOT_TYPE_LOCALE,
15
16
  } = require("./const/strings");
16
17
 
17
18
  const getRootTypeLocaleFromString = (text) => {
@@ -46,7 +47,16 @@ const printRelationOf = (type, section, getRelation, options) => {
46
47
  }
47
48
 
48
49
  const category = getRootTypeLocaleFromString(relation);
49
- data = data.concat(types.map((t) => getRelationLink(category, t, options)));
50
+ const badge = printBadge({
51
+ text: category.singular,
52
+ classname: DEFAULT_CSS_CLASSNAME,
53
+ });
54
+ data = data.concat(
55
+ types.map((t) => {
56
+ const link = getRelationLink(category, t, options);
57
+ return link ? `[\`${link.text}\`](${link.url}) ${badge}` : "";
58
+ }),
59
+ );
50
60
  }
51
61
 
52
62
  if (data.length === 0) {