@graphcommerce/graphql-codegen-markdown-docs 7.1.0-canary.9 → 8.0.0-canary.100

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/CHANGELOG.md CHANGED
@@ -1,5 +1,179 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.0.0-canary.100
4
+
5
+ ## 8.0.0-canary.99
6
+
7
+ ## 8.0.0-canary.98
8
+
9
+ ## 8.0.0-canary.97
10
+
11
+ ## 8.0.0-canary.96
12
+
13
+ ## 8.0.0-canary.95
14
+
15
+ ## 8.0.0-canary.94
16
+
17
+ ## 8.0.0-canary.93
18
+
19
+ ## 8.0.0-canary.92
20
+
21
+ ## 8.0.0-canary.91
22
+
23
+ ## 8.0.0-canary.90
24
+
25
+ ## 8.0.0-canary.89
26
+
27
+ ## 8.0.0-canary.88
28
+
29
+ ## 8.0.0-canary.87
30
+
31
+ ## 8.0.0-canary.86
32
+
33
+ ## 8.0.0-canary.85
34
+
35
+ ## 8.0.0-canary.84
36
+
37
+ ## 8.0.0-canary.83
38
+
39
+ ## 8.0.0-canary.82
40
+
41
+ ## 8.0.0-canary.81
42
+
43
+ ## 8.0.0-canary.80
44
+
45
+ ## 8.0.0-canary.79
46
+
47
+ ## 8.0.0-canary.78
48
+
49
+ ## 8.0.0-canary.77
50
+
51
+ ## 8.0.0-canary.76
52
+
53
+ ## 8.0.0-canary.75
54
+
55
+ ## 8.0.0-canary.74
56
+
57
+ ## 8.0.0-canary.73
58
+
59
+ ## 8.0.0-canary.72
60
+
61
+ ## 8.0.0-canary.71
62
+
63
+ ## 8.0.0-canary.70
64
+
65
+ ## 8.0.0-canary.69
66
+
67
+ ## 7.1.0-canary.68
68
+
69
+ ## 7.1.0-canary.67
70
+
71
+ ## 7.1.0-canary.66
72
+
73
+ ## 7.1.0-canary.65
74
+
75
+ ## 7.1.0-canary.64
76
+
77
+ ## 7.1.0-canary.63
78
+
79
+ ## 7.1.0-canary.62
80
+
81
+ ## 7.1.0-canary.61
82
+
83
+ ## 7.1.0-canary.60
84
+
85
+ ## 7.1.0-canary.59
86
+
87
+ ## 7.1.0-canary.58
88
+
89
+ ## 7.1.0-canary.57
90
+
91
+ ## 7.1.0-canary.56
92
+
93
+ ## 7.1.0-canary.55
94
+
95
+ ## 7.1.0-canary.54
96
+
97
+ ## 7.1.0-canary.53
98
+
99
+ ## 7.1.0-canary.52
100
+
101
+ ## 7.1.0-canary.51
102
+
103
+ ## 7.1.0-canary.50
104
+
105
+ ## 7.1.0-canary.49
106
+
107
+ ## 7.1.0-canary.48
108
+
109
+ ## 7.1.0-canary.47
110
+
111
+ ## 7.1.0-canary.46
112
+
113
+ ## 7.1.0-canary.45
114
+
115
+ ### Patch Changes
116
+
117
+ - [#2077](https://github.com/graphcommerce-org/graphcommerce/pull/2077) [`2e46389ed`](https://github.com/graphcommerce-org/graphcommerce/commit/2e46389edcd506c490cd7273be384e5c42df4a9e) - Render framework/config.md more nicely, so that we follow a more typescript-esque style, inline enums. ([@bramvanderholst](https://github.com/bramvanderholst))
118
+
119
+ ## 7.1.0-canary.38
120
+
121
+ ## 7.1.0-canary.37
122
+
123
+ ## 7.1.0-canary.36
124
+
125
+ ## 7.1.0-canary.35
126
+
127
+ ## 7.1.0-canary.34
128
+
129
+ ## 7.1.0-canary.33
130
+
131
+ ## 7.1.0-canary.32
132
+
133
+ ## 7.1.0-canary.31
134
+
135
+ ## 7.1.0-canary.30
136
+
137
+ ## 7.1.0-canary.29
138
+
139
+ ## 7.1.0-canary.28
140
+
141
+ ## 7.1.0-canary.27
142
+
143
+ ## 7.1.0-canary.26
144
+
145
+ ## 7.1.0-canary.25
146
+
147
+ ## 7.1.0-canary.24
148
+
149
+ ## 7.1.0-canary.23
150
+
151
+ ## 7.1.0-canary.22
152
+
153
+ ## 7.1.0-canary.21
154
+
155
+ ## 7.1.0-canary.20
156
+
157
+ ## 7.1.0-canary.19
158
+
159
+ ## 7.1.0-canary.18
160
+
161
+ ## 7.1.0-canary.17
162
+
163
+ ## 7.1.0-canary.16
164
+
165
+ ## 7.1.0-canary.15
166
+
167
+ ## 7.1.0-canary.14
168
+
169
+ ## 7.1.0-canary.13
170
+
171
+ ## 7.1.0-canary.12
172
+
173
+ ## 7.1.0-canary.11
174
+
175
+ ## 7.1.0-canary.10
176
+
3
177
  ## 7.1.0-canary.9
4
178
 
5
179
  ## 7.1.0-canary.8
package/dist/index.js CHANGED
@@ -17,8 +17,14 @@ config) => {
17
17
  }
