@constructive-io/graphql-codegen 3.2.0 → 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.
- package/README.md +25 -30
- package/cli/index.js +36 -41
- package/cli/shared.d.ts +15 -17
- package/cli/shared.js +113 -21
- package/client/error.js +31 -9
- package/client/execute.js +2 -2
- package/client/index.d.ts +3 -3
- package/client/index.js +6 -6
- package/core/ast.d.ts +1 -1
- package/core/ast.js +1 -1
- package/core/codegen/babel-ast.d.ts +1 -1
- package/core/codegen/babel-ast.js +2 -2
- package/core/codegen/barrel.d.ts +0 -6
- package/core/codegen/barrel.js +22 -19
- package/core/codegen/client.d.ts +2 -12
- package/core/codegen/client.js +7 -21
- package/core/codegen/custom-mutations.d.ts +0 -14
- package/core/codegen/custom-mutations.js +139 -88
- package/core/codegen/custom-queries.d.ts +0 -14
- package/core/codegen/custom-queries.js +483 -193
- package/core/codegen/hooks-ast.d.ts +75 -0
- package/core/codegen/hooks-ast.js +522 -0
- package/core/codegen/index.d.ts +16 -18
- package/core/codegen/index.js +42 -88
- package/core/codegen/invalidation.d.ts +1 -7
- package/core/codegen/invalidation.js +50 -16
- package/core/codegen/mutation-keys.d.ts +1 -10
- package/core/codegen/mutation-keys.js +22 -8
- package/core/codegen/mutations.d.ts +0 -13
- package/core/codegen/mutations.js +301 -366
- package/core/codegen/orm/barrel.d.ts +0 -5
- package/core/codegen/orm/barrel.js +5 -0
- package/core/codegen/orm/client-generator.d.ts +0 -5
- package/core/codegen/orm/client-generator.js +7 -2
- package/core/codegen/orm/client.js +3 -1
- package/core/codegen/orm/custom-ops-generator.d.ts +0 -6
- package/core/codegen/orm/custom-ops-generator.js +104 -51
- package/core/codegen/orm/index.d.ts +4 -4
- package/core/codegen/orm/index.js +28 -15
- package/core/codegen/orm/input-types-generator.d.ts +1 -13
- package/core/codegen/orm/input-types-generator.js +85 -23
- package/core/codegen/orm/model-generator.d.ts +0 -5
- package/core/codegen/orm/model-generator.js +309 -131
- package/core/codegen/orm/select-types.d.ts +19 -14
- package/core/codegen/queries.d.ts +0 -8
- package/core/codegen/queries.js +360 -559
- package/core/codegen/query-keys.d.ts +1 -1
- package/core/codegen/query-keys.js +37 -23
- package/core/codegen/scalars.js +3 -1
- package/core/codegen/schema-types-generator.d.ts +1 -1
- package/core/codegen/schema-types-generator.js +17 -2
- package/core/codegen/select-helpers.d.ts +19 -0
- package/core/codegen/select-helpers.js +40 -0
- package/core/codegen/selection.d.ts +4 -0
- package/core/codegen/selection.js +65 -0
- package/core/codegen/shared/index.d.ts +2 -15
- package/core/codegen/shared/index.js +17 -4
- package/core/codegen/templates/hooks-client.ts +49 -0
- package/core/codegen/templates/hooks-selection.ts +58 -0
- package/core/codegen/templates/orm-client.ts +8 -6
- package/core/codegen/templates/query-builder.ts +250 -46
- package/core/codegen/templates/select-types.ts +31 -14
- package/core/codegen/type-resolver.d.ts +1 -5
- package/core/codegen/type-resolver.js +0 -22
- package/core/codegen/types.d.ts +0 -3
- package/core/codegen/types.js +71 -14
- package/core/codegen/utils.d.ts +1 -4
- package/core/codegen/utils.js +4 -1
- package/core/config/index.d.ts +1 -1
- package/core/config/resolver.js +1 -3
- package/core/generate.js +38 -50
- package/core/index.d.ts +3 -3
- package/core/index.js +3 -4
- package/core/introspect/index.d.ts +6 -6
- package/core/introspect/index.js +5 -8
- package/core/introspect/infer-tables.d.ts +0 -14
- package/core/introspect/infer-tables.js +15 -1
- package/core/introspect/source/database.js +1 -1
- package/core/introspect/source/endpoint.d.ts +0 -6
- package/core/introspect/source/endpoint.js +7 -1
- package/core/introspect/source/index.d.ts +4 -4
- package/core/introspect/source/index.js +5 -9
- package/core/introspect/source/pgpm-module.js +3 -3
- package/core/introspect/transform-schema.d.ts +2 -2
- package/core/introspect/transform-schema.js +2 -2
- package/core/output/index.d.ts +1 -1
- package/core/output/index.js +2 -2
- package/core/output/writer.d.ts +3 -0
- package/core/output/writer.js +20 -1
- package/core/pipeline/index.d.ts +2 -2
- package/core/query-builder.d.ts +2 -2
- package/core/query-builder.js +1 -1
- package/core/watch/index.d.ts +4 -4
- package/core/watch/index.js +9 -9
- package/core/watch/orchestrator.js +5 -3
- package/esm/cli/index.js +37 -42
- package/esm/cli/shared.d.ts +15 -17
- package/esm/cli/shared.js +103 -20
- package/esm/client/error.js +31 -9
- package/esm/client/execute.js +2 -2
- package/esm/client/index.d.ts +3 -3
- package/esm/client/index.js +3 -3
- package/esm/core/ast.d.ts +1 -1
- package/esm/core/ast.js +1 -1
- package/esm/core/codegen/babel-ast.d.ts +1 -1
- package/esm/core/codegen/babel-ast.js +2 -2
- package/esm/core/codegen/barrel.d.ts +0 -6
- package/esm/core/codegen/barrel.js +23 -20
- package/esm/core/codegen/client.d.ts +2 -12
- package/esm/core/codegen/client.js +7 -21
- package/esm/core/codegen/custom-mutations.d.ts +0 -14
- package/esm/core/codegen/custom-mutations.js +141 -90
- package/esm/core/codegen/custom-queries.d.ts +0 -14
- package/esm/core/codegen/custom-queries.js +486 -196
- package/esm/core/codegen/hooks-ast.d.ts +75 -0
- package/esm/core/codegen/hooks-ast.js +424 -0
- package/esm/core/codegen/index.d.ts +16 -18
- package/esm/core/codegen/index.js +26 -71
- package/esm/core/codegen/invalidation.d.ts +1 -7
- package/esm/core/codegen/invalidation.js +51 -17
- package/esm/core/codegen/mutation-keys.d.ts +1 -10
- package/esm/core/codegen/mutation-keys.js +23 -9
- package/esm/core/codegen/mutations.d.ts +0 -13
- package/esm/core/codegen/mutations.js +302 -367
- package/esm/core/codegen/orm/barrel.d.ts +0 -5
- package/esm/core/codegen/orm/barrel.js +6 -1
- package/esm/core/codegen/orm/client-generator.d.ts +0 -5
- package/esm/core/codegen/orm/client-generator.js +7 -2
- package/esm/core/codegen/orm/client.js +3 -1
- package/esm/core/codegen/orm/custom-ops-generator.d.ts +0 -6
- package/esm/core/codegen/orm/custom-ops-generator.js +103 -50
- package/esm/core/codegen/orm/index.d.ts +4 -4
- package/esm/core/codegen/orm/index.js +25 -12
- package/esm/core/codegen/orm/input-types-generator.d.ts +1 -13
- package/esm/core/codegen/orm/input-types-generator.js +85 -23
- package/esm/core/codegen/orm/model-generator.d.ts +0 -5
- package/esm/core/codegen/orm/model-generator.js +310 -132
- package/esm/core/codegen/orm/select-types.d.ts +19 -14
- package/esm/core/codegen/queries.d.ts +0 -8
- package/esm/core/codegen/queries.js +362 -561
- package/esm/core/codegen/query-keys.d.ts +1 -1
- package/esm/core/codegen/query-keys.js +38 -24
- package/esm/core/codegen/scalars.js +3 -1
- package/esm/core/codegen/schema-types-generator.d.ts +1 -1
- package/esm/core/codegen/schema-types-generator.js +17 -2
- package/esm/core/codegen/select-helpers.d.ts +19 -0
- package/esm/core/codegen/select-helpers.js +35 -0
- package/esm/core/codegen/selection.d.ts +4 -0
- package/esm/core/codegen/selection.js +29 -0
- package/esm/core/codegen/shared/index.d.ts +2 -15
- package/esm/core/codegen/shared/index.js +16 -3
- package/esm/core/codegen/type-resolver.d.ts +1 -5
- package/esm/core/codegen/type-resolver.js +1 -22
- package/esm/core/codegen/types.d.ts +0 -3
- package/esm/core/codegen/types.js +72 -15
- package/esm/core/codegen/utils.d.ts +1 -4
- package/esm/core/codegen/utils.js +4 -1
- package/esm/core/config/index.d.ts +1 -1
- package/esm/core/config/resolver.js +2 -4
- package/esm/core/generate.js +38 -50
- package/esm/core/index.d.ts +3 -3
- package/esm/core/index.js +2 -3
- package/esm/core/introspect/index.d.ts +6 -6
- package/esm/core/introspect/index.js +3 -6
- package/esm/core/introspect/infer-tables.d.ts +0 -14
- package/esm/core/introspect/infer-tables.js +16 -2
- package/esm/core/introspect/source/database.js +2 -2
- package/esm/core/introspect/source/endpoint.d.ts +0 -6
- package/esm/core/introspect/source/endpoint.js +7 -1
- package/esm/core/introspect/source/index.d.ts +4 -4
- package/esm/core/introspect/source/index.js +6 -10
- package/esm/core/introspect/source/pgpm-module.js +3 -3
- package/esm/core/introspect/transform-schema.d.ts +2 -2
- package/esm/core/introspect/transform-schema.js +2 -2
- package/esm/core/output/index.d.ts +1 -1
- package/esm/core/output/index.js +1 -1
- package/esm/core/output/writer.d.ts +3 -0
- package/esm/core/output/writer.js +20 -1
- package/esm/core/pipeline/index.d.ts +2 -2
- package/esm/core/pipeline/index.js +2 -2
- package/esm/core/query-builder.d.ts +2 -2
- package/esm/core/query-builder.js +2 -2
- package/esm/core/watch/index.d.ts +4 -4
- package/esm/core/watch/index.js +3 -3
- package/esm/core/watch/orchestrator.js +5 -3
- package/esm/generators/index.d.ts +3 -3
- package/esm/generators/index.js +3 -3
- package/esm/generators/mutations.d.ts +1 -1
- package/esm/generators/select.d.ts +1 -1
- package/esm/index.d.ts +3 -3
- package/esm/index.js +1 -4
- package/esm/types/config.d.ts +0 -10
- package/esm/types/config.js +0 -2
- package/esm/types/index.d.ts +6 -6
- package/esm/types/index.js +1 -1
- package/generators/index.d.ts +3 -3
- package/generators/index.js +8 -8
- package/generators/mutations.d.ts +1 -1
- package/generators/select.d.ts +1 -1
- package/index.d.ts +3 -3
- package/index.js +11 -5
- package/package.json +11 -11
- package/types/config.d.ts +0 -10
- package/types/config.js +0 -2
- package/types/index.d.ts +6 -6
- package/types/index.js +2 -2
- package/core/codegen/gql-ast.d.ts +0 -41
- package/core/codegen/gql-ast.js +0 -353
- package/core/codegen/schema-gql-ast.d.ts +0 -51
- package/core/codegen/schema-gql-ast.js +0 -385
- package/core/codegen/templates/client.browser.ts +0 -271
- package/core/codegen/templates/client.node.ts +0 -337
- package/esm/core/codegen/gql-ast.d.ts +0 -41
- package/esm/core/codegen/gql-ast.js +0 -312
- package/esm/core/codegen/schema-gql-ast.d.ts +0 -51
- package/esm/core/codegen/schema-gql-ast.js +0 -343
package/README.md
CHANGED
|
@@ -661,7 +661,7 @@ Filter patterns support wildcards:
|
|
|
661
661
|
|
|
662
662
|
The CLI provides a convenient way to run code generation from the command line.
|
|
663
663
|
|
|
664
|
-
### `graphql-
|
|
664
|
+
### `graphql-codegen`
|
|
665
665
|
|
|
666
666
|
Generate React Query hooks and/or ORM client from various sources.
|
|
667
667
|
|
|
@@ -682,62 +682,57 @@ Database Options (for pgpm modes):
|
|
|
682
682
|
Generator Options:
|
|
683
683
|
--react-query Generate React Query hooks
|
|
684
684
|
--orm Generate ORM client
|
|
685
|
-
-t, --target <name> Target name in config file
|
|
686
685
|
-o, --output <dir> Output directory
|
|
686
|
+
-t, --target <name> Target name (for multi-target configs)
|
|
687
687
|
-a, --authorization <token> Authorization header value
|
|
688
688
|
--browser-compatible Generate browser-compatible code (default: true)
|
|
689
689
|
Set to false for Node.js with localhost DNS fix
|
|
690
690
|
--skip-custom-operations Only generate table CRUD operations
|
|
691
691
|
--dry-run Preview without writing files
|
|
692
|
-
--keep-db Keep ephemeral database after generation (pgpm modes)
|
|
693
692
|
-v, --verbose Show detailed output
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
--poll-interval <ms> Polling interval in milliseconds (default: 5000)
|
|
698
|
-
--debounce <ms> Debounce delay in milliseconds (default: 500)
|
|
699
|
-
--touch <path> Touch file after regeneration
|
|
700
|
-
--no-clear Don't clear console on regeneration
|
|
693
|
+
--keep-db Keep ephemeral database after generation (pgpm modes)
|
|
694
|
+
-h, --help Show help message
|
|
695
|
+
--version Show version number
|
|
701
696
|
```
|
|
702
697
|
|
|
703
698
|
Examples:
|
|
704
699
|
|
|
705
700
|
```bash
|
|
706
701
|
# Generate React Query hooks from an endpoint
|
|
707
|
-
npx graphql-
|
|
702
|
+
npx @constructive-io/graphql-codegen --endpoint https://api.example.com/graphql --output ./generated --react-query
|
|
708
703
|
|
|
709
704
|
# Generate ORM client from an endpoint
|
|
710
|
-
npx graphql-
|
|
705
|
+
npx @constructive-io/graphql-codegen --endpoint https://api.example.com/graphql --output ./generated --orm
|
|
711
706
|
|
|
712
707
|
# Generate both React Query hooks and ORM client
|
|
713
|
-
npx graphql-
|
|
708
|
+
npx @constructive-io/graphql-codegen --endpoint https://api.example.com/graphql --output ./generated --react-query --orm
|
|
714
709
|
|
|
715
|
-
# Generate from
|
|
716
|
-
npx graphql-
|
|
710
|
+
# Generate from schema file
|
|
711
|
+
npx @constructive-io/graphql-codegen --schema-file ./schema.graphql --output ./generated --react-query
|
|
717
712
|
|
|
718
|
-
# Generate
|
|
719
|
-
npx graphql-
|
|
720
|
-
```
|
|
713
|
+
# Generate from database with schemas
|
|
714
|
+
npx @constructive-io/graphql-codegen --schemas public,app_public --output ./generated --react-query
|
|
721
715
|
|
|
722
|
-
|
|
716
|
+
# Generate from database with API names
|
|
717
|
+
npx @constructive-io/graphql-codegen --api-names my_api --output ./generated --orm
|
|
723
718
|
|
|
724
|
-
|
|
719
|
+
# Use config file
|
|
720
|
+
npx @constructive-io/graphql-codegen --config ./graphql-codegen.config.ts
|
|
725
721
|
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
-f, --format <format> Config format: ts, js, json (default: ts)
|
|
729
|
-
-o, --output <path> Output path for config file
|
|
722
|
+
# Generate specific target from multi-target config
|
|
723
|
+
npx @constructive-io/graphql-codegen --config ./graphql-codegen.config.ts --target admin
|
|
730
724
|
```
|
|
731
725
|
|
|
732
|
-
###
|
|
726
|
+
### Using with Constructive CLI
|
|
733
727
|
|
|
734
|
-
|
|
728
|
+
The `@constructive-io/cli` package includes the codegen command:
|
|
735
729
|
|
|
736
730
|
```bash
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
731
|
+
# Install Constructive CLI
|
|
732
|
+
npm install -g @constructive-io/cli
|
|
733
|
+
|
|
734
|
+
# Run codegen via cnc
|
|
735
|
+
cnc codegen --endpoint http://localhost:5555/graphql --output ./codegen --react-query
|
|
741
736
|
```
|
|
742
737
|
|
|
743
738
|
## Architecture
|
package/cli/index.js
CHANGED
|
@@ -9,8 +9,8 @@ exports.options = exports.commands = void 0;
|
|
|
9
9
|
* All business logic is in the core modules.
|
|
10
10
|
*/
|
|
11
11
|
const inquirerer_1 = require("inquirerer");
|
|
12
|
-
const generate_1 = require("../core/generate");
|
|
13
12
|
const config_1 = require("../core/config");
|
|
13
|
+
const generate_1 = require("../core/generate");
|
|
14
14
|
const shared_1 = require("./shared");
|
|
15
15
|
const usage = `
|
|
16
16
|
graphql-codegen - GraphQL SDK generator for Constructive databases
|
|
@@ -33,8 +33,6 @@ Generator Options:
|
|
|
33
33
|
-o, --output <dir> Output directory
|
|
34
34
|
-t, --target <name> Target name (for multi-target configs)
|
|
35
35
|
-a, --authorization <token> Authorization header value
|
|
36
|
-
--browser-compatible Generate browser-compatible code (default: true)
|
|
37
|
-
Set to false for Node.js with localhost DNS fix
|
|
38
36
|
--dry-run Preview without writing files
|
|
39
37
|
-v, --verbose Show detailed output
|
|
40
38
|
|
|
@@ -51,9 +49,16 @@ const commands = async (argv, prompter, _options) => {
|
|
|
51
49
|
console.log(usage);
|
|
52
50
|
process.exit(0);
|
|
53
51
|
}
|
|
54
|
-
const
|
|
52
|
+
const hasSourceFlags = Boolean(argv.endpoint ||
|
|
53
|
+
argv.e ||
|
|
54
|
+
argv['schema-file'] ||
|
|
55
|
+
argv.s ||
|
|
56
|
+
argv.schemas ||
|
|
57
|
+
argv['api-names']);
|
|
58
|
+
const explicitConfigPath = (argv.config || argv.c);
|
|
59
|
+
const configPath = explicitConfigPath || (!hasSourceFlags ? (0, config_1.findConfigFile)() : undefined);
|
|
55
60
|
const targetName = (argv.target || argv.t);
|
|
56
|
-
|
|
61
|
+
let fileConfig = {};
|
|
57
62
|
if (configPath) {
|
|
58
63
|
const loaded = await (0, config_1.loadConfigFile)(configPath);
|
|
59
64
|
if (!loaded.success) {
|
|
@@ -61,20 +66,24 @@ const commands = async (argv, prompter, _options) => {
|
|
|
61
66
|
process.exit(1);
|
|
62
67
|
}
|
|
63
68
|
const config = loaded.config;
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
const isMulti = !('endpoint' in config ||
|
|
70
|
+
'schemaFile' in config ||
|
|
71
|
+
'db' in config);
|
|
66
72
|
if (isMulti) {
|
|
67
|
-
// Multi-target: simple for loop over targets
|
|
68
73
|
const targets = config;
|
|
69
74
|
const names = targetName ? [targetName] : Object.keys(targets);
|
|
70
75
|
if (targetName && !targets[targetName]) {
|
|
71
76
|
console.error('x', `Target "${targetName}" not found. Available: ${Object.keys(targets).join(', ')}`);
|
|
72
77
|
process.exit(1);
|
|
73
78
|
}
|
|
79
|
+
const cliOptions = (0, shared_1.buildDbConfig)((0, shared_1.normalizeCodegenListOptions)((0, shared_1.camelizeArgv)(argv)));
|
|
74
80
|
let hasError = false;
|
|
75
81
|
for (const name of names) {
|
|
76
82
|
console.log(`\n[${name}]`);
|
|
77
|
-
const result = await (0, generate_1.generate)(
|
|
83
|
+
const result = await (0, generate_1.generate)({
|
|
84
|
+
...targets[name],
|
|
85
|
+
...cliOptions,
|
|
86
|
+
});
|
|
78
87
|
(0, shared_1.printResult)(result);
|
|
79
88
|
if (!result.success)
|
|
80
89
|
hasError = true;
|
|
@@ -84,33 +93,14 @@ const commands = async (argv, prompter, _options) => {
|
|
|
84
93
|
process.exit(1);
|
|
85
94
|
return argv;
|
|
86
95
|
}
|
|
87
|
-
|
|
88
|
-
const result = await (0, generate_1.generate)(config);
|
|
89
|
-
(0, shared_1.printResult)(result);
|
|
90
|
-
if (!result.success)
|
|
91
|
-
process.exit(1);
|
|
92
|
-
prompter.close();
|
|
93
|
-
return argv;
|
|
96
|
+
fileConfig = config;
|
|
94
97
|
}
|
|
95
|
-
|
|
96
|
-
const answers =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} : undefined;
|
|
102
|
-
const result = await (0, generate_1.generate)({
|
|
103
|
-
endpoint: answers.endpoint,
|
|
104
|
-
schemaFile: answers.schemaFile,
|
|
105
|
-
db,
|
|
106
|
-
output: answers.output,
|
|
107
|
-
authorization: answers.authorization,
|
|
108
|
-
reactQuery: answers.reactQuery,
|
|
109
|
-
orm: answers.orm,
|
|
110
|
-
browserCompatible: answers.browserCompatible,
|
|
111
|
-
dryRun: answers.dryRun,
|
|
112
|
-
verbose: answers.verbose,
|
|
113
|
-
});
|
|
98
|
+
const seeded = (0, shared_1.seedArgvFromConfig)(argv, fileConfig);
|
|
99
|
+
const answers = (0, shared_1.hasResolvedCodegenSource)(seeded)
|
|
100
|
+
? seeded
|
|
101
|
+
: await prompter.prompt(seeded, shared_1.codegenQuestions);
|
|
102
|
+
const options = (0, shared_1.buildGenerateOptions)(answers, fileConfig);
|
|
103
|
+
const result = await (0, generate_1.generate)(options);
|
|
114
104
|
(0, shared_1.printResult)(result);
|
|
115
105
|
prompter.close();
|
|
116
106
|
return argv;
|
|
@@ -128,13 +118,18 @@ exports.options = {
|
|
|
128
118
|
a: 'authorization',
|
|
129
119
|
v: 'verbose',
|
|
130
120
|
},
|
|
131
|
-
boolean: [
|
|
132
|
-
'help', 'version', 'verbose', 'dry-run', 'react-query', 'orm', 'keep-db', 'browser-compatible',
|
|
133
|
-
],
|
|
134
121
|
string: [
|
|
135
|
-
'config',
|
|
136
|
-
'
|
|
137
|
-
'
|
|
122
|
+
'config',
|
|
123
|
+
'endpoint',
|
|
124
|
+
'schema-file',
|
|
125
|
+
'output',
|
|
126
|
+
'target',
|
|
127
|
+
'authorization',
|
|
128
|
+
'pgpm-module-path',
|
|
129
|
+
'pgpm-workspace-path',
|
|
130
|
+
'pgpm-module-name',
|
|
131
|
+
'schemas',
|
|
132
|
+
'api-names',
|
|
138
133
|
],
|
|
139
134
|
},
|
|
140
135
|
};
|
package/cli/shared.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared CLI utilities for graphql-codegen
|
|
3
|
-
*
|
|
4
|
-
* These are exported so that packages/cli can use the same questions
|
|
5
|
-
* and types, ensuring consistency between the two CLIs.
|
|
6
|
-
*/
|
|
7
1
|
import type { Question } from 'inquirerer';
|
|
8
2
|
import type { GenerateResult } from '../core/generate';
|
|
9
|
-
|
|
10
|
-
* Sanitize function that splits comma-separated strings into arrays
|
|
11
|
-
*/
|
|
3
|
+
import type { GraphQLSDKConfigTarget } from '../types/config';
|
|
12
4
|
export declare const splitCommas: (input: string | undefined) => string[] | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Interface for codegen CLI answers
|
|
15
|
-
*/
|
|
16
5
|
export interface CodegenAnswers {
|
|
17
6
|
endpoint?: string;
|
|
18
7
|
schemaFile?: string;
|
|
@@ -21,16 +10,25 @@ export interface CodegenAnswers {
|
|
|
21
10
|
apiNames?: string[];
|
|
22
11
|
reactQuery?: boolean;
|
|
23
12
|
orm?: boolean;
|
|
24
|
-
browserCompatible?: boolean;
|
|
25
13
|
authorization?: string;
|
|
26
14
|
dryRun?: boolean;
|
|
27
15
|
verbose?: boolean;
|
|
28
16
|
}
|
|
17
|
+
export declare const codegenQuestions: Question[];
|
|
18
|
+
export declare function printResult(result: GenerateResult): void;
|
|
19
|
+
export declare const camelizeArgv: (argv: Record<string, any>) => Record<string, any>;
|
|
20
|
+
export declare const hyphenateKeys: (obj: Record<string, any>) => Record<string, any>;
|
|
21
|
+
export declare function filterDefined(obj: Record<string, unknown>): Record<string, unknown>;
|
|
22
|
+
export declare function flattenDbFields(config: Record<string, unknown>): Record<string, unknown>;
|
|
23
|
+
export declare function buildDbConfig(options: Record<string, unknown>): Record<string, unknown>;
|
|
29
24
|
/**
|
|
30
|
-
*
|
|
25
|
+
* Normalizes top-level list-like CLI options to string arrays.
|
|
26
|
+
* This keeps non-interactive paths equivalent to prompt sanitize behavior.
|
|
31
27
|
*/
|
|
32
|
-
export declare
|
|
28
|
+
export declare function normalizeCodegenListOptions(options: Record<string, unknown>): Record<string, unknown>;
|
|
33
29
|
/**
|
|
34
|
-
*
|
|
30
|
+
* Returns true when source options are already available, so prompting can be skipped.
|
|
35
31
|
*/
|
|
36
|
-
export declare function
|
|
32
|
+
export declare function hasResolvedCodegenSource(options: Record<string, unknown>): boolean;
|
|
33
|
+
export declare function seedArgvFromConfig(argv: Record<string, unknown>, fileConfig: GraphQLSDKConfigTarget): Record<string, unknown>;
|
|
34
|
+
export declare function buildGenerateOptions(answers: Record<string, unknown>, fileConfig?: GraphQLSDKConfigTarget): GraphQLSDKConfigTarget;
|
package/cli/shared.js
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.codegenQuestions = exports.splitCommas = void 0;
|
|
3
|
+
exports.hyphenateKeys = exports.camelizeArgv = exports.codegenQuestions = exports.splitCommas = void 0;
|
|
4
4
|
exports.printResult = printResult;
|
|
5
|
+
exports.filterDefined = filterDefined;
|
|
6
|
+
exports.flattenDbFields = flattenDbFields;
|
|
7
|
+
exports.buildDbConfig = buildDbConfig;
|
|
8
|
+
exports.normalizeCodegenListOptions = normalizeCodegenListOptions;
|
|
9
|
+
exports.hasResolvedCodegenSource = hasResolvedCodegenSource;
|
|
10
|
+
exports.seedArgvFromConfig = seedArgvFromConfig;
|
|
11
|
+
exports.buildGenerateOptions = buildGenerateOptions;
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
13
|
+
* Shared CLI utilities for graphql-codegen
|
|
14
|
+
*
|
|
15
|
+
* These are exported so that packages/cli can use the same questions,
|
|
16
|
+
* types, and transform utilities, ensuring consistency between the two CLIs.
|
|
7
17
|
*/
|
|
18
|
+
const inflekt_1 = require("inflekt");
|
|
19
|
+
const transform_keys_1 = require("inflekt/transform-keys");
|
|
8
20
|
const splitCommas = (input) => {
|
|
9
21
|
if (!input)
|
|
10
22
|
return undefined;
|
|
11
|
-
return input
|
|
23
|
+
return input
|
|
24
|
+
.split(',')
|
|
25
|
+
.map((s) => s.trim())
|
|
26
|
+
.filter(Boolean);
|
|
12
27
|
};
|
|
13
28
|
exports.splitCommas = splitCommas;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
function normalizeListOption(input) {
|
|
30
|
+
if (Array.isArray(input)) {
|
|
31
|
+
return input
|
|
32
|
+
.flatMap((item) => typeof item === 'string' ? ((0, exports.splitCommas)(item) ?? []) : [String(item)])
|
|
33
|
+
.map((s) => s.trim())
|
|
34
|
+
.filter(Boolean);
|
|
35
|
+
}
|
|
36
|
+
if (typeof input === 'string') {
|
|
37
|
+
return (0, exports.splitCommas)(input);
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
17
41
|
exports.codegenQuestions = [
|
|
18
42
|
{
|
|
19
43
|
name: 'endpoint',
|
|
@@ -22,7 +46,7 @@ exports.codegenQuestions = [
|
|
|
22
46
|
required: false,
|
|
23
47
|
},
|
|
24
48
|
{
|
|
25
|
-
name: '
|
|
49
|
+
name: 'schema-file',
|
|
26
50
|
message: 'Path to GraphQL schema file',
|
|
27
51
|
type: 'text',
|
|
28
52
|
required: false,
|
|
@@ -43,14 +67,14 @@ exports.codegenQuestions = [
|
|
|
43
67
|
sanitize: exports.splitCommas,
|
|
44
68
|
},
|
|
45
69
|
{
|
|
46
|
-
name: '
|
|
70
|
+
name: 'api-names',
|
|
47
71
|
message: 'API names (comma-separated)',
|
|
48
72
|
type: 'text',
|
|
49
73
|
required: false,
|
|
50
74
|
sanitize: exports.splitCommas,
|
|
51
75
|
},
|
|
52
76
|
{
|
|
53
|
-
name: '
|
|
77
|
+
name: 'react-query',
|
|
54
78
|
message: 'Generate React Query hooks?',
|
|
55
79
|
type: 'confirm',
|
|
56
80
|
required: false,
|
|
@@ -65,14 +89,6 @@ exports.codegenQuestions = [
|
|
|
65
89
|
default: false,
|
|
66
90
|
useDefault: true,
|
|
67
91
|
},
|
|
68
|
-
{
|
|
69
|
-
name: 'browserCompatible',
|
|
70
|
-
message: 'Generate browser-compatible code?',
|
|
71
|
-
type: 'confirm',
|
|
72
|
-
required: false,
|
|
73
|
-
default: true,
|
|
74
|
-
useDefault: true,
|
|
75
|
-
},
|
|
76
92
|
{
|
|
77
93
|
name: 'authorization',
|
|
78
94
|
message: 'Authorization header value',
|
|
@@ -80,7 +96,7 @@ exports.codegenQuestions = [
|
|
|
80
96
|
required: false,
|
|
81
97
|
},
|
|
82
98
|
{
|
|
83
|
-
name: '
|
|
99
|
+
name: 'dry-run',
|
|
84
100
|
message: 'Preview without writing files?',
|
|
85
101
|
type: 'confirm',
|
|
86
102
|
required: false,
|
|
@@ -96,9 +112,6 @@ exports.codegenQuestions = [
|
|
|
96
112
|
useDefault: true,
|
|
97
113
|
},
|
|
98
114
|
];
|
|
99
|
-
/**
|
|
100
|
-
* Print the result of a generate operation
|
|
101
|
-
*/
|
|
102
115
|
function printResult(result) {
|
|
103
116
|
if (result.success) {
|
|
104
117
|
console.log('[ok]', result.message);
|
|
@@ -112,3 +125,82 @@ function printResult(result) {
|
|
|
112
125
|
process.exit(1);
|
|
113
126
|
}
|
|
114
127
|
}
|
|
128
|
+
// ============================================================================
|
|
129
|
+
// Key transform utilities
|
|
130
|
+
// ============================================================================
|
|
131
|
+
const isTopLevel = (_key, path) => path.length === 0;
|
|
132
|
+
const skipNonTopLevel = (key, path) => !isTopLevel(key, path) || key === '_' || key.startsWith('_');
|
|
133
|
+
const camelizeArgv = (argv) => (0, transform_keys_1.inflektTree)(argv, (key) => {
|
|
134
|
+
const underscored = key.replace(/-/g, '_');
|
|
135
|
+
return (0, inflekt_1.camelize)(underscored, true);
|
|
136
|
+
}, { skip: skipNonTopLevel });
|
|
137
|
+
exports.camelizeArgv = camelizeArgv;
|
|
138
|
+
const hyphenateKeys = (obj) => (0, transform_keys_1.inflektTree)(obj, (key) => key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), {
|
|
139
|
+
skip: skipNonTopLevel,
|
|
140
|
+
});
|
|
141
|
+
exports.hyphenateKeys = hyphenateKeys;
|
|
142
|
+
// ============================================================================
|
|
143
|
+
// Config <-> CLI shape transforms
|
|
144
|
+
// ============================================================================
|
|
145
|
+
function filterDefined(obj) {
|
|
146
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined && v !== null));
|
|
147
|
+
}
|
|
148
|
+
function flattenDbFields(config) {
|
|
149
|
+
const { db, ...rest } = config;
|
|
150
|
+
if (db && typeof db === 'object') {
|
|
151
|
+
const dbObj = db;
|
|
152
|
+
const schemas = Array.isArray(dbObj.schemas)
|
|
153
|
+
? dbObj.schemas.join(',')
|
|
154
|
+
: dbObj.schemas;
|
|
155
|
+
const apiNames = Array.isArray(dbObj.apiNames)
|
|
156
|
+
? dbObj.apiNames.join(',')
|
|
157
|
+
: dbObj.apiNames;
|
|
158
|
+
return { ...rest, schemas, apiNames };
|
|
159
|
+
}
|
|
160
|
+
return rest;
|
|
161
|
+
}
|
|
162
|
+
function buildDbConfig(options) {
|
|
163
|
+
const { schemas, apiNames, ...rest } = options;
|
|
164
|
+
if (schemas || apiNames) {
|
|
165
|
+
return { ...rest, db: { schemas, apiNames } };
|
|
166
|
+
}
|
|
167
|
+
return rest;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Normalizes top-level list-like CLI options to string arrays.
|
|
171
|
+
* This keeps non-interactive paths equivalent to prompt sanitize behavior.
|
|
172
|
+
*/
|
|
173
|
+
function normalizeCodegenListOptions(options) {
|
|
174
|
+
return {
|
|
175
|
+
...options,
|
|
176
|
+
schemas: normalizeListOption(options.schemas),
|
|
177
|
+
apiNames: normalizeListOption(options.apiNames),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Returns true when source options are already available, so prompting can be skipped.
|
|
182
|
+
*/
|
|
183
|
+
function hasResolvedCodegenSource(options) {
|
|
184
|
+
const normalized = normalizeCodegenListOptions((0, exports.camelizeArgv)(options));
|
|
185
|
+
const db = normalized.db;
|
|
186
|
+
const dbSchemas = normalizeListOption(db?.schemas);
|
|
187
|
+
const dbApiNames = normalizeListOption(db?.apiNames);
|
|
188
|
+
return Boolean(normalized.endpoint ||
|
|
189
|
+
normalized.schemaFile ||
|
|
190
|
+
normalized.schemas?.length ||
|
|
191
|
+
normalized.apiNames?.length ||
|
|
192
|
+
dbSchemas?.length ||
|
|
193
|
+
dbApiNames?.length);
|
|
194
|
+
}
|
|
195
|
+
function seedArgvFromConfig(argv, fileConfig) {
|
|
196
|
+
const flat = flattenDbFields(fileConfig);
|
|
197
|
+
const hyphenated = (0, exports.hyphenateKeys)(flat);
|
|
198
|
+
const defined = filterDefined(hyphenated);
|
|
199
|
+
return { ...defined, ...argv };
|
|
200
|
+
}
|
|
201
|
+
function buildGenerateOptions(answers, fileConfig = {}) {
|
|
202
|
+
const camelized = (0, exports.camelizeArgv)(answers);
|
|
203
|
+
const normalized = normalizeCodegenListOptions(camelized);
|
|
204
|
+
const withDb = buildDbConfig(normalized);
|
|
205
|
+
return { ...fileConfig, ...withDb };
|
|
206
|
+
}
|
package/client/error.js
CHANGED
|
@@ -126,17 +126,35 @@ exports.PG_ERROR_CODES = {
|
|
|
126
126
|
// Error Factory
|
|
127
127
|
// ============================================================================
|
|
128
128
|
exports.createError = {
|
|
129
|
-
network: (originalError) => new DataError(exports.DataErrorType.NETWORK_ERROR, 'Network error occurred', {
|
|
130
|
-
|
|
129
|
+
network: (originalError) => new DataError(exports.DataErrorType.NETWORK_ERROR, 'Network error occurred', {
|
|
130
|
+
originalError,
|
|
131
|
+
}),
|
|
132
|
+
timeout: (originalError) => new DataError(exports.DataErrorType.TIMEOUT_ERROR, 'Request timed out', {
|
|
133
|
+
originalError,
|
|
134
|
+
}),
|
|
131
135
|
unauthorized: (message = 'Authentication required') => new DataError(exports.DataErrorType.UNAUTHORIZED, message),
|
|
132
136
|
forbidden: (message = 'Access forbidden') => new DataError(exports.DataErrorType.FORBIDDEN, message),
|
|
133
137
|
badRequest: (message, code) => new DataError(exports.DataErrorType.BAD_REQUEST, message, { code }),
|
|
134
138
|
notFound: (message = 'Resource not found') => new DataError(exports.DataErrorType.NOT_FOUND, message),
|
|
135
139
|
graphql: (message, code) => new DataError(exports.DataErrorType.GRAPHQL_ERROR, message, { code }),
|
|
136
|
-
uniqueViolation: (message, fieldName, constraint) => new DataError(exports.DataErrorType.UNIQUE_VIOLATION, message, {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
uniqueViolation: (message, fieldName, constraint) => new DataError(exports.DataErrorType.UNIQUE_VIOLATION, message, {
|
|
141
|
+
fieldName,
|
|
142
|
+
constraint,
|
|
143
|
+
code: '23505',
|
|
144
|
+
}),
|
|
145
|
+
foreignKeyViolation: (message, fieldName, constraint) => new DataError(exports.DataErrorType.FOREIGN_KEY_VIOLATION, message, {
|
|
146
|
+
fieldName,
|
|
147
|
+
constraint,
|
|
148
|
+
code: '23503',
|
|
149
|
+
}),
|
|
150
|
+
notNullViolation: (message, fieldName, constraint) => new DataError(exports.DataErrorType.NOT_NULL_VIOLATION, message, {
|
|
151
|
+
fieldName,
|
|
152
|
+
constraint,
|
|
153
|
+
code: '23502',
|
|
154
|
+
}),
|
|
155
|
+
unknown: (originalError) => new DataError(exports.DataErrorType.UNKNOWN_ERROR, originalError.message, {
|
|
156
|
+
originalError,
|
|
157
|
+
}),
|
|
140
158
|
};
|
|
141
159
|
function parseGraphQLErrorCode(code) {
|
|
142
160
|
if (!code)
|
|
@@ -167,10 +185,13 @@ function classifyByMessage(message) {
|
|
|
167
185
|
if (lower.includes('timeout') || lower.includes('timed out')) {
|
|
168
186
|
return exports.DataErrorType.TIMEOUT_ERROR;
|
|
169
187
|
}
|
|
170
|
-
if (lower.includes('network') ||
|
|
188
|
+
if (lower.includes('network') ||
|
|
189
|
+
lower.includes('fetch') ||
|
|
190
|
+
lower.includes('failed to fetch')) {
|
|
171
191
|
return exports.DataErrorType.NETWORK_ERROR;
|
|
172
192
|
}
|
|
173
|
-
if (lower.includes('unauthorized') ||
|
|
193
|
+
if (lower.includes('unauthorized') ||
|
|
194
|
+
lower.includes('authentication required')) {
|
|
174
195
|
return exports.DataErrorType.UNAUTHORIZED;
|
|
175
196
|
}
|
|
176
197
|
if (lower.includes('forbidden') || lower.includes('permission')) {
|
|
@@ -182,7 +203,8 @@ function classifyByMessage(message) {
|
|
|
182
203
|
if (lower.includes('foreign key constraint')) {
|
|
183
204
|
return exports.DataErrorType.FOREIGN_KEY_VIOLATION;
|
|
184
205
|
}
|
|
185
|
-
if (lower.includes('not-null constraint') ||
|
|
206
|
+
if (lower.includes('not-null constraint') ||
|
|
207
|
+
lower.includes('null value in column')) {
|
|
186
208
|
return exports.DataErrorType.NOT_NULL_VIOLATION;
|
|
187
209
|
}
|
|
188
210
|
return exports.DataErrorType.UNKNOWN_ERROR;
|
package/client/execute.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.execute = execute;
|
|
7
7
|
exports.createGraphQLClient = createGraphQLClient;
|
|
8
8
|
const graphql_1 = require("graphql");
|
|
9
|
-
const typed_document_1 = require("./typed-document");
|
|
10
9
|
const error_1 = require("./error");
|
|
10
|
+
const typed_document_1 = require("./typed-document");
|
|
11
11
|
// ============================================================================
|
|
12
12
|
// Helpers
|
|
13
13
|
// ============================================================================
|
|
@@ -102,7 +102,7 @@ async function handleHttpError(response) {
|
|
|
102
102
|
* Create a GraphQL client instance
|
|
103
103
|
*/
|
|
104
104
|
function createGraphQLClient(options) {
|
|
105
|
-
const { endpoint, headers: defaultHeaders = {}, timeout: defaultTimeout = 30000 } = options;
|
|
105
|
+
const { endpoint, headers: defaultHeaders = {}, timeout: defaultTimeout = 30000, } = options;
|
|
106
106
|
return {
|
|
107
107
|
/**
|
|
108
108
|
* Execute a GraphQL operation
|
package/client/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Client exports
|
|
3
3
|
*/
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
4
|
+
export { createError, DataError, type DataErrorOptions, DataErrorType, type GraphQLError, isDataError, parseGraphQLError, PG_ERROR_CODES, } from './error';
|
|
5
|
+
export { createGraphQLClient, execute, type ExecuteOptions, type GraphQLClient, type GraphQLClientOptions, type GraphQLResponse, } from './execute';
|
|
6
|
+
export { type DocumentTypeDecoration, TypedDocumentString, } from './typed-document';
|
package/client/index.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* Client exports
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
var typed_document_1 = require("./typed-document");
|
|
8
|
-
Object.defineProperty(exports, "TypedDocumentString", { enumerable: true, get: function () { return typed_document_1.TypedDocumentString; } });
|
|
6
|
+
exports.TypedDocumentString = exports.execute = exports.createGraphQLClient = exports.PG_ERROR_CODES = exports.parseGraphQLError = exports.isDataError = exports.DataErrorType = exports.DataError = exports.createError = void 0;
|
|
9
7
|
var error_1 = require("./error");
|
|
8
|
+
Object.defineProperty(exports, "createError", { enumerable: true, get: function () { return error_1.createError; } });
|
|
10
9
|
Object.defineProperty(exports, "DataError", { enumerable: true, get: function () { return error_1.DataError; } });
|
|
11
10
|
Object.defineProperty(exports, "DataErrorType", { enumerable: true, get: function () { return error_1.DataErrorType; } });
|
|
12
|
-
Object.defineProperty(exports, "createError", { enumerable: true, get: function () { return error_1.createError; } });
|
|
13
|
-
Object.defineProperty(exports, "parseGraphQLError", { enumerable: true, get: function () { return error_1.parseGraphQLError; } });
|
|
14
11
|
Object.defineProperty(exports, "isDataError", { enumerable: true, get: function () { return error_1.isDataError; } });
|
|
12
|
+
Object.defineProperty(exports, "parseGraphQLError", { enumerable: true, get: function () { return error_1.parseGraphQLError; } });
|
|
15
13
|
Object.defineProperty(exports, "PG_ERROR_CODES", { enumerable: true, get: function () { return error_1.PG_ERROR_CODES; } });
|
|
16
14
|
var execute_1 = require("./execute");
|
|
17
|
-
Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return execute_1.execute; } });
|
|
18
15
|
Object.defineProperty(exports, "createGraphQLClient", { enumerable: true, get: function () { return execute_1.createGraphQLClient; } });
|
|
16
|
+
Object.defineProperty(exports, "execute", { enumerable: true, get: function () { return execute_1.execute; } });
|
|
17
|
+
var typed_document_1 = require("./typed-document");
|
|
18
|
+
Object.defineProperty(exports, "TypedDocumentString", { enumerable: true, get: function () { return typed_document_1.TypedDocumentString; } });
|
package/core/ast.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DocumentNode, FieldNode } from 'graphql';
|
|
2
|
-
import type { ASTFunctionParams,
|
|
2
|
+
import type { ASTFunctionParams, MutationASTParams, QueryFieldSelection } from './types';
|
|
3
3
|
export declare const getAll: ({ queryName, operationName, selection, }: ASTFunctionParams) => DocumentNode;
|
|
4
4
|
export declare const getCount: ({ queryName, operationName, query, }: Omit<ASTFunctionParams, "selection">) => DocumentNode;
|
|
5
5
|
export declare const getMany: ({ builder, queryName, operationName, query, selection, }: ASTFunctionParams) => DocumentNode;
|
package/core/ast.js
CHANGED
|
@@ -571,7 +571,7 @@ function getUpdateVariablesAst(attrs, patchers) {
|
|
|
571
571
|
const patchVariables = attrs
|
|
572
572
|
.filter((field) => !patchers.includes(field.name))
|
|
573
573
|
.map((field) => {
|
|
574
|
-
const { name: fieldName, type: fieldType, isArray, isArrayNotNull } = field;
|
|
574
|
+
const { name: fieldName, type: fieldType, isArray, isArrayNotNull, } = field;
|
|
575
575
|
let type = t.namedType({ type: fieldType });
|
|
576
576
|
if (isArray) {
|
|
577
577
|
type = t.listType({ type });
|
|
@@ -36,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.commentLine = exports.commentBlock = exports.
|
|
39
|
+
exports.commentLine = exports.commentBlock = exports.t = exports.generate = void 0;
|
|
40
40
|
exports.generateCode = generateCode;
|
|
41
41
|
exports.addJSDocComment = addJSDocComment;
|
|
42
42
|
exports.addLineComment = addLineComment;
|
|
@@ -96,7 +96,7 @@ exports.commentLine = commentLine;
|
|
|
96
96
|
function addJSDocComment(node, lines) {
|
|
97
97
|
const commentText = lines.length === 1
|
|
98
98
|
? `* ${lines[0]} `
|
|
99
|
-
: `*\n${lines.map(line => ` * ${line}`).join('\n')}\n `;
|
|
99
|
+
: `*\n${lines.map((line) => ` * ${line}`).join('\n')}\n `;
|
|
100
100
|
if (!node.leadingComments) {
|
|
101
101
|
node.leadingComments = [];
|
|
102
102
|
}
|
package/core/codegen/barrel.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Barrel file generators - creates index.ts files for exports
|
|
3
|
-
*
|
|
4
|
-
* Using Babel AST for generating barrel (index.ts) files with re-exports.
|
|
5
|
-
*/
|
|
6
1
|
import type { CleanTable } from '../../types/schema';
|
|
7
2
|
/**
|
|
8
3
|
* Generate the queries/index.ts barrel file
|
|
@@ -19,7 +14,6 @@ export declare function generateMutationsBarrel(tables: CleanTable[]): string;
|
|
|
19
14
|
* @param hasSchemaTypes - Whether schema-types.ts was generated
|
|
20
15
|
*/
|
|
21
16
|
export interface MainBarrelOptions {
|
|
22
|
-
hasSchemaTypes?: boolean;
|
|
23
17
|
hasMutations?: boolean;
|
|
24
18
|
/** Whether query-keys.ts was generated */
|
|
25
19
|
hasQueryKeys?: boolean;
|