@graphql-markdown/core 1.8.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/config.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CliOptions, ConfigDocOptions, ConfigOptions, ConfigPrintTypeOptions, CustomDirective, DeprecatedCliOptions, DeprecatedConfigDocOptions, DirectiveName, GroupByDirectiveOptions, LoaderOption, Maybe, Options, TypeDiffMethod } from "@graphql-markdown/types";
1
+ import type { CliOptions, ConfigDocOptions, ConfigOptions, ConfigPrintTypeOptions, CustomDirective, DeprecatedCliOptions, DeprecatedConfigDocOptions, DirectiveName, GroupByDirectiveOptions, Maybe, Options, TypeDiffMethod } from "@graphql-markdown/types";
2
2
  export declare enum DiffMethod {
3
3
  NONE = "NONE",
4
4
  FORCE = "FORCE"
@@ -11,12 +11,7 @@ export declare enum DeprecatedOption {
11
11
  export declare const DOCS_URL: "https://graphql-markdown.github.io/docs";
12
12
  export declare const PACKAGE_NAME: "@graphql-markdown/docusaurus";
13
13
  export declare const ASSET_HOMEPAGE_LOCATION: string;
14
- export declare const DEFAULT_OPTIONS: Required<Omit<ConfigOptions, "customDirective" | "groupByDirective" | "loaders" | "metatags">> & {
15
- customDirective: Maybe<CustomDirective>;
16
- groupByDirective: Maybe<GroupByDirectiveOptions>;
17
- loaders: Maybe<LoaderOption>;
18
- metatags: Record<string, string>[];
19
- };
14
+ export declare const DEFAULT_OPTIONS: Readonly<Pick<ConfigOptions, "customDirective" | "groupByDirective" | "loaders"> & Required<Omit<ConfigOptions, "customDirective" | "groupByDirective" | "loaders">>>;
20
15
  export declare const getDocDirective: (name: Maybe<DirectiveName>) => DirectiveName;
21
16
  export declare const getOnlyDocDirectives: (cliOpts: Maybe<CliOptions>, configFileOpts: Maybe<Pick<ConfigOptions, "onlyDocDirective">>) => DirectiveName[];
22
17
  export declare const getSkipDocDirectives: (cliOpts: Maybe<CliOptions>, configFileOpts: Maybe<Pick<ConfigOptions, "printTypeOptions" | "skipDocDirective">>) => DirectiveName[];
package/dist/config.js CHANGED
@@ -38,9 +38,11 @@ exports.DEFAULT_OPTIONS = {
38
38
  printTypeOptions: {
39
39
  codeSection: true,
40
40
  deprecated: DeprecatedOption.DEFAULT,
41
+ exampleSection: false,
41
42
  parentTypePrefix: true,
42
43
  relatedTypeSection: true,
43
44
  typeBadges: true,
45
+ useApiGroup: true,
44
46
  },
45
47
  rootPath: "./docs",
46
48
  schema: "./schema.graphql",
@@ -159,12 +161,16 @@ const getPrintTypeOptions = (cliOpts, configOptions) => {
159
161
  deprecated: (cliOpts?.deprecated ??
160
162
  configOptions?.deprecated ??
161
163
  exports.DEFAULT_OPTIONS.printTypeOptions.deprecated).toLocaleLowerCase(),
164
+ exampleSection: (!cliOpts?.noExample && configOptions?.exampleSection) ??
165
+ exports.DEFAULT_OPTIONS.printTypeOptions.exampleSection,
162
166
  parentTypePrefix: (!cliOpts?.noParentType && configOptions?.parentTypePrefix) ??
163
167
  exports.DEFAULT_OPTIONS.printTypeOptions.parentTypePrefix,
164
168
  relatedTypeSection: (!cliOpts?.noRelatedType && configOptions?.relatedTypeSection) ??
165
169
  exports.DEFAULT_OPTIONS.printTypeOptions.relatedTypeSection,
166
170
  typeBadges: (!cliOpts?.noTypeBadges && configOptions?.typeBadges) ??
167
171
  exports.DEFAULT_OPTIONS.printTypeOptions.typeBadges,
172
+ useApiGroup: (!cliOpts?.noApiGroup && configOptions?.useApiGroup) ??
173
+ exports.DEFAULT_OPTIONS.printTypeOptions.useApiGroup,
168
174
  };
169
175
  };
170
176
  exports.getPrintTypeOptions = getPrintTypeOptions;
package/dist/generator.js CHANGED
@@ -59,7 +59,8 @@ const generateDocFromSchema = async ({ baseURL, customDirective, diffMethod, doc
59
59
  });
60
60
  const renderer = new renderer_1.Renderer(printer, outputDir, baseURL, groups, prettify, {
61
61
  ...docOptions,
62
- deprecated: printTypeOptions.deprecated,
62
+ deprecated: printTypeOptions?.deprecated,
63
+ useApiGroup: printTypeOptions?.useApiGroup,
63
64
  });
64
65
  const pages = await Promise.all(Object.keys(rootTypes).map(async (typeName) => {
65
66
  return renderer.renderRootTypes(typeName, rootTypes[typeName]);
@@ -84,7 +84,7 @@ const loadConfiguration = async (id, options, { throwOnMissing, throwOnEmpty } =
84
84
  if (typeof projectConfig.schema === "object") {
85
85
  projectConfig.schema = Object.keys(schema)[0];
86
86
  if (typeof projectConfig.loaders !== "undefined") {
87
- projectConfig.loaders = (0, exports.setLoaderOptions)(projectConfig.loaders, Object.values(schema)[0]);
87
+ projectConfig.loaders = (0, exports.setLoaderOptions)(projectConfig.loaders ?? {}, Object.values(schema)[0]);
88
88
  }
89
89
  }
90
90
  }
@@ -1,17 +1,16 @@
1
- import type { Category, ConfigDocOptions, Maybe, Printer, SchemaEntitiesGroupMap, SchemaEntity, TypeDeprecatedOption } from "@graphql-markdown/types";
1
+ import type { Category, Maybe, Printer, RendererDocOptions, SchemaEntitiesGroupMap, SchemaEntity } from "@graphql-markdown/types";
2
2
  export declare class Renderer {
3
3
  group: Maybe<SchemaEntitiesGroupMap>;
4
4
  outputDir: string;
5
5
  baseURL: string;
6
6
  prettify: boolean;
7
- options: Maybe<ConfigDocOptions & {
8
- deprecated: TypeDeprecatedOption;
9
- }>;
7
+ options: Maybe<RendererDocOptions>;
10
8
  private readonly printer;
11
- constructor(printer: Printer, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<ConfigDocOptions & {
12
- deprecated: TypeDeprecatedOption;
13
- }>);
14
- generateCategoryMetafile(category: string, dirPath: string, sidebarPosition?: number, styleClass?: string): Promise<void>;
9
+ constructor(printer: Printer, outputDir: string, baseURL: string, group: Maybe<SchemaEntitiesGroupMap>, prettify: boolean, docOptions: Maybe<RendererDocOptions>);
10
+ generateCategoryMetafile(category: string, dirPath: string, sidebarPosition?: number, styleClass?: string, options?: {
11
+ collapsible: boolean;
12
+ collapsed: boolean;
13
+ }): Promise<void>;
15
14
  generateCategoryMetafileType(type: unknown, name: string, rootTypeName: SchemaEntity): Promise<string>;
16
15
  renderRootTypes(rootTypeName: SchemaEntity, type: unknown): Promise<Maybe<Maybe<Category>[]>>;
17
16
  renderTypeEntities(dirPath: string, name: string, type: unknown): Promise<Maybe<Category>>;
package/dist/renderer.js CHANGED
@@ -27,7 +27,10 @@ class Renderer {
27
27
  this.prettify = prettify;
28
28
  this.options = docOptions;
29
29
  }
30
- async generateCategoryMetafile(category, dirPath, sidebarPosition = SidebarPosition.FIRST, styleClass) {
30
+ async generateCategoryMetafile(category, dirPath, sidebarPosition, styleClass, options = {
31
+ collapsible: true,
32
+ collapsed: true,
33
+ }) {
31
34
  const filePath = (0, node_path_1.join)(dirPath, CATEGORY_YAML);
32
35
  if (await (0, utils_1.fileExists)(filePath)) {
33
36
  return;
@@ -38,13 +41,19 @@ class Renderer {
38
41
  ? "null"
39
42
  : `\n type: generated-index\n title: '${label} overview'`;
40
43
  const className = typeof styleClass === "string" ? `className: ${styleClass}\n` : "";
41
- await (0, utils_1.saveFile)(filePath, `label: ${label}\nposition: ${sidebarPosition}\n${className}link: ${link}\n`);
44
+ const position = typeof sidebarPosition === "number"
45
+ ? sidebarPosition
46
+ : SidebarPosition.FIRST;
47
+ await (0, utils_1.saveFile)(filePath, `label: ${label}\nposition: ${position}\n${className}link: ${link}\ncollapsible: ${options.collapsible}\ncollapsed: ${options.collapsed}\n`);
42
48
  }
43
49
  async generateCategoryMetafileType(type, name, rootTypeName) {
44
50
  let dirPath = this.outputDir;
45
- if (this.options &&
46
- this.options.deprecated === "group" &&
47
- (0, graphql_1.isDeprecated)(type)) {
51
+ if (this.options?.useApiGroup === true) {
52
+ const typeCat = (0, graphql_1.isApiType)(type) ? "api" : "types";
53
+ dirPath = (0, node_path_1.join)(dirPath, (0, utils_1.slugify)(typeCat));
54
+ await this.generateCategoryMetafile(typeCat, dirPath, undefined, "graphql-markdown-api-section", { collapsible: false, collapsed: false });
55
+ }
56
+ if (this.options?.deprecated === "group" && (0, graphql_1.isDeprecated)(type)) {
48
57
  dirPath = (0, node_path_1.join)(dirPath, (0, utils_1.slugify)("deprecated"));
49
58
  await this.generateCategoryMetafile("deprecated", dirPath, SidebarPosition.LAST, "deprecated");
50
59
  }
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.0",
8
+ "version": "1.10.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
@@ -62,18 +62,18 @@
62
62
  "clean": "rm -rf ./dist"
63
63
  },
64
64
  "dependencies": {
65
- "@graphql-markdown/graphql": "^1.0.2",
66
- "@graphql-markdown/logger": "^1.0.1",
67
- "@graphql-markdown/utils": "^1.6.2"
65
+ "@graphql-markdown/graphql": "^1.1.1",
66
+ "@graphql-markdown/logger": "^1.0.2",
67
+ "@graphql-markdown/utils": "^1.6.3"
68
68
  },
69
69
  "peerDependencies": {
70
- "@graphql-markdown/diff": "^1.1.2",
71
- "@graphql-markdown/helpers": "^1.0.2",
72
- "@graphql-markdown/printer-legacy": "^1.6.0",
70
+ "@graphql-markdown/diff": "^1.1.4",
71
+ "@graphql-markdown/helpers": "^1.0.4",
72
+ "@graphql-markdown/printer-legacy": "^1.8.0",
73
73
  "graphql-config": "^5.0.3"
74
74
  },
75
75
  "devDependencies": {
76
- "@graphql-markdown/types": "^1.0.0"
76
+ "@graphql-markdown/types": "^1.3.0"
77
77
  },
78
78
  "peerDependenciesMeta": {
79
79
  "@graphql-markdown/printer-legacy": {