18
18
  return node.description ? `\n\n${node.description}` : '';
19
19
  };
20
- const possibleScalars = ['Boolean', 'String', 'Int', 'Float', 'ID'];
21
- const content = (0, graphql_1.visit)(astNode, {
20
+ const possibleScalars = {
21
+ Boolean: 'boolean',
22
+ String: 'string',
23
+ Int: 'number',
24
+ Float: 'number',
25
+ ID: 'string',
26
+ };
27
+ let content = (0, graphql_1.visit)(astNode, {
22
28
  Document: {
23
29
  leave: (node) => `<!-- Automatically generated from Config.graphqls -->${node.definitions
24
30
  .filter(Boolean)
@@ -26,46 +32,62 @@ config) => {
26
32
  },
27
33
  Name: { leave: (node) => node.value },
28
34
  NamedType: {
29
- leave: (node) => possibleScalars.includes(node.name) ? node.name : `[${node.name}](#${node.name})`,
30
- },
35
+ leave: (node) => possibleScalars[node.name] ?? `[${node.name}](#${node.name})`,
36
+ }, // String, Boolean, GraphCommerceDebugConfig, etc.
31
37
  StringValue: { leave: (node) => node.value },
32
- BooleanValue: { leave: (node) => node.value },
33
- EnumValue: { leave: (node) => node.value },
38
+ BooleanValue: {
39
+ leave: (node) => (node.value ? 'true' : 'false'),
40
+ },
41
+ EnumValue: { leave: (node) => `'${node.value}'` },
34
42
  IntValue: { leave: (node) => node.value },
43
+ ObjectValue: {
44
+ leave: (node) => {
45
+ const fields = node.fields.join(', ') ?? '';
46
+ return `{ ${fields} }`;
47
+ },
48
+ },
35
49
  FloatValue: { leave: (node) => node.value },
36
- ListType: { leave: (node) => `[${node.type}]` },
50
+ ListType: {
51
+ leave: (node) => `${node.type.replace(' (required)', '')}[]`,
52
+ },
53
+ ObjectField: { leave: (node) => `${node.name}: ${node.value}` },
37
54
  NonNullType: {
38
- leave: (node) => `${node.type}!`,
55
+ leave: (node) => `${node.type} (required)`,
39
56
  },
40
57
  InputValueDefinition: {
41
58
  leave: (node) => {
42
- const defaultValue = node.defaultValue ? ` (default: ${node.defaultValue})` : '';
43
- return `\`${node.name}: ${node.type}${defaultValue}\`${descriptionText(node)}`;
59
+ const defaultValue = node.defaultValue ? ` = ${node.defaultValue}` : '';
60
+ return `${node.name}: ${node.type}${defaultValue}${descriptionText(node)}`;
44
61
  },
45
62
  },
46
63
  InputObjectTypeDefinition: {
47
64
  enter: (node) => ({
48
65
  ...node,
49
66
  // Move required fields to the top.
50
- fields: [...(node.fields ?? [])].sort((a, b) => a.type.kind === 'NonNullType' && b.type.kind !== 'NonNullType' ? -1 : 1),
67
+ fields: [...(node.fields ?? [])].sort((a, b) =>
68
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
69
+ a.type.kind === 'NonNullType' && b.type.kind !== 'NonNullType' ? -1 : 1),
51
70
  }),
52
71
  leave: (node) => {
53
- const title = descriptionText(node).trimStart().startsWith('#')
54
- ? `${descriptionText(node).trimStart()}\n\n### ${node.name}`
55
- : `### ${node.name}${descriptionText(node)}`;
72
+ const text = descriptionText(node);
73
+ const title = text.trimStart().startsWith('#')
74
+ ? `${text.trimStart()}\n\n### ${node.name}`
75
+ : `### ${node.name}${text}`;
56
76
  return `\n${title}\n${node.fields?.map((f) => `\n#### ${f}`).join('\n')}`;
57
77
  },
58
78
  },
59
- EnumValueDefinition: {
60
- leave: (node) => `${node.name} # ${node.description}`,
61
- },
79
+ EnumValueDefinition: { leave: (node) => node.name },
62
80
  EnumTypeDefinition: {
63
81
  leave: (node) => {
64
- enumStings.set(node.name, node.values?.join('\n') || '');
82
+ if (node.values)
83
+ enumStings.set(node.name, node.values.map((v) => `'${v.trim()}'`).join(' | '));
65
84
  return '';
66
85
  },
67
86
  },
68
87
  });
88
+ enumStings.forEach((value, key) => {
89
+ content = content.replaceAll(`[${key}](#${key})`, value);
90
+ });
69
91
  return { content };
70
92
  };
71
93
  exports.plugin = plugin;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/graphql-codegen-markdown-docs",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "7.1.0-canary.9",
5
+ "version": "8.0.0-canary.100",
6
6
  "sideEffects": false,
7
7
  "type": "commonjs",
8
8
  "main": "dist/index.js",
@@ -20,20 +20,18 @@
20
20
  "project": "./tsconfig.json"
21
21
  }
