@graphcommerce/graphql-codegen-markdown-docs 11.0.0-canary.66 → 11.0.0-canary.69

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,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 11.0.0-canary.69
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2732](https://github.com/graphcommerce-org/graphcommerce/pull/2732) [`6c45ee6`](https://github.com/graphcommerce-org/graphcommerce/commit/6c45ee647a4e656924a185b4eb985eb036b9d9c8) - Changed the generated configuration docs for a field with a default value. The docs show its default without "(required)", between the other optional fields. ([@bramvanderholst](https://github.com/bramvanderholst))
8
+
9
+ ## 11.0.0-canary.68
10
+
11
+ ## 11.0.0-canary.67
12
+
3
13
  ## 11.0.0-canary.66
4
14
 
5
15
  ## 11.0.0-canary.65
package/dist/index.js CHANGED
@@ -57,17 +57,21 @@ config) => {
57
57
  },
58
58
  InputValueDefinition: {
59
59
  leave: (node) => {
60
- const defaultValue = node.defaultValue ? ` = \`${node.defaultValue}\`` : '';
61
- return `${node.name}: ${node.type}${defaultValue}${descriptionText(node)}`;
60
+ if (!node.defaultValue)
61
+ return `${node.name}: ${node.type}${descriptionText(node)}`;
62
+ const type = node.type.replace(' (required)', '');
63
+ return `${node.name}: ${type} = \`${node.defaultValue}\`${descriptionText(node)}`;
62
64
  },
63
65
  },
64
66
  InputObjectTypeDefinition: {
65
67
  enter: (node) => ({
66
68
  ...node,
67
69
  // Move required fields to the top.
68
- fields: [...(node.fields ?? [])].sort((a, b) =>
69
- // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
70
- a.type.kind === 'NonNullType' && b.type.kind !== 'NonNullType' ? -1 : 1),
70
+ fields: [...(node.fields ?? [])].sort((a, b) => a.type.kind === 'NonNullType' &&
71
+ !a.defaultValue &&
72
+ (b.type.kind !== 'NonNullType' || b.defaultValue)
73
+ ? -1
74
+ : 1),
71
75
  }),
72
76
  leave: (node) => {
73
77
  const text = descriptionText(node);
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": "11.0.0-canary.66",
5
+ "version": "11.0.0-canary.69",
6
6
  "sideEffects": false,
7
7
  "type": "commonjs",
8
8
  "exports": {
@@ -37,8 +37,8 @@
37
37
  "typescript": "6.0.3"
38
38
  },
39
39
  "peerDependencies": {
40
- "@graphcommerce/eslint-config-pwa": "^11.0.0-canary.66",
41
- "@graphcommerce/prettier-config-pwa": "^11.0.0-canary.66",
42
- "@graphcommerce/typescript-config-pwa": "^11.0.0-canary.66"
40
+ "@graphcommerce/eslint-config-pwa": "^11.0.0-canary.69",
41
+ "@graphcommerce/prettier-config-pwa": "^11.0.0-canary.69",
42
+ "@graphcommerce/typescript-config-pwa": "^11.0.0-canary.69"
43
43
  }
44
44
  }
package/src/index.ts CHANGED
@@ -65,8 +65,9 @@ export const plugin: PluginFunction<MarkdownDocsPluginConfig, Types.ComplexPlugi
65
65
  },
66
66
  InputValueDefinition: {
67
67
  leave: (node) => {
68
- const defaultValue = node.defaultValue ? ` = \`${node.defaultValue}\`` : ''
69
- return `${node.name}: ${node.type}${defaultValue}${descriptionText(node)}`
68
+ if (!node.defaultValue) return `${node.name}: ${node.type}${descriptionText(node)}`
69
+ const type = node.type.replace(' (required)', '')
70
+ return `${node.name}: ${type} = \`${node.defaultValue}\`${descriptionText(node)}`
70
71
  },
71
72
  },
72
73
  InputObjectTypeDefinition: {
@@ -74,8 +75,11 @@ export const plugin: PluginFunction<MarkdownDocsPluginConfig, Types.ComplexPlugi
74
75
  ...node,
75
76
  // Move required fields to the top.
76
77
  fields: [...(node.fields ?? [])].sort((a, b) =>
77
- // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
78
- a.type.kind === 'NonNullType' && b.type.kind !== 'NonNullType' ? -1 : 1,
78
+ a.type.kind === 'NonNullType' &&
79
+ !a.defaultValue &&
80
+ (b.type.kind !== 'NonNullType' || b.defaultValue)
81
+ ? -1
82
+ : 1,
79
83
  ),
80
84
  }),
81
85
  leave: (node) => {