Repository: graphql-markdown/graphql-markdown
Pull request #1820 (2024-11-24 14:12:15)

♻️ remove circular dependencies
# Description

Remove circular dependencies reported by `npx madge --circular --extensions ts ./packages`

# Checklist

- [x] My changes follow the [contributing guidelines](https://github.com/graphql-markdown/graphql-markdown/blob/main/CONTRIBUTING.md) of this project.
- [x] I have performed a self-review of my code.
- [ ] I have made corresponding changes to the documentation.
- [x] I have added tests that prove my fix is effective or that my changes work.
- [x] New and existing unit tests pass locally with my changes.


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=graphql-markdown_helpers&pullRequest=1820) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=graphql-markdown_helpers&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=graphql-markdown_helpers&pullRequest=1820&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=graphql-markdown_helpers&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_helpers&pullRequest=1820&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_helpers&pullRequest=1820&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=graphql-markdown_helpers&pullRequest=1820)


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=graphql-markdown_graphql&pullRequest=1820) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=graphql-markdown_graphql&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=graphql-markdown_graphql&pullRequest=1820&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=graphql-markdown_graphql&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_graphql&pullRequest=1820&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_graphql&pullRequest=1820&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=graphql-markdown_graphql&pullRequest=1820)


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=graphql-markdown_utils&pullRequest=1820) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=graphql-markdown_utils&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=graphql-markdown_utils&pullRequest=1820&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=graphql-markdown_utils&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_utils&pullRequest=1820&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_utils&pullRequest=1820&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=graphql-markdown_utils&pullRequest=1820)


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=graphql-markdown_core&pullRequest=1820) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=graphql-markdown_core&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=graphql-markdown_core&pullRequest=1820&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=graphql-markdown_core&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_core&pullRequest=1820&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_core&pullRequest=1820&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=graphql-markdown_core&pullRequest=1820)


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=graphql-markdown_printer-legacy&pullRequest=1820) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=graphql-markdown_printer-legacy&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=graphql-markdown_printer-legacy&pullRequest=1820&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=graphql-markdown_printer-legacy&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_printer-legacy&pullRequest=1820&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_printer-legacy&pullRequest=1820&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=graphql-markdown_printer-legacy&pullRequest=1820)


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=graphql-markdown_docusaurus&pullRequest=1820) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=graphql-markdown_docusaurus&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=graphql-markdown_docusaurus&pullRequest=1820&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=graphql-markdown_docusaurus&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_docusaurus&pullRequest=1820&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_docusaurus&pullRequest=1820&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=graphql-markdown_docusaurus&pullRequest=1820)


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=graphql-markdown_logger&pullRequest=1820) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=graphql-markdown_logger&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=graphql-markdown_logger&pullRequest=1820&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=graphql-markdown_logger&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_logger&pullRequest=1820&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_logger&pullRequest=1820&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=graphql-markdown_logger&pullRequest=1820)


sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=graphql-markdown_diff&pullRequest=1820) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=graphql-markdown_diff&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=graphql-markdown_diff&pullRequest=1820&issueStatuses=ACCEPTED)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=graphql-markdown_diff&pullRequest=1820&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_diff&pullRequest=1820&metric=new_coverage&view=list)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=graphql-markdown_diff&pullRequest=1820&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=graphql-markdown_diff&pullRequest=1820)



Patch:
diff --git a/packages/graphql/src/directive.ts b/packages/graphql/src/directive.ts
index 7ea3b825..0d0e7a19 100644
--- a/packages/graphql/src/directive.ts
+++ b/packages/graphql/src/directive.ts
@@ -13,14 +13,12 @@ import type {
   CustomDirectiveOptions,
   Maybe,
   SchemaMap,
-  GraphQLDirective,
   CustomDirectiveMapItem,
 } from "@graphql-markdown/types";
 
 import { isEmpty } from "@graphql-markdown/utils";
 
 import { getDirective } from "./introspection";
-import { DirectiveLocation } from "graphql/language";
 
 /**
  * Wildcard `*` character for matching any directive name.
@@ -276,39 +274,3 @@ export const getConstDirectiveMap = (
     {},
   );
 };
-
-/**
- * Checks if a directive is executable (related to operations).
- *
- * @param type - a GraphQL directive.
- *
- */
-export const executableDirectiveLocation = (
-  directive: GraphQLDirective,
-): boolean => {
-  return [
-    DirectiveLocation.QUERY,
-    DirectiveLocation.MUTATION,
-    DirectiveLocation.SUBSCRIPTION,
-    DirectiveLocation.FIELD,
-    DirectiveLocation.FRAGMENT_DEFINITION,
-    DirectiveLocation.FRAGMENT_SPREAD,
-    DirectiveLocation.INLINE_FRAGMENT,
-    DirectiveLocation.VARIABLE_DEFINITION,
-  ].some((item) => {
-    return directive.locations.includes(item);
-  });
-};
-
-/**
- * Checks if a directive is system (related to schema definition).
- *
- * @param type - a GraphQL directive.
- *
- */
-export const typeSystemDirectiveLocation = (
-  directive: GraphQLDirective,
-): boolean => {
-  // we assume that if not executable then it is a system directive
-  return !executableDirectiveLocation(directive);
-};
diff --git a/packages/graphql/src/guard.ts b/packages/graphql/src/guard.ts
index 2237ac1b..e5f79485 100644
--- a/packages/graphql/src/guard.ts
+++ b/packages/graphql/src/guard.ts
@@ -5,15 +5,15 @@
  */
 
 import type {
+  GraphQLDirective,
   GraphQLField,
   GraphQLOperationType,
   DeprecatedType,
 } from "@graphql-markdown/types";
 