22
22
  },
23
- "devDependencies": {
24
- "@graphcommerce/eslint-config-pwa": "7.1.0-canary.9",
25
- "@graphcommerce/prettier-config-pwa": "7.1.0-canary.9",
26
- "@graphcommerce/typescript-config-pwa": "7.1.0-canary.9"
27
- },
28
23
  "dependencies": {
29
- "@graphql-codegen/add": "5.0.0",
30
- "@graphql-codegen/plugin-helpers": "5.0.1",
31
- "@graphql-codegen/visitor-plugin-common": "4.0.1",
32
- "@graphql-tools/utils": "^10.0.1",
33
- "@types/parse-filepath": "^1.0.0",
24
+ "@graphql-codegen/add": "5.0.1",
25
+ "@graphql-codegen/plugin-helpers": "5.0.2",
26
+ "@graphql-codegen/visitor-plugin-common": "4.1.0",
27
+ "@graphql-tools/utils": "^10.0.12",
28
+ "@types/parse-filepath": "^1.0.2",
34
29
  "parse-filepath": "^1.0.2"
35
30
  },
36
31
  "peerDependencies": {
32
+ "@graphcommerce/eslint-config-pwa": "^8.0.0-canary.100",
33
+ "@graphcommerce/prettier-config-pwa": "^8.0.0-canary.100",
34
+ "@graphcommerce/typescript-config-pwa": "^8.0.0-canary.100",
37
35
  "graphql": "^16.7.1"
38
36
  }
39
37
  }
package/src/index.ts CHANGED
@@ -25,9 +25,15 @@ export const plugin: PluginFunction<MarkdownDocsPluginConfig, Types.ComplexPlugi
25
25
  return node.description ? `\n\n${node.description}` : ''
26
26
  }
27
27
 
28
- const possibleScalars = ['Boolean', 'String', 'Int', 'Float', 'ID']
28
+ const possibleScalars: Record<string, string> = {
29
+ Boolean: 'boolean',
30
+ String: 'string',
31
+ Int: 'number',
32
+ Float: 'number',
33
+ ID: 'string',
34
+ }
29
35
 
