@constructive-io/graphql-query 3.2.4 → 3.3.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.
Files changed (88) hide show
  1. package/README.md +411 -65
  2. package/ast.d.ts +4 -4
  3. package/ast.js +24 -9
  4. package/client/error.d.ts +95 -0
  5. package/client/error.js +277 -0
  6. package/client/execute.d.ts +57 -0
  7. package/client/execute.js +124 -0
  8. package/client/index.d.ts +8 -0
  9. package/client/index.js +20 -0
  10. package/client/typed-document.d.ts +31 -0
  11. package/client/typed-document.js +44 -0
  12. package/custom-ast.d.ts +22 -8
  13. package/custom-ast.js +16 -1
  14. package/esm/ast.js +22 -7
  15. package/esm/client/error.js +271 -0
  16. package/esm/client/execute.js +120 -0
  17. package/esm/client/index.js +8 -0
  18. package/esm/client/typed-document.js +40 -0
  19. package/esm/custom-ast.js +16 -1
  20. package/esm/generators/field-selector.js +381 -0
  21. package/esm/generators/index.js +13 -0
  22. package/esm/generators/mutations.js +200 -0
  23. package/esm/generators/naming-helpers.js +154 -0
  24. package/esm/generators/select.js +661 -0
  25. package/esm/index.js +30 -0
  26. package/esm/introspect/index.js +9 -0
  27. package/esm/introspect/infer-tables.js +697 -0
  28. package/esm/introspect/schema-query.js +120 -0
  29. package/esm/introspect/transform-schema.js +271 -0
  30. package/esm/introspect/transform.js +38 -0
  31. package/esm/meta-object/convert.js +3 -0
  32. package/esm/meta-object/format.json +11 -41
  33. package/esm/meta-object/validate.js +20 -4
  34. package/esm/query-builder.js +14 -18
  35. package/esm/types/index.js +18 -0
  36. package/esm/types/introspection.js +54 -0
  37. package/esm/types/mutation.js +4 -0
  38. package/esm/types/query.js +4 -0
  39. package/esm/types/schema.js +5 -0
  40. package/esm/types/selection.js +4 -0
  41. package/esm/utils.js +69 -0
  42. package/generators/field-selector.d.ts +30 -0
  43. package/generators/field-selector.js +387 -0
  44. package/generators/index.d.ts +9 -0
  45. package/generators/index.js +42 -0
  46. package/generators/mutations.d.ts +30 -0
  47. package/generators/mutations.js +238 -0
  48. package/generators/naming-helpers.d.ts +48 -0
  49. package/generators/naming-helpers.js +169 -0
  50. package/generators/select.d.ts +39 -0
  51. package/generators/select.js +705 -0
  52. package/index.d.ts +19 -0
  53. package/index.js +34 -1
  54. package/introspect/index.d.ts +9 -0
  55. package/introspect/index.js +25 -0
  56. package/introspect/infer-tables.d.ts +42 -0
  57. package/introspect/infer-tables.js +700 -0
  58. package/introspect/schema-query.d.ts +20 -0
  59. package/introspect/schema-query.js +123 -0
  60. package/introspect/transform-schema.d.ts +86 -0
  61. package/introspect/transform-schema.js +281 -0
  62. package/introspect/transform.d.ts +20 -0
  63. package/introspect/transform.js +43 -0
  64. package/meta-object/convert.d.ts +3 -0
  65. package/meta-object/convert.js +3 -0
  66. package/meta-object/format.json +11 -41
  67. package/meta-object/validate.d.ts +8 -3
  68. package/meta-object/validate.js +20 -4
  69. package/package.json +4 -3
  70. package/query-builder.d.ts +11 -12
  71. package/query-builder.js +25 -29
  72. package/{types.d.ts → types/core.d.ts} +25 -18
  73. package/types/index.d.ts +12 -0
  74. package/types/index.js +34 -0
  75. package/types/introspection.d.ts +121 -0
  76. package/types/introspection.js +62 -0
  77. package/types/mutation.d.ts +45 -0
  78. package/types/mutation.js +5 -0
  79. package/types/query.d.ts +91 -0
  80. package/types/query.js +5 -0
  81. package/types/schema.d.ts +265 -0
  82. package/types/schema.js +6 -0
  83. package/types/selection.d.ts +43 -0
  84. package/types/selection.js +5 -0
  85. package/utils.d.ts +17 -0
  86. package/utils.js +72 -0
  87. /package/esm/{types.js → types/core.js} +0 -0
  88. /package/{types.js → types/core.js} +0 -0
package/utils.js ADDED
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * Utility functions for GraphQL query generation
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.stripSmartComments = stripSmartComments;
7
+ /**
8
+ * PostGraphile boilerplate description prefixes that should be suppressed
9
+ */
10
+ const POSTGRAPHILE_BOILERPLATE = [
11
+ 'The exclusive input argument for this mutation.',
12
+ 'An arbitrary string value with no semantic meaning.',
13
+ 'The exact same `clientMutationId` that was provided in the mutation input,',
14
+ 'The output of our',
15
+ 'All input for the',
16
+ 'A cursor for use in pagination.',
17
+ 'An edge for our',
18
+ 'Information to aid in pagination.',
19
+ 'Reads and enables pagination through a set of',
20
+ 'A list of edges which contains the',
21
+ 'The count of *all* `',
22
+ 'A list of `',
23
+ 'Our root query field',
24
+ 'Reads a single',
25
+ 'The root query type',
26
+ 'The root mutation type',
27
+ ];
28
+ /**
29
+ * Check if a description is generic PostGraphile boilerplate that should be suppressed.
30
+ */
31
+ function isBoilerplateDescription(description) {
32
+ const trimmed = description.trim();
33
+ return POSTGRAPHILE_BOILERPLATE.some((bp) => trimmed.startsWith(bp));
34
+ }
35
+ /**
36
+ * Strip PostGraphile smart comments and boilerplate from a description string.
37
+ *
38
+ * Smart comments are lines starting with `@` (e.g., `@omit`, `@name newName`).
39
+ * Boilerplate descriptions are generic PostGraphile-generated text that repeats
40
+ * on every mutation input, clientMutationId field, etc.
41
+ *
42
+ * This returns only the meaningful human-readable portion of the comment,
43
+ * or undefined if the result is empty or boilerplate.
44
+ *
45
+ * @param description - Raw description from GraphQL introspection
46
+ * @returns Cleaned description, or undefined if empty/boilerplate
47
+ */
48
+ function stripSmartComments(description, enabled = true) {
49
+ if (!enabled)
50
+ return undefined;
51
+ if (!description)
52
+ return undefined;
53
+ // Check if entire description is boilerplate
54
+ if (isBoilerplateDescription(description))
55
+ return undefined;
56
+ const lines = description.split('\n');
57
+ const cleanLines = [];
58
+ for (const line of lines) {
59
+ const trimmed = line.trim();
60
+ // Skip lines that start with @ (smart comment directives)
61
+ if (trimmed.startsWith('@'))
62
+ continue;
63
+ cleanLines.push(line);
64
+ }
65
+ const result = cleanLines.join('\n').trim();
66
+ if (result.length === 0)
67
+ return undefined;
68
+ // Re-check after stripping smart comments
69
+ if (isBoilerplateDescription(result))
70
+ return undefined;
71
+ return result;
72
+ }
File without changes
File without changes