+import { DirectiveLocation } from "graphql/language";
 import { isDirective } from "graphql/type/directives";
 
-import { executableDirectiveLocation } from "./directive";
-
 export {
   isDirective as isDirectiveType,
   isEnumType,
@@ -95,6 +95,42 @@ export const isOperation = (type: unknown): type is GraphQLOperationType => {
   return typeof type === "object" && type !== null && "type" in type;
 };
 
+/**
+ * Checks if a directive is executable (related to operations).
+ *
+ * @param type - a GraphQL directive.
+ *
+ */
+export const executableDirectiveLocation = (
+  directive: GraphQLDirective,
+): boolean => {
+  return [
+    DirectiveLocation.QUERY,
+    DirectiveLocation.MUTATION,
+    DirectiveLocation.SUBSCRIPTION,
+    DirectiveLocation.FIELD,
+    DirectiveLocation.FRAGMENT_DEFINITION,
+    DirectiveLocation.FRAGMENT_SPREAD,
+    DirectiveLocation.INLINE_FRAGMENT,
+    DirectiveLocation.VARIABLE_DEFINITION,
+  ].some((item) => {
+    return directive.locations.includes(item);
+  });
+};
+
+/**
+ * Checks if a directive is system (related to schema definition).
+ *
+ * @param type - a GraphQL directive.
+ *
+ */
+export const typeSystemDirectiveLocation = (
+  directive: GraphQLDirective,
+): boolean => {
+  // we assume that if not executable then it is a system directive
+  return !executableDirectiveLocation(directive);
+};
+
 /**
  * Checks if a type belongs to API (operation related).
  *
diff --git a/packages/printer-legacy/src/code.ts b/packages/printer-legacy/src/code.ts
index b95e6579..812ee151 100644
--- a/packages/printer-legacy/src/code.ts
+++ b/packages/printer-legacy/src/code.ts
@@ -11,7 +11,7 @@ import {
   DEPRECATED,
   MARKDOWN_CODE_INDENTATION,
 } from "./const/strings";
-import { hasPrintableDirective } from "./common";
+import { hasPrintableDirective } from "./link";
 
 export const printCodeArguments = (
   type: unknown,
diff --git a/packages/printer-legacy/src/common.ts b/packages/printer-legacy/src/common.ts
index a39add01..8d275ab4 100644
--- a/packages/printer-legacy/src/common.ts
+++ b/packages/printer-legacy/src/common.ts
@@ -10,11 +10,7 @@ import type {
 
 import { isEmpty, escapeMDX } from "@graphql-markdown/utils";
 
-import {
-  isDeprecated,
-  getConstDirectiveMap,
-  hasDirective,
-} from "@graphql-markdown/graphql";
+import { isDeprecated, getConstDirectiveMap } from "@graphql-markdown/graphql";
 
 import { getCustomDirectiveResolver } from "./directive";
 
@@ -103,36 +99,3 @@ export const printDescription = (
   const deprecation = printDeprecation(type);
   return `${deprecation}${description}${customDirectives}`;
 };
-
-export const hasPrintableDirective = (
-  type: unknown,
-  options?: Pick<
-    PrintTypeOptions,
-    "deprecated" | "onlyDocDirectives" | "skipDocDirectives"
-  >,
-): boolean => {
-  if (!type) {
-    return false;
-  }
-
-  if (!options) {
-    return true;
-  }
-
-  const skipDirective =
-    "skipDocDirectives" in options && options.skipDocDirectives
-      ? hasDirective(type, options.skipDocDirectives)
-      : false;
-
-  const skipDeprecated =
-    "deprecated" in options &&
-    options.deprecated === "skip" &&
-    isDeprecated(type);
-
-  const onlyDirective =
-    "onlyDocDirectives" in options && options.onlyDocDirectives
-      ? hasDirective(type, options.onlyDocDirectives, true)
-      : true;
-
-  return !(skipDirective || skipDeprecated) && onlyDirective;
-};
diff --git a/packages/printer-legacy/src/example.ts b/packages/printer-legacy/src/example.ts
index 1c401be6..69e48e7b 100644
--- a/packages/printer-legacy/src/example.ts
+++ b/packages/printer-legacy/src/example.ts
@@ -24,7 +24,7 @@ import {
   print,
 } from "@graphql-markdown/graphql";
 
-import { hasPrintableDirective } from "./common";
+import { hasPrintableDirective } from "./link";
 
 export const getDirectiveExampleOption = (
   options: PrintTypeOptions,
diff --git a/packages/printer-legacy/src/graphql/enum.ts b/packages/printer-legacy/src/graphql/enum.ts
index 432271fc..7242ea65 100644
--- a/packages/printer-legacy/src/graphql/enum.ts
+++ b/packages/printer-legacy/src/graphql/enum.ts
@@ -8,7 +8,7 @@ import {
 
 import { MARKDOWN_EOL, DEPRECATED } from "../const/strings";
 import { printMetadataSection } from "../section";
-import { hasPrintableDirective } from "../common";
+import { hasPrintableDirective } from "../link";
 
 export const printEnumMetadata = (
   type: unknown,
diff --git a/packages/printer-legacy/src/link.ts b/packages/printer-legacy/src/link.ts
index ffaac202..856e18ff 100644
--- a/packages/printer-legacy/src/link.ts
+++ b/packages/printer-legacy/src/link.ts
@@ -5,6 +5,7 @@ import type {
   MDXString,
   Maybe,
   PrintLinkOptions,
+  PrintTypeOptions,
   SchemaEntity,
   TypeDeprecatedOption,
   TypeHierarchyObjectType,
@@ -16,6 +17,7 @@ import type {
 import {
   getNamedType,
   getTypeName,
+  hasDirective,
   isApiType,
   isDeprecated,
   isDirectiveType,
@@ -39,7 +41,6 @@ import {
   LINK_MDX_EXTENSION,
   ROOT_TYPE_LOCALE,
 } from "./const/strings";
-import { hasPrintableDirective } from "./common";
 import { TypeHierarchy } from "./const/options";
 
 export const API_GROUPS: Required<ApiGroupOverrideType> = {
@@ -47,6 +48,39 @@ export const API_GROUPS: Required<ApiGroupOverrideType> = {
   types: "types",
 } as const;
 
+export const hasPrintableDirective = (
+  type: unknown,
+  options?: Pick<
+    PrintTypeOptions,
+    "deprecated" | "onlyDocDirectives" | "skipDocDirectives"
+  >,
+): boolean => {
+  if (!type) {
+    return false;
+  }
+
+  if (!options) {
+    return true;
+  }
+
+  const skipDirective =
+    "skipDocDirectives" in options && options.skipDocDirectives
+      ? hasDirective(type, options.skipDocDirectives)
+      : false;
+
+  const skipDeprecated =
+    "deprecated" in options &&
+    options.deprecated === "skip" &&
+    isDeprecated(type);
+
+  const onlyDirective =
+    "onlyDocDirectives" in options && options.onlyDocDirectives
+      ? hasDirective(type, options.onlyDocDirectives, true)
+      : true;
+
+  return !(skipDirective || skipDeprecated) && onlyDirective;
+};
+
 export const getCategoryLocale = (type: unknown): Maybe<TypeLocale> => {
   switch (true) {
     case isDirectiveType(type):
diff --git a/packages/printer-legacy/src/printer.ts b/packages/printer-legacy/src/printer.ts
index 18071064..386e4c0d 100644
--- a/packages/printer-legacy/src/printer.ts
+++ b/packages/printer-legacy/src/printer.ts
@@ -26,7 +26,7 @@ import {
 import { pathUrl } from "@graphql-markdown/utils";
 
 import { printRelations } from "./relation";
-import { hasPrintableDirective, printDescription } from "./common";
+import { printDescription } from "./common";
 import { printCustomDirectives, printCustomTags } from "./directive";
 import { printFrontMatter } from "./frontmatter";
 import {
@@ -47,6 +47,7 @@ import {
   printScalarMetadata,
   printUnionMetadata,
 } from "./graphql";
+import { hasPrintableDirective } from "./link";
 
 import {
   MARKDOWN_EOC,
diff --git a/packages/printer-legacy/src/section.ts b/packages/printer-legacy/src/section.ts
index af3c97ff..99759e00 100644
--- a/packages/printer-legacy/src/section.ts
+++ b/packages/printer-legacy/src/section.ts
@@ -8,9 +8,9 @@ import type {
 
 import { isGraphQLFieldType, isDeprecated } from "@graphql-markdown/graphql";
 
-import { hasPrintableDirective, printDescription } from "./common";
+import { printDescription } from "./common";
 import { printBadges } from "./badge";
-import { printLink, printParentLink } from "./link";
+import { hasPrintableDirective, printLink, printParentLink } from "./link";
 import { printCustomTags } from "./directive";
 
 import {
diff --git a/packages/types/src/core.d.ts b/packages/types/src/core.d.ts
index 935aa837..a1732d2b 100644
--- a/packages/types/src/core.d.ts
+++ b/packages/types/src/core.d.ts
@@ -1,13 +1,11 @@
 import type { UnnormalizedTypeDefPointer } from "@graphql-tools/load";
 import type { BaseLoaderOptions } from "@graphql-tools/utils";
 
-import type {
-  CustomDirective,
-  DirectiveName,
-  GraphQLDirective,
-  GraphQLSchema,
-  Maybe,
-} from ".";
+import type { DirectiveName, GraphQLDirective, GraphQLSchema } from "./graphql";
+
+import type { CustomDirective } from "./helpers";
+
+import type { Maybe } from "./utils";
 
 export type FrontMatterOptions = Record<string, unknown>;
 
diff --git a/packages/types/src/graphql.d.ts b/packages/types/src/graphql.d.ts
index f40dca30..ed6eafc7 100644
--- a/packages/types/src/graphql.d.ts
+++ b/packages/types/src/graphql.d.ts
@@ -1,5 +1,6 @@
+import type { GraphQLProjectConfig } from "graphql-config";
+import type { ObjectTypeDefinitionNode } from "graphql/language";
 import type {
-  ConfigOptions,
   GraphQLDirective,
   GraphQLEnumType,
   GraphQLFieldMap,
@@ -10,11 +11,33 @@ import type {
   GraphQLObjectType,
   GraphQLScalarType,
   GraphQLUnionType,
-  Maybe,
-  ObjectTypeDefinitionNode,
-} from ".";
+} from "graphql/type";
 
-import type { GraphQLProjectConfig } from "graphql-config";
+import type { Maybe } from "./utils";
+
+export type {
+  GraphQLArgument,
+  GraphQLDirective,
+  GraphQLEnumType,
+  GraphQLField,
+  GraphQLFieldMap,
+  GraphQLInputFieldMap,
+  GraphQLInputObjectType,
+  GraphQLInterfaceType,
+  GraphQLNamedType,
+  GraphQLObjectType,
+  GraphQLScalarType,
+  GraphQLSchema,
+  GraphQLSchemaConfig,
+  GraphQLType,
+  GraphQLUnionType,
+} from "graphql/type";
+
+export type { LoadSchemaOptions } from "@graphql-tools/load";
+
+export type { GraphQLExtensionDeclaration } from "graphql-config";
+
+export type { ASTNode, DirectiveNode } from "graphql/language";
 
 export type DeprecatedType<T> = Partial<{
   deprecationReason: string;
@@ -72,14 +95,14 @@ export type RelationOfInterface = GraphQLInterfaceType | GraphQLObjectType;
 export type RelationOfImplementation = GraphQLUnionType | RelationOfInterface;
 export type ExtensionProjectConfig = Omit<ConfigOptions, "schema"> &
   Writeable<GraphQLProjectConfig>;
-export interface RelationOf {
-  section: string;
-  getRelation: IGetRelation;
-}
 export type IGetRelation<T> = (
   type: unknown,
   schemaMap: Maybe<SchemaMap>,
 ) => Partial<Record<SchemaEntity, T[]>>;
+export interface RelationOf {
+  section: string;
+  getRelation: IGetRelation<T>;
+}
 type Writeable<T> = {
   -readonly [P in keyof T]: T[P];
 };
diff --git a/packages/types/src/helpers.d.ts b/packages/types/src/helpers.d.ts
index 7cf5f30d..f57071a1 100644
--- a/packages/types/src/helpers.d.ts
+++ b/packages/types/src/helpers.d.ts
@@ -1,4 +1,4 @@
-import type { GraphQLDirective, DirectiveName } from ".";
+import type { GraphQLDirective, DirectiveName } from "./graphql";
 
 export type CustomDirectiveFunction = (
   directive?: GraphQLDirective,
diff --git a/packages/types/src/index.d.ts b/packages/types/src/index.d.ts
index 89e424c0..2fb8114d 100644
--- a/packages/types/src/index.d.ts
+++ b/packages/types/src/index.d.ts
@@ -1,43 +1,17 @@
-export type {
-  GraphQLArgument,
-  GraphQLDirective,
-  GraphQLEnumType,
-  GraphQLField,
-  GraphQLFieldMap,
-  GraphQLInputFieldMap,
-  GraphQLInputObjectType,
-  GraphQLInterfaceType,
-  GraphQLNamedType,
-  GraphQLObjectType,
-  GraphQLScalarType,
-  GraphQLSchema,
-  GraphQLSchemaConfig,
-  GraphQLType,
-  GraphQLUnionType,
-} from "graphql/type";
-
-export type { LoadSchemaOptions } from "@graphql-tools/load";
-
-export type { GraphQLExtensionDeclaration } from "graphql-config";
-
-export type { ASTNode, DirectiveNode } from "graphql/language";
-
-export type Maybe<T> = T | null | undefined;
-
 // @graphql-markdown/core
-export * from "./core";
+export type * from "./core";
 
 // @graphql-markdown/utils
-export * from "./utils";
+export type * from "./utils";
 
 // @graphql-markdown/printer-legacy
-export * from "./printer";
+export type * from "./printer";
 
 // @graphql-markdown/logger
 export type * from "./logger";
 
 // @graphql-markdown/graphql
-export * from "./graphql";
+export type * from "./graphql";
 
 // @graphql-markdown/helpers
 export type * from "./helpers";
diff --git a/packages/types/src/printer.d.ts b/packages/types/src/printer.d.ts
index f47b6146..153189bd 100644
--- a/packages/types/src/printer.d.ts
+++ b/packages/types/src/printer.d.ts
@@ -1,15 +1,17 @@
 import type {
   ConfigPrintTypeOptions,
-  CustomDirectiveMap,
   FrontMatterOptions,
-  GraphQLDirective,
-  GraphQLSchema,
-  Maybe,
-  SchemaEntitiesGroupMap,
   TypeDeprecatedOption,
   TypeExampleSectionOption,
   TypeHierarchyObjectType,
-} from ".";
+} from "./core";
+import type {
+  GraphQLDirective,
+  GraphQLSchema,
+  SchemaEntitiesGroupMap,
+} from "./graphql";
+import type { CustomDirectiveMap } from "./helpers";
+import type { Maybe, MDXString } from "./utils";
 
 export type RootTypeName =
   | "DIRECTIVE"
diff --git a/packages/types/src/utils.d.ts b/packages/types/src/utils.d.ts
index b5919faa..1d1b3499 100644
--- a/packages/types/src/utils.d.ts
+++ b/packages/types/src/utils.d.ts
@@ -1,4 +1,4 @@
-import type { Maybe } from ".";
+export type Maybe<T> = T | null | undefined;
 
 export interface Category {
   category: string;


Test patch:
diff --git a/packages/graphql/tests/unit/directive.test.ts b/packages/graphql/tests/unit/directive.test.ts
index fb777d6c..62d35aca 100644
--- a/packages/graphql/tests/unit/directive.test.ts
+++ b/packages/graphql/tests/unit/directive.test.ts
@@ -18,6 +18,8 @@ const {
   isCustomDirective,
 } = Directives;
 
+import * as Guard from "../../src/guard";
+
 describe("directive", () => {
   const schema = buildSchema(`
     directive @testA(
@@ -374,9 +376,7 @@ describe("directive", () => {
             locations,
           });
 
-          expect(Directives.executableDirectiveLocation(directive)).toBe(
-            executable,
-          );
+          expect(Guard.executableDirectiveLocation(directive)).toBe(executable);
         },
       );
     });
@@ -392,7 +392,7 @@ describe("directive", () => {
             locations,
           });
 
-          expect(Directives.typeSystemDirectiveLocation(directive)).not.toBe(
+          expect(Guard.typeSystemDirectiveLocation(directive)).not.toBe(
             executable,
           );
         },
diff --git a/packages/printer-legacy/tests/unit/common.test.ts b/packages/printer-legacy/tests/unit/common.test.ts
index c57e645e..6930ef82 100644
--- a/packages/printer-legacy/tests/unit/common.test.ts
+++ b/packages/printer-legacy/tests/unit/common.test.ts
@@ -1,13 +1,7 @@
-import type { ConstDirectiveNode } from "graphql/language";
-import {
-  GraphQLDirective,
-  GraphQLEnumType,
-  GraphQLScalarType,
-} from "graphql/type";
-import { DirectiveLocation, Kind } from "graphql/language";
+import { GraphQLDirective, GraphQLScalarType } from "graphql/type";
+import { DirectiveLocation } from "graphql/language";
 
 import {
-  hasPrintableDirective,
   printCustomDirectives,
   printDeprecation,
   printDescription,
@@ -15,7 +9,6 @@ import {
 } from "../../src/common";
 
 import { DEFAULT_OPTIONS } from "../../src/const/options";
-import type { PrintTypeOptions } from "@graphql-markdown/types";
 
 import * as DocusaurusUtils from "@docusaurus/utils";
 jest.mock("@docusaurus/utils", (): unknown => {
@@ -317,188 +310,6 @@ Test testDirective"
     });
   });
 
-  describe("hasPrintableDirective()", () => {
-    const noDocDirective = new GraphQLDirective({
-      name: "noDoc",
-      locations: [DirectiveLocation.ENUM],
-      astNode: {
-        kind: Kind.DIRECTIVE_DEFINITION,
-        name: { kind: Kind.NAME, value: "noDoc" },
-        repeatable: false,
-        locations: [],
-      },
-    });
-    const publicDirective = new GraphQLDirective({
-      name: "public",
-      locations: [DirectiveLocation.ENUM],
-      astNode: {
-        kind: Kind.DIRECTIVE_DEFINITION,
-        name: { kind: Kind.NAME, value: "public" },
-        repeatable: false,
-        locations: [],
-      },
-    });
-    const docDirective = new GraphQLDirective({
-      name: "doc",
-      locations: [DirectiveLocation.OBJECT],
-      astNode: {
-        kind: Kind.DIRECTIVE_DEFINITION,
-        name: { kind: Kind.NAME, value: "doc" },
-        repeatable: false,
-        locations: [],
-      },
-    });
-    const enumType = new GraphQLEnumType({
-      name: "test",
-      values: {
-        RED: { value: 0 },
-        GREEN: { value: 1 },
-        BLUE: { value: 2 },
-      },
-      astNode: {
-        kind: Kind.ENUM_TYPE_DEFINITION,
-        name: { kind: Kind.NAME, value: "test" },
-        directives: [
-          {
-            ...publicDirective.astNode,
-            kind: Kind.DIRECTIVE,
-          } as ConstDirectiveNode,
-        ],
-      },
-    });
-
-    test.each([
-      { options: undefined },
-      {
-        options: {
-          skipDocDirectives: undefined,
-          onlyDocDirectives: undefined,
-          deprecated: undefined,
-        },
-      },
-      {
-        options: {},
-      },
-    ])("return true if no option set", ({ options }) => {
-      expect.assertions(1);
-
-      expect(
-        hasPrintableDirective({}, options as unknown as PrintTypeOptions),
-      ).toBeTruthy();
-    });
-
-    test("return false if type undefined", () => {
-      expect.assertions(1);
-
-      expect(hasPrintableDirective(undefined, {})).toBeFalsy();
-    });
-
-    test("return false if type has skip directive", () => {
-      expect.assertions(1);
-
-      const options = {
-        skipDocDirectives: [noDocDirective],
-      } as unknown as PrintTypeOptions;
-      mockGraphQL.isDeprecated.mockReturnValue(false);
-      mockGraphQL.hasDirective.mockReturnValue(true);
-
-      expect(hasPrintableDirective(enumType, options)).toBeFalsy();
-    });
-
-    test("return true if type has not skip directive", () => {
-      expect.assertions(1);
-
-      const options = {
-        skipDocDirectives: [noDocDirective],
-      } as unknown as PrintTypeOptions;
-      mockGraphQL.isDeprecated.mockReturnValue(false);
-      mockGraphQL.hasDirective.mockReturnValue(false);
-
-      expect(hasPrintableDirective(enumType, options)).toBeTruthy();
-    });
-
-    test("return false if type has skip deprecated", () => {
-      expect.assertions(1);
-
-      const options = {
-        deprecated: "skip",
-      } as unknown as PrintTypeOptions;
-      mockGraphQL.isDeprecated.mockReturnValue(true);
-      mockGraphQL.hasDirective.mockReturnValue(true);
-
-      expect(hasPrintableDirective(enumType, options)).toBeFalsy();
-    });
-
-    test("return true if type has not skip deprecated", () => {
-      expect.assertions(1);
-
-      const options = {
-        deprecated: "default",
-      } as unknown as PrintTypeOptions;
-      mockGraphQL.isDeprecated.mockReturnValue(true);
-      mockGraphQL.hasDirective.mockReturnValue(true);
-
-      expect(hasPrintableDirective(enumType, options)).toBeTruthy();
-    });
-
-    test("return true if type has only directive", () => {
-      expect.assertions(1);
-
-      const options = {
-        onlyDocDirectives: [publicDirective],
-      } as unknown as PrintTypeOptions;
-      mockGraphQL.isDeprecated.mockReturnValue(false);
-      mockGraphQL.hasDirective.mockImplementation(
-        jest.requireActual("@graphql-markdown/graphql").hasDirective,
-      );
-
-      expect(hasPrintableDirective(enumType, options)).toBeTruthy();
-    });
-
-    test("return false if type has not only directive and type is a valid location", () => {
-      expect.assertions(1);
-
-      const options = {
-        onlyDocDirectives: [noDocDirective],
-      } as unknown as PrintTypeOptions;
-      mockGraphQL.isDeprecated.mockReturnValue(false);
-      mockGraphQL.hasDirective.mockImplementation(
-        jest.requireActual("@graphql-markdown/graphql").hasDirective,
-      );
-
-      expect(hasPrintableDirective(enumType, options)).toBeFalsy();
-    });
-
-    test("return true if type has not only directive and type is not a valid location", () => {
-      expect.assertions(1);
-
-      const options = {
-        onlyDocDirectives: [docDirective],
-      } as unknown as PrintTypeOptions;
-      mockGraphQL.isDeprecated.mockReturnValue(false);
-      mockGraphQL.hasDirective.mockImplementation(
-        jest.requireActual("@graphql-markdown/graphql").hasDirective,
-      );
-
-      expect(hasPrintableDirective(enumType, options)).toBeTruthy();
-    });
-
-    test("return false if type has only directive and skip deprecated", () => {
-      expect.assertions(1);
-
-      const options = {
-        deprecated: "skip",
-        onlyDocDirectives: [publicDirective],
-      } as unknown as PrintTypeOptions;
-      mockGraphQL.isDeprecated.mockReturnValue(true);
-      mockGraphQL.hasDirective.mockImplementation(
-        jest.requireActual("@graphql-markdown/graphql").hasDirective,
-      );
-
-      expect(hasPrintableDirective(enumType, options)).toBeFalsy();
-    });
-  });
-
   describe("printWarning()", () => {
     test("prints admonition caution for Docusaurus v2", () => {
       expect.assertions(1);
diff --git a/packages/printer-legacy/tests/unit/example.test.ts b/packages/printer-legacy/tests/unit/example.test.ts
index 5d4ca00b..b7046b64 100644
--- a/packages/printer-legacy/tests/unit/example.test.ts
+++ b/packages/printer-legacy/tests/unit/example.test.ts
@@ -7,6 +7,9 @@ import { getDirectiveExampleOption, printExample } from "../../src/example";
 import * as Common from "../../src/common";
 jest.mock("../../src/common");
 
+import * as Link from "../../src/link";
+jest.mock("../../src/link");
+
 describe("example", () => {
   const schema = buildSchema(`
   directive @example(
@@ -69,7 +72,7 @@ describe("example", () => {
 `);
 
   beforeEach(() => {
-    jest.spyOn(Common, "hasPrintableDirective").mockReturnValue(true);
+    jest.spyOn(Link, "hasPrintableDirective").mockReturnValue(true);
   });
 
   afterEach(() => {
@@ -170,7 +173,7 @@ describe("example", () => {
     test("returns undefined if directive not printable", () => {
       expect.assertions(1);
 
-      jest.spyOn(Common, "hasPrintableDirective").mockReturnValue(false);
+      jest.spyOn(Link, "hasPrintableDirective").mockReturnValue(false);
 
       expect(
         printExample(schema.getType("ScalarExample"), {
@@ -205,7 +208,7 @@ describe("example", () => {
       expect.assertions(1);
 
       jest
-        .spyOn(Common, "hasPrintableDirective")
+        .spyOn(Link, "hasPrintableDirective")
         // eslint-disable-next-line @typescript-eslint/no-unused-vars
         .mockImplementation((type, _options) => {
           return (type as { name: string }).name !== "ScalarExample";
@@ -222,7 +225,7 @@ describe("example", () => {
       expect.assertions(1);
 
       jest
-        .spyOn(Common, "hasPrintableDirective")
+        .spyOn(Link, "hasPrintableDirective")
         // eslint-disable-next-line @typescript-eslint/no-unused-vars
         .mockImplementation((type, _options) => {
           return (type as { name: string }).name !== "TypeExample";
diff --git a/packages/printer-legacy/tests/unit/link.test.ts b/packages/printer-legacy/tests/unit/link.test.ts
index df0a0e81..b73a7f91 100644
--- a/packages/printer-legacy/tests/unit/link.test.ts
+++ b/packages/printer-legacy/tests/unit/link.test.ts
@@ -1,12 +1,16 @@
 import {
   GraphQLList,
   GraphQLDirective,
+  GraphQLEnumType,
   GraphQLObjectType,
   GraphQLScalarType,
 } from "graphql/type";
 
+import { ConstDirectiveNode, DirectiveLocation, Kind } from "graphql/language";
+
 import type {
   PrintLinkOptions,
+  PrintTypeOptions,
   TypeLocale,
   GraphQLNamedType,
   ApiGroupOverrideType,
@@ -59,7 +63,6 @@ jest.mock("../../src/group", () => {
 const mockGroup = jest.mocked(Group, { shallow: true });
 
 import * as Link from "../../src/link";
-import * as Common from "../../src/common";
 
 describe("link", () => {
   const basePath: string = "docs/graphql";
@@ -122,7 +125,7 @@ describe("link", () => {
       ({ guard }) => {
         expect.assertions(1);
 
-        jest.spyOn(Common, "hasPrintableDirective").mockReturnValue(true);
+        jest.spyOn(Link, "hasPrintableDirective").mockReturnValue(true);
 
         mockGraphQL[guard].mockReturnValueOnce(true);
 
@@ -148,7 +151,7 @@ describe("link", () => {
   describe("toLink()", () => {
     beforeEach(() => {
       mockGroup.getGroup.mockReturnValue("");
-      jest.spyOn(Common, "hasPrintableDirective").mockReturnValue(true);
+      jest.spyOn(Link, "hasPrintableDirective").mockReturnValue(true);
     });
 
     test.each(types)(
@@ -243,7 +246,7 @@ describe("link", () => {
         entityName as unknown as GraphQLNamedType,
       );
       mockGraphQL[TypeGuard.DIRECTIVE].mockReturnValue(true);
-      jest.spyOn(Common, "hasPrintableDirective").mockReturnValueOnce(false);
+      jest.spyOn(Link, "hasPrintableDirective").mockReturnValueOnce(false);
 
       const link = Link.toLink(type, entityName, undefined, {
         ...DEFAULT_OPTIONS,
@@ -606,7 +609,7 @@ describe("link", () => {
         name: entityName,
       });
 
-      jest.spyOn(Common, "hasPrintableDirective").mockReturnValue(true);
+      jest.spyOn(Link, "hasPrintableDirective").mockReturnValue(true);
 
       mockGraphQL.getNamedType.mockReturnValue(
         entityName as unknown as GraphQLNamedType,
@@ -686,4 +689,186 @@ describe("link", () => {
       );
     });
   });
+
+  describe("hasPrintableDirective()", () => {
+    const noDocDirective = new GraphQLDirective({
+      name: "noDoc",
+      locations: [DirectiveLocation.ENUM],
+      astNode: {
+        kind: Kind.DIRECTIVE_DEFINITION,
+        name: { kind: Kind.NAME, value: "noDoc" },
+        repeatable: false,
+        locations: [],
+      },
+    });
+    const publicDirective = new GraphQLDirective({
+      name: "public",
+      locations: [DirectiveLocation.ENUM],
+      astNode: {
+        kind: Kind.DIRECTIVE_DEFINITION,
+        name: { kind: Kind.NAME, value: "public" },
+        repeatable: false,
+        locations: [],
+      },
+    });
+    const docDirective = new GraphQLDirective({
+      name: "doc",
+      locations: [DirectiveLocation.OBJECT],
+      astNode: {
+        kind: Kind.DIRECTIVE_DEFINITION,
+        name: { kind: Kind.NAME, value: "doc" },
+        repeatable: false,
+        locations: [],
+      },
+    });
+    const enumType = new GraphQLEnumType({
+      name: "test",
+      values: {
+        RED: { value: 0 },
+        GREEN: { value: 1 },
+        BLUE: { value: 2 },
+      },
+      astNode: {
+        kind: Kind.ENUM_TYPE_DEFINITION,
+        name: { kind: Kind.NAME, value: "test" },
+        directives: [
+          {
+            ...publicDirective.astNode,
+            kind: Kind.DIRECTIVE,
+          } as ConstDirectiveNode,
+        ],
+      },
+    });
+
+    test.each([
+      { options: undefined },
+      {
+        options: {
+          skipDocDirectives: undefined,
+          onlyDocDirectives: undefined,
+          deprecated: undefined,
+        },
+      },
+      {
+        options: {},
+      },
+    ])("return true if no option set", ({ options }) => {
+      expect.assertions(1);
+
+      expect(
+        Link.hasPrintableDirective({}, options as unknown as PrintTypeOptions),
+      ).toBeTruthy();
+    });
+
+    test("return false if type undefined", () => {
+      expect.assertions(1);
+
+      expect(Link.hasPrintableDirective(undefined, {})).toBeFalsy();
+    });
+
+    test("return false if type has skip directive", () => {
+      expect.assertions(1);
+
+      const options = {
+        skipDocDirectives: [noDocDirective],
+      } as unknown as PrintTypeOptions;
+      mockGraphQL.isDeprecated.mockReturnValue(false);
+      mockGraphQL.hasDirective.mockReturnValue(true);
+
+      expect(Link.hasPrintableDirective(enumType, options)).toBeFalsy();
+    });
+
+    test("return true if type has not skip directive", () => {
+      expect.assertions(1);
+
+      const options = {
+        skipDocDirectives: [noDocDirective],
+      } as unknown as PrintTypeOptions;
+      mockGraphQL.isDeprecated.mockReturnValue(false);
+      mockGraphQL.hasDirective.mockReturnValue(false);
+
+      expect(Link.hasPrintableDirective(enumType, options)).toBeTruthy();
+    });
+
+    test("return false if type has skip deprecated", () => {
+      expect.assertions(1);
+
+      const options = {
+        deprecated: "skip",
+      } as unknown as PrintTypeOptions;
+      mockGraphQL.isDeprecated.mockReturnValue(true);
+      mockGraphQL.hasDirective.mockReturnValue(true);
+
+      expect(Link.hasPrintableDirective(enumType, options)).toBeFalsy();
+    });
+
+    test("return true if type has not skip deprecated", () => {
+      expect.assertions(1);
+
+      const options = {
+        deprecated: "default",
+      } as unknown as PrintTypeOptions;
+      mockGraphQL.isDeprecated.mockReturnValue(true);
+      mockGraphQL.hasDirective.mockReturnValue(true);
+
+      expect(Link.hasPrintableDirective(enumType, options)).toBeTruthy();
+    });
+
+    test("return true if type has only directive", () => {
+      expect.assertions(1);
+
+      const options = {
+        onlyDocDirectives: [publicDirective],
+      } as unknown as PrintTypeOptions;
+      mockGraphQL.isDeprecated.mockReturnValue(false);
+      mockGraphQL.hasDirective.mockImplementation(
+        jest.requireActual("@graphql-markdown/graphql").hasDirective,
+      );
+
+      expect(Link.hasPrintableDirective(enumType, options)).toBeTruthy();
+    });
+
+    test("return false if type has not only directive and type is a valid location", () => {
+      expect.assertions(1);
+
+      const options = {
+        onlyDocDirectives: [noDocDirective],
+      } as unknown as PrintTypeOptions;
+      mockGraphQL.isDeprecated.mockReturnValue(false);
+      mockGraphQL.hasDirective.mockImplementation(
+        jest.requireActual("@graphql-markdown/graphql").hasDirective,
+      );
+
+      expect(Link.hasPrintableDirective(enumType, options)).toBeFalsy();
+    });
+
+    test("return true if type has not only directive and type is not a valid location", () => {
+      expect.assertions(1);
+
+      const options = {
+        onlyDocDirectives: [docDirective],
+      } as unknown as PrintTypeOptions;
+      mockGraphQL.isDeprecated.mockReturnValue(false);
+      mockGraphQL.hasDirective.mockImplementation(
+        jest.requireActual("@graphql-markdown/graphql").hasDirective,
+      );
+
+      expect(Link.hasPrintableDirective(enumType, options)).toBeTruthy();
+    });
+
+    test("return false if type has only directive and skip deprecated", () => {
+      expect.assertions(1);
+
+      const options = {
+        deprecated: "skip",
+        onlyDocDirectives: [publicDirective],
+      } as unknown as PrintTypeOptions;
+      mockGraphQL.isDeprecated.mockReturnValue(true);
+      mockGraphQL.hasDirective.mockImplementation(
+        jest.requireActual("@graphql-markdown/graphql").hasDirective,
+      );
+
+      expect(Link.hasPrintableDirective(enumType, options)).toBeFalsy();
+    });
+  });
 });
diff --git a/packages/printer-legacy/tests/unit/printer.test.ts b/packages/printer-legacy/tests/unit/printer.test.ts
index 2a128cc2..e62de390 100644
--- a/packages/printer-legacy/tests/unit/printer.test.ts
+++ b/packages/printer-legacy/tests/unit/printer.test.ts
@@ -48,6 +48,7 @@ jest.mock("../../src/example");
 import * as ExamplePrinter from "../../src/example";
 
 import * as Common from "../../src/common";
+import * as Link from "../../src/link";
 
 import { Printer } from "../../src/printer";
 import { DEFAULT_OPTIONS, TypeHierarchy } from "../../src/const/options";
@@ -409,7 +410,7 @@ describe("Printer", () => {
       ({ name, type }) => {
         expect.hasAssertions();
 
-        jest.spyOn(Common, "hasPrintableDirective").mockReturnValue(true);
+        jest.spyOn(Link, "hasPrintableDirective").mockReturnValue(true);
 
         const spies = methods.map((method) => {
           return jest.spyOn(Printer, method).mockReturnValue("");
@@ -441,7 +442,7 @@ describe("Printer", () => {
 
     test("returns undefined if type has no printable directive", () => {
       expect.hasAssertions();
-      jest.spyOn(Common, "hasPrintableDirective").mockReturnValueOnce(false);
+      jest.spyOn(Link, "hasPrintableDirective").mockReturnValueOnce(false);
       const printedType = Printer.printType("any", null);
 
       expect(printedType).toBeUndefined();