30
- const content = visit<string>(astNode, {
36
+ let content = visit<string>(astNode, {
31
37
  Document: {
32
38
  leave: (node) =>
33
39
  `<!-- Automatically generated from Config.graphqls -->${node.definitions
@@ -36,22 +42,32 @@ export const plugin: PluginFunction<MarkdownDocsPluginConfig, Types.ComplexPlugi
36
42
  },
37
43
  Name: { leave: (node) => node.value },
38
44
  NamedType: {
39
- leave: (node) =>
40
- possibleScalars.includes(node.name) ? node.name : `[${node.name}](#${node.name})`,
45
+ leave: (node) => possibleScalars[node.name] ?? `[${node.name}](#${node.name})`,
41
46
  }, // String, Boolean, GraphCommerceDebugConfig, etc.
42
47
  StringValue: { leave: (node) => node.value },
43
- BooleanValue: { leave: (node) => node.value },
44
- EnumValue: { leave: (node) => node.value },
48
+ BooleanValue: {
49
+ leave: (node) => (node.value ? 'true' : 'false'),
50
+ },
51
+ EnumValue: { leave: (node) => `'${node.value}'` },
45
52
  IntValue: { leave: (node) => node.value },
53
+ ObjectValue: {
54
+ leave: (node) => {
55
+ const fields = node.fields.join(', ') ?? ''
56
+ return `{ ${fields} }`
57
+ },
58
+ },
46
59
  FloatValue: { leave: (node) => node.value },
47
- ListType: { leave: (node) => `[${node.type}]` },
60
+ ListType: {
61
+ leave: (node) => `${node.type.replace(' (required)', '')}[]`,
62
+ },
63
+ ObjectField: { leave: (node) => `${node.name}: ${node.value}` },
48
64
  NonNullType: {
49
- leave: (node) => `${node.type}!`,
65
+ leave: (node) => `${node.type} (required)`,
50
66
  },
51
67
  InputValueDefinition: {
52
68
  leave: (node) => {
53
- const defaultValue = node.defaultValue ? ` (default: ${node.defaultValue})` : ''
54
- return `\`${node.name}: ${node.type}${defaultValue}\`${descriptionText(node)}`
69
+ const defaultValue = node.defaultValue ? ` = ${node.defaultValue}` : ''
70
+ return `${node.name}: ${node.type}${defaultValue}${descriptionText(node)}`
55
71
  },
56
72
  },
57
73
  InputObjectTypeDefinition: {
@@ -59,27 +75,32 @@ export const plugin: PluginFunction<MarkdownDocsPluginConfig, Types.ComplexPlugi
59
75
  ...node,
60
76
  // Move required fields to the top.
61
77
  fields: [...(node.fields ?? [])].sort((a, b) =>
78
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
62
79
  a.type.kind === 'NonNullType' && b.type.kind !== 'NonNullType' ? -1 : 1,
63
80
  ),
64
81
  }),
65
82
  leave: (node) => {
66
- const title = descriptionText(node).trimStart().startsWith('#')
67
- ? `${descriptionText(node).trimStart()}\n\n### ${node.name}`
68
- : `### ${node.name}${descriptionText(node)}`
83
+ const text = descriptionText(node)
84
+ const title = text.trimStart().startsWith('#')
85
+ ? `${text.trimStart()}\n\n### ${node.name}`
86
+ : `### ${node.name}${text}`
69
87
 
70
88
  return `\n${title}\n${node.fields?.map((f) => `\n#### ${f}`).join('\n')}`
71
89
  },
72
90
  },
73
- EnumValueDefinition: {
74
- leave: (node) => `${node.name} # ${node.description}`,
75
- },
91
+ EnumValueDefinition: { leave: (node) => node.name },
76
92
  EnumTypeDefinition: {
77
93
  leave: (node) => {
78
- enumStings.set(node.name, node.values?.join('\n') || '')
94
+ if (node.values)
95
+ enumStings.set(node.name, node.values.map((v) => `'${v.trim()}'`).join(' | '))
79
96
  return ''
80
97
  },
81
98
  },
82
99
  })
83
100
 
101
+ enumStings.forEach((value, key) => {
102
+ content = content.replaceAll(`[${key}](#${key})`, value)
103
+ })
104
+
84
105
  return { content }
85
106